[v3,01/11] devtools: warn when adding some pthread calls

Message ID 20230913114351.1940459-2-thomas@monjalon.net (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series rework thread management |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon Sept. 13, 2023, 11:28 a.m. UTC
  All pthread functions below have an equivalent in rte_thread API:
	- pthread_create
	- pthread_join
	- pthread_detach
	- pthread_setname_np
	- pthread_set_name_np
	- pthread_setaffinity_np
	- pthread_attr_setinheritsched
	- pthread_attr_setschedpolicy
Usage of these functions will be raised to encourage rte_thread adoption.

The pthread functions for locks and cancel are still allowed.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

---
v2: replace (|_) with _?
---
 devtools/checkpatches.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
  

Patch

diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index 55fabc5458..ec9d232393 100755
--- a/devtools/checkpatches.sh
+++ b/devtools/checkpatches.sh
@@ -119,6 +119,14 @@  check_forbidden_additions() { # <patch>
 		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
 		"$1" || res=1
 
+	# refrain from using some pthread functions
+	awk -v FOLDERS="lib drivers app examples" \
+		-v EXPRESSIONS="pthread_(create|join|detach|set(_?name_np|affinity_np)|attr_set(inheritsched|schedpolicy))\\\(" \
+		-v RET_ON_FAIL=1 \
+		-v MESSAGE='Using pthread functions, prefer rte_thread' \
+		-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
+		"$1" || res=1
+
 	# forbid use of __reserved which is a reserved keyword in Windows system headers
 	awk -v FOLDERS="lib drivers app examples" \
 		-v EXPRESSIONS='\\<__reserved\\>' \