Skip to contentSkip to conversation

devtools: add tracepoint check in checkpatch

PATCH Superseded Ankur Dwivedi 5 participants 40 messages Oct 12, 2022 – Mar 31

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 devtools: add tracepoint check in checkpatch

This patch adds a check in checkpatch tool, to check if a tracepoint is present in any new function added in cryptodev library.

It uses the existing build_map_changes() function and version.map file to create a list of newly added functions. The definition of these functions are checked if they contain tracepoint. The checkpatch return error if the tracepoint is not present.

For functions for which trace is not needed, they can be appended to devtools/trace-skiplist.txt file. The above tracepoint check will be skipped for them.

---
 devtools/check-symbol-change.sh | 76 +-------------------------------
 devtools/check-tracepoint.py    | 52 ++++++++++++++++++++++
 devtools/check-tracepoint.sh    | 65 ++++++++++++++++++++++++++++
 devtools/checkpatches.sh        |  9 ++++
 devtools/common-func.sh         | 77 +++++++++++++++++++++++++++++++++
 devtools/trace-skiplist.txt     |  0
 6 files changed, 205 insertions(+), 74 deletions(-)
 create mode 100755 devtools/check-tracepoint.py
 create mode 100755 devtools/check-tracepoint.sh
 create mode 100644 devtools/common-func.sh
 create mode 100644 devtools/trace-skiplist.txt
devtools/check-symbol-change.sh +2 -74
index 8992214ac8..4bdd0d727a 100755
@@ -2,80 +2,8 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Neil Horman <[email protected]>
 
-build_map_changes()
-{
-	local fname="$1"
-	local mapdb="$2"
-
-	cat "$fname" | awk '
-		# Initialize our variables
-		BEGIN {map="";sym="";ar="";sec=""; in_sec=0; in_map=0}
-
-		# Anything that starts with + or -, followed by an a
-		# and ends in the string .map is the name of our map file
-		# This may appear multiple times in a patch if multiple
-		# map files are altered, and all section/symbol names
-		# appearing between a triggering of this rule and the
-		# next trigger of this rule are associated with this file
-		/[-+] [ab]\/.*\.map/ {map=$2; in_map=1; next}
-
-		# The previous rule catches all .map files, anything else
-		# indicates we left the map chunk.
-		/[-+] [ab]\// {in_map=0}
-
-		# Triggering this rule, which starts a line and ends it
-		# with a { identifies a versioned section.  The section name is
-		# the rest of the line with the + and { symbols removed.
-		# Triggering this rule sets in_sec to 1, which actives the
-		# symbol rule below
-		/^.*{/ {
-			gsub("+", "");
-			if (in_map == 1) {
-				sec=$(NF-1); in_sec=1;
-			}
-		}
-
-		# This rule identifies the end of a section, and disables the
-		# symbol rule
-		/.*}/ {in_sec=0}
-
-		# This rule matches on a + followed by any characters except a :
-		# (which denotes a global vs local segment), and ends with a ;.
-		# The semicolon is removed and the symbol is printed with its
-		# association file name and version section, along with an
-		# indicator that the symbol is a new addition.  Note this rule
-		# only works if we have found a version section in the rule
-		# above (hence the in_sec check) And found a map file (the
-		# in_map check).  If we are not in a map chunk, do nothing.  If
-		# we are in a map chunk but not a section chunk, record it as
-		# unknown.
-		/^+[^}].*[^:*];/ {gsub(";","");sym=$2;
-			if (in_map == 1) {
-				if (in_sec == 1) {
-					print map " " sym " " sec " add"
-				} else {
-					print map " " sym " unknown add"
-				}
-			}
-		}
-
-		# This is the same rule as above, but the rule matches on a
-		# leading - rather than a +, denoting that the symbol is being
-		# removed.
-		/^-[^}].*[^:*];/ {gsub(";","");sym=$2;
-			if (in_map == 1) {
-				if (in_sec == 1) {
-					print map " " sym " " sec " del"
-				} else {
-					print map " " sym " unknown del"
-				}
-			}
-		}' > "$mapdb"
-
-		sort -u "$mapdb" > "$mapdb.2"
-		mv -f "$mapdb.2" "$mapdb"
-
-}
+selfdir=$(dirname $(readlink -f $0))
+. $selfdir/common-func.sh
 
 is_stable_section() {
 	[ "$1" != 'EXPERIMENTAL' ] && [ "$1" != 'INTERNAL' ]
devtools/check-tracepoint.py new file +52 -0

52 lines not on this page · raw message

devtools/check-tracepoint.sh new file +65 -0

65 lines not on this page · raw message

devtools/checkpatches.sh +9 -0
index 1f1175c4f1..7392560460 100755
@@ -10,6 +10,7 @@
 . $(dirname $(readlink -f $0))/load-devel-config
 
 VALIDATE_NEW_API=$(dirname $(readlink -f $0))/check-symbol-change.sh
+VALIDATE_TRACEPOINT=$(dirname $(readlink -f $0))/check-tracepoint.sh
 
 # Enable codespell by default. This can be overwritten from a config file.
 # Codespell can also be enabled by setting DPDK_CHECKPATCH_CODESPELL to a valid path
@@ -352,6 +353,14 @@ check () { # <patch> <commit> <title>
 		ret=1
 	fi
 
+	! $verbose || printf '\nChecking API additions with tracepoint :\n'
+	report=$($VALIDATE_TRACEPOINT "$tmpinput")
+	if [ $? -ne 0 ] ; then
+		$headline_printed || print_headline "$3"
+		printf '%s\n' "$report"
+		ret=1
+	fi
+
 	if [ "$tmpinput" != "$1" ]; then
 		rm -f "$tmpinput"
 		trap - INT
devtools/common-func.sh new file +77 -0

77 lines not on this page · raw message

devtools/trace-skiplist.txt new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
Signature · 1 line
2.28.0
#1 lore raw

PATCH v2 1/1 devtools: add tracepoint check in checkpatch

This patch adds a check in checkpatch tool, to check if a tracepoint is present in any new function added in cryptodev library.

It uses the existing build_map_changes() function and version.map file to create a list of newly added functions. The definition of these functions are checked if they contain tracepoint. The checkpatch return error if the tracepoint is not present.

For functions for which trace is not needed, they can be appended to devtools/trace-skiplist.txt file. The above tracepoint check will be skipped for them.

---
v2:
- Add check for parent directory.

 devtools/check-symbol-change.sh | 76 +-------------------------------
 devtools/check-tracepoint.py    | 52 ++++++++++++++++++++++
 devtools/check-tracepoint.sh    | 66 ++++++++++++++++++++++++++++
 devtools/checkpatches.sh        |  9 ++++
 devtools/common-func.sh         | 77 +++++++++++++++++++++++++++++++++
 devtools/trace-skiplist.txt     |  0
 6 files changed, 206 insertions(+), 74 deletions(-)
 create mode 100755 devtools/check-tracepoint.py
 create mode 100755 devtools/check-tracepoint.sh
 create mode 100644 devtools/common-func.sh
 create mode 100644 devtools/trace-skiplist.txt
devtools/check-symbol-change.sh +2 -74
index 8992214ac8..4bdd0d727a 100755
@@ -2,80 +2,8 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Neil Horman <[email protected]>
 
-build_map_changes()
-{
-	local fname="$1"
-	local mapdb="$2"
-
-	cat "$fname" | awk '
-		# Initialize our variables
-		BEGIN {map="";sym="";ar="";sec=""; in_sec=0; in_map=0}
-
-		# Anything that starts with + or -, followed by an a
-		# and ends in the string .map is the name of our map file
-		# This may appear multiple times in a patch if multiple
-		# map files are altered, and all section/symbol names
-		# appearing between a triggering of this rule and the
-		# next trigger of this rule are associated with this file
-		/[-+] [ab]\/.*\.map/ {map=$2; in_map=1; next}
-
-		# The previous rule catches all .map files, anything else
-		# indicates we left the map chunk.
-		/[-+] [ab]\// {in_map=0}
-
-		# Triggering this rule, which starts a line and ends it
-		# with a { identifies a versioned section.  The section name is
-		# the rest of the line with the + and { symbols removed.
-		# Triggering this rule sets in_sec to 1, which actives the
-		# symbol rule below
-		/^.*{/ {
-			gsub("+", "");
-			if (in_map == 1) {
-				sec=$(NF-1); in_sec=1;
-			}
-		}
-
-		# This rule identifies the end of a section, and disables the
-		# symbol rule
-		/.*}/ {in_sec=0}
-
-		# This rule matches on a + followed by any characters except a :
-		# (which denotes a global vs local segment), and ends with a ;.
-		# The semicolon is removed and the symbol is printed with its
-		# association file name and version section, along with an
-		# indicator that the symbol is a new addition.  Note this rule
-		# only works if we have found a version section in the rule
-		# above (hence the in_sec check) And found a map file (the
-		# in_map check).  If we are not in a map chunk, do nothing.  If
-		# we are in a map chunk but not a section chunk, record it as
-		# unknown.
-		/^+[^}].*[^:*];/ {gsub(";","");sym=$2;
-			if (in_map == 1) {
-				if (in_sec == 1) {
-					print map " " sym " " sec " add"
-				} else {
-					print map " " sym " unknown add"
-				}
-			}
-		}
-
-		# This is the same rule as above, but the rule matches on a
-		# leading - rather than a +, denoting that the symbol is being
-		# removed.
-		/^-[^}].*[^:*];/ {gsub(";","");sym=$2;
-			if (in_map == 1) {
-				if (in_sec == 1) {
-					print map " " sym " " sec " del"
-				} else {
-					print map " " sym " unknown del"
-				}
-			}
-		}' > "$mapdb"
-
-		sort -u "$mapdb" > "$mapdb.2"
-		mv -f "$mapdb.2" "$mapdb"
-
-}
+selfdir=$(dirname $(readlink -f $0))
+. $selfdir/common-func.sh
 
 is_stable_section() {
 	[ "$1" != 'EXPERIMENTAL' ] && [ "$1" != 'INTERNAL' ]
devtools/check-tracepoint.py new file +52 -0

52 lines not on this page · raw message

devtools/check-tracepoint.sh new file +66 -0

66 lines not on this page · raw message

devtools/checkpatches.sh +9 -0
index 1f1175c4f1..7392560460 100755
@@ -10,6 +10,7 @@
 . $(dirname $(readlink -f $0))/load-devel-config
 
 VALIDATE_NEW_API=$(dirname $(readlink -f $0))/check-symbol-change.sh
+VALIDATE_TRACEPOINT=$(dirname $(readlink -f $0))/check-tracepoint.sh
 
 # Enable codespell by default. This can be overwritten from a config file.
 # Codespell can also be enabled by setting DPDK_CHECKPATCH_CODESPELL to a valid path
@@ -352,6 +353,14 @@ check () { # <patch> <commit> <title>
 		ret=1
 	fi
 
+	! $verbose || printf '\nChecking API additions with tracepoint :\n'
+	report=$($VALIDATE_TRACEPOINT "$tmpinput")
+	if [ $? -ne 0 ] ; then
+		$headline_printed || print_headline "$3"
+		printf '%s\n' "$report"
+		ret=1
+	fi
+
 	if [ "$tmpinput" != "$1" ]; then
 		rm -f "$tmpinput"
 		trap - INT
devtools/common-func.sh new file +77 -0

77 lines not on this page · raw message

devtools/trace-skiplist.txt new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
Signature · 1 line
2.28.0
#2 lore raw

12/10/2022 13:45, Ankur Dwivedi:

Quoted 6 lines
 devtools/check-symbol-change.sh | 76 +-------------------------------
 devtools/check-tracepoint.py    | 52 ++++++++++++++++++++++
 devtools/check-tracepoint.sh    | 66 ++++++++++++++++++++++++++++
 devtools/checkpatches.sh        |  9 ++++
 devtools/common-func.sh         | 77 +++++++++++++++++++++++++++++++++
 devtools/trace-skiplist.txt     |  0

Before diving into this proposal,
I would like a split of the patch for the rework (and move) of check-symbol-change.sh alone.

In general I see too many files added:
check-tracepoint.py and check-tracepoint.sh
common-func.sh is probably a bad name.

#3 lore raw
Quoted 23 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, October 12, 2022 6:39 PM
To: Ankur Dwivedi <[email protected]>
Cc: [email protected]; Akhil Goyal <[email protected]>; [email protected]; Amit Prakash Shukla <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Ankur Dwivedi <[email protected]>; [email protected]
Subject: [EXT] Re: [PATCH v2] devtools: add tracepoint check in checkpatch

External Email

----------------------------------------------------------------------
12/10/2022 13:45, Ankur Dwivedi:

Quoted 6 lines
 devtools/check-symbol-change.sh | 76 +-------------------------------
 devtools/check-tracepoint.py    | 52 ++++++++++++++++++++++
 devtools/check-tracepoint.sh    | 66 ++++++++++++++++++++++++++++
 devtools/checkpatches.sh        |  9 ++++
 devtools/common-func.sh         | 77 +++++++++++++++++++++++++++++++++
 devtools/trace-skiplist.txt     |  0
Quoted 3 lines

Before diving into this proposal,
I would like a split of the patch for the rework (and move) of check-symbol- change.sh alone.

Will split the patch in next version.

Quoted 4 lines

In general I see too many files added:
check-tracepoint.py and check-tracepoint.sh common-func.sh is
probably a bad name.

Regarding common-func.sh name, I am thinking of renaming it to common.sh or helper.sh, considering there may be more common shell routines in future. Otherwise it can be renamed to build-map.sh considering it will contain only build_map_changes() function. Please suggest a suitable name if my suggested names are bad.

Will try to combine check-tracepoint.py and check-tracepoint.sh.

Quoted 1 line
#4 lore raw

12/10/2022 17:16, Ankur Dwivedi:

Quoted 27 lines
Quoted 22 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, October 12, 2022 6:39 PM
To: Ankur Dwivedi <[email protected]>
Cc: [email protected]; Akhil Goyal <[email protected]>; [email protected]; Amit Prakash Shukla <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Ankur Dwivedi <[email protected]>; [email protected]
Subject: [EXT] Re: [PATCH v2] devtools: add tracepoint check in checkpatch

External Email

----------------------------------------------------------------------
12/10/2022 13:45, Ankur Dwivedi:

Quoted 6 lines
 devtools/check-symbol-change.sh | 76 +-------------------------------
 devtools/check-tracepoint.py    | 52 ++++++++++++++++++++++
 devtools/check-tracepoint.sh    | 66 ++++++++++++++++++++++++++++
 devtools/checkpatches.sh        |  9 ++++
 devtools/common-func.sh         | 77 +++++++++++++++++++++++++++++++++
 devtools/trace-skiplist.txt     |  0
Quoted 3 lines

Before diving into this proposal,
I would like a split of the patch for the rework (and move) of check-symbol- change.sh alone.

Will split the patch in next version.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

In general I see too many files added:
check-tracepoint.py and check-tracepoint.sh common-func.sh is
probably a bad name.

Regarding common-func.sh name, I am thinking of renaming it to common.sh or helper.sh, considering there may be more common shell routines in future. Otherwise it can be renamed to build-map.sh considering it will contain only build_map_changes() function. Please suggest a suitable name if my suggested names are bad.

Will try to combine check-tracepoint.py and check-tracepoint.sh.

There are many very different scripts in devtools.
Having a very common script won't work well.
Please keep scripts specialized.
If you need a script to check symbol, it should include "symbol" in its name.

#5 lore raw

v3 cover devtools: add tracepoint check in checkpatch

In reply to Ankur Dwivedi

This patch series adds a validation in checkpatch tool to check if tracepoint is present in any new function added in cryptodev library.

The first patch in the series moves build_map_changes function from check-symbol-change.sh to a new file build-symbol-map.sh.

The second patch in the series adds a new script file check-tracepoint.sh which is called from checkpatch tool. The check-tracepoint.sh contains the code to detect the presence of tracepoint in a new function added to cryptodev library.

v3:
- Split the v2 patch into 2 patches.
- The file common-func.sh is renamed to build-symbol-map.sh.
- Removed check-tracepoint.py file.
- Code improvements in check-tracepoint.sh.

v2:
- Add check for parent directory.

Ankur Dwivedi (2):
devtools: move build symbol map function
devtools: add tracepoint check in checkpatch

 devtools/build-symbol-map.sh    |  77 +++++++++++++++++++
 devtools/check-symbol-change.sh |  76 +------------------
 devtools/check-tracepoint.sh    | 129 ++++++++++++++++++++++++++++++++
 devtools/checkpatches.sh        |   9 +++
 devtools/trace-skiplist.txt     |   0
 5 files changed, 217 insertions(+), 74 deletions(-)
 create mode 100644 devtools/build-symbol-map.sh
 create mode 100755 devtools/check-tracepoint.sh
 create mode 100644 devtools/trace-skiplist.txt
Signature · 1 line
2.28.0
#6 lore raw

PATCH v3 1/2 devtools: move build symbol map function

This patch moves the build_map_changes function from check-symbol-change.sh to a new build-symbol-map.sh file. This function can be used in other scripts by including build-symbol-map.sh file.

---
 devtools/build-symbol-map.sh    | 77 +++++++++++++++++++++++++++++++++
 devtools/check-symbol-change.sh | 76 +-------------------------------
 2 files changed, 79 insertions(+), 74 deletions(-)
 create mode 100644 devtools/build-symbol-map.sh
devtools/build-symbol-map.sh new file +77 -0
new file mode 100644
index 0000000000..c88e949890
@@ -0,0 +1,77 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Neil Horman <[email protected]>
+
+build_map_changes()
+{
+	local fname="$1"
+	local mapdb="$2"
+
+	cat "$fname" | awk '
+		# Initialize our variables
+		BEGIN {map="";sym="";ar="";sec=""; in_sec=0; in_map=0}
+
+		# Anything that starts with + or -, followed by an a
+		# and ends in the string .map is the name of our map file
+		# This may appear multiple times in a patch if multiple
+		# map files are altered, and all section/symbol names
+		# appearing between a triggering of this rule and the
+		# next trigger of this rule are associated with this file
+		/[-+] [ab]\/.*\.map/ {map=$2; in_map=1; next}
+
+		# The previous rule catches all .map files, anything else
+		# indicates we left the map chunk.
+		/[-+] [ab]\// {in_map=0}
+
+		# Triggering this rule, which starts a line and ends it
+		# with a { identifies a versioned section.  The section name is
+		# the rest of the line with the + and { symbols removed.
+		# Triggering this rule sets in_sec to 1, which actives the
+		# symbol rule below
+		/^.*{/ {
+			gsub("+", "");
+			if (in_map == 1) {
+				sec=$(NF-1); in_sec=1;
+			}
+		}
+
+		# This rule identifies the end of a section, and disables the
+		# symbol rule
+		/.*}/ {in_sec=0}
+
+		# This rule matches on a + followed by any characters except a :
+		# (which denotes a global vs local segment), and ends with a ;.
+		# The semicolon is removed and the symbol is printed with its
+		# association file name and version section, along with an
+		# indicator that the symbol is a new addition.  Note this rule
+		# only works if we have found a version section in the rule
+		# above (hence the in_sec check) And found a map file (the
+		# in_map check).  If we are not in a map chunk, do nothing.  If
+		# we are in a map chunk but not a section chunk, record it as
+		# unknown.
+		/^+[^}].*[^:*];/ {gsub(";","");sym=$2;
+			if (in_map == 1) {
+				if (in_sec == 1) {
+					print map " " sym " " sec " add"
+				} else {
+					print map " " sym " unknown add"
+				}
+			}
+		}
+
+		# This is the same rule as above, but the rule matches on a
+		# leading - rather than a +, denoting that the symbol is being
+		# removed.
+		/^-[^}].*[^:*];/ {gsub(";","");sym=$2;
+			if (in_map == 1) {
+				if (in_sec == 1) {
+					print map " " sym " " sec " del"
+				} else {
+					print map " " sym " unknown del"
+				}
+			}
+		}' > "$mapdb"
+
+		sort -u "$mapdb" > "$mapdb.2"
+		mv -f "$mapdb.2" "$mapdb"
+}
devtools/check-symbol-change.sh +2 -74

82 lines not on this page · raw message

Signature · 1 line
2.28.0
#7 lore raw

PATCH v3 2/2 devtools: add tracepoint check in checkpatch

In reply to Ankur Dwivedi

This patch adds a validation in checkpatch tool, to check if a tracepoint is present in any new function added in cryptodev library.

It uses the existing build_map_changes function to create a map of functions. In the map, the newly added functions are identified and their definition are checked for the presence of tracepoint. The checkpatch return error if the tracepoint is not present.

For functions for which trace is not needed, they can be added to devtools/trace-skiplist.txt file. The above tracepoint check will be skipped for them.

---
 devtools/check-tracepoint.sh | 129 +++++++++++++++++++++++++++++++++++
 devtools/checkpatches.sh     |   9 +++
 devtools/trace-skiplist.txt  |   0
 3 files changed, 138 insertions(+)
 create mode 100755 devtools/check-tracepoint.sh
 create mode 100644 devtools/trace-skiplist.txt
devtools/check-tracepoint.sh new file +129 -0
new file mode 100755
index 0000000000..2e8a33758c
@@ -0,0 +1,129 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (C) 2022 Marvell.
+
+selfdir=$(dirname $(readlink -f $0))
+. $selfdir/build-symbol-map.sh
+
+# Library for trace check
+libdir="cryptodev"
+
+# Functions for which the trace check can be skipped
+skiplist="$selfdir/trace-skiplist.txt"
+
+find_trace_fn()
+{
+	local fname="$1"
+
+	cat "$fname" | awk -v symname="$2 *\\\(" '
+		# Initialize the variables.
+		# The variable symname provides a pattern to match
+		# "function_name(", zero or more spaces can be present
+		# between function_name and (.
+		BEGIN {found=0; fndef=""}
+
+		# Matches the function name, set found=1.
+		$0 ~ symname {found=1}
+
+		# If closing parentheses with semicolon ");" is found, then it
+		# is not the function definition.
+		/) *;/ {
+			if (found == 1) {
+				found=0
+			}
+		}
+
+		# If closing parentheses is found, this is the start of function
+		# definition. Check for tracepoint in the function definition.
+		# The tracepoint has _trace_ in its name.
+		/)/ {
+			if (found == 1) {
+				while (index($0, "}") == 0) {
+					if (index($0, "_trace_") != 0) {
+						exit 0
+					}
+					if (getline <= 0) {
+						break
+					}
+				}
+				exit 1
+			}
+		}
+	'
+}
+
+check_for_tracepoint()
+{
+	local patch="$1"
+	local mapdb="$2"
+	local skip_sym
+	local libname
+	local secname
+	local mname
+	local ret=0
+	local pdir
+	local libp
+	local libn
+	local sym
+	local ar
+
+	while read -r mname symname secname ar; do
+		pdir=$(echo $mname | awk 'BEGIN {FS="/"};{print $2}')
+		libname=$(echo $mname | awk 'BEGIN {FS="/"};{print $3}')
+		skip_sym=0
+		libp=0
+
+		if [ "$pdir" != "lib" ]; then
+			continue
+		fi
+
+		for libn in $libdir; do
+			if [ $libn = $libname ]; then
+				libp=1
+				break
+			fi
+		done
+
+		if [ $libp -eq 0 ]; then
+			continue
+		fi
+
+		for sym in $(cat $skiplist); do
+			if [ $sym = $symname ]; then
+				skip_sym=1
+				break
+			fi
+		done
+
+		if [ $skip_sym -eq 1 ]; then
+			continue
+		fi
+
+		if [ "$ar" = "add" ] && [ "$secname" = "EXPERIMENTAL" ]; then
+			# Check if new API is added with tracepoint
+			find_trace_fn $patch $symname
+			if [ $? -eq 1 ]; then
+				ret=1
+				echo -n "ERROR: New function $symname is added "
+				echo -n "without a tracepoint. Please add a tracepoint "
+				echo -n "or add the function $symname in "
+				echo "devtools/trace-skiplist.txt to skip this error."
+			fi
+		fi
+	done < "$mapdb"
+
+	return $ret
+}
+
+clean_and_exit_on_sig()
+{
+	rm -rf "$mapfile"
+}
+
+trap clean_and_exit_on_sig EXIT
+
+mapfile=$(mktemp -t dpdk.mapdb.XXXXXX)
+patch=$1
+
+build_map_changes "$patch" "$mapfile"
+check_for_tracepoint "$patch" "$mapfile"
devtools/checkpatches.sh +9 -0
index 1f1175c4f1..7392560460 100755
@@ -10,6 +10,7 @@
 . $(dirname $(readlink -f $0))/load-devel-config
 
 VALIDATE_NEW_API=$(dirname $(readlink -f $0))/check-symbol-change.sh
+VALIDATE_TRACEPOINT=$(dirname $(readlink -f $0))/check-tracepoint.sh
 
 # Enable codespell by default. This can be overwritten from a config file.
 # Codespell can also be enabled by setting DPDK_CHECKPATCH_CODESPELL to a valid path
@@ -352,6 +353,14 @@ check () { # <patch> <commit> <title>
 		ret=1
 	fi
 
+	! $verbose || printf '\nChecking API additions with tracepoint :\n'
+	report=$($VALIDATE_TRACEPOINT "$tmpinput")
+	if [ $? -ne 0 ] ; then
+		$headline_printed || print_headline "$3"
+		printf '%s\n' "$report"
+		ret=1
+	fi
+
 	if [ "$tmpinput" != "$1" ]; then
 		rm -f "$tmpinput"
 		trap - INT
devtools/trace-skiplist.txt new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
Signature · 1 line
2.28.0
#8 lore raw
In reply to Ankur Dwivedi

Hi Thomas,

Please let me know if this series can be included in 22.11 rc3.

Regards,
Ankur

Quoted 44 lines

-----Original Message-----
From: Ankur Dwivedi <[email protected]>
Sent: Saturday, October 15, 2022 6:28 PM
To: [email protected]
Cc: [email protected]; [email protected]; Akhil Goyal <[email protected]>; [email protected]; Amit Prakash Shukla <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; Ankur Dwivedi <[email protected]>
Subject: [PATCH v3 0/2] devtools: add tracepoint check in checkpatch

This patch series adds a validation in checkpatch tool to check if tracepoint is present in any new function added in cryptodev library.

The first patch in the series moves build_map_changes function from check- symbol-change.sh to a new file build-symbol-map.sh.

The second patch in the series adds a new script file check-tracepoint.sh which is called from checkpatch tool. The check-tracepoint.sh contains the code to detect the presence of tracepoint in a new function added to cryptodev library.

v3:
- Split the v2 patch into 2 patches.
- The file common-func.sh is renamed to build-symbol-map.sh.
- Removed check-tracepoint.py file.
- Code improvements in check-tracepoint.sh.

v2:
- Add check for parent directory.

Ankur Dwivedi (2):
devtools: move build symbol map function
devtools: add tracepoint check in checkpatch

devtools/build-symbol-map.sh    |  77 +++++++++++++++++++
devtools/check-symbol-change.sh |  76 +------------------
devtools/check-tracepoint.sh    | 129 ++++++++++++++++++++++++++++++++
devtools/checkpatches.sh        |   9 +++
devtools/trace-skiplist.txt     |   0
5 files changed, 217 insertions(+), 74 deletions(-)  create mode 100644

devtools/build-symbol-map.sh create mode 100755 devtools/check- tracepoint.sh create mode 100644 devtools/trace-skiplist.txt

--
2.28.0

#9 lore raw

v4 cover devtools: add tracepoint check in checkpatch

In reply to Ankur Dwivedi

This patch series adds a validation in checkpatch tool to check if tracepoint is present in any new function added in ethdev library.

The first patch in the series moves build_map_changes function from check-symbol-change.sh to a new file build-symbol-map.sh.

The second patch in the series adds a new script file check-tracepoint.sh which is called from checkpatch tool. The check-tracepoint.sh contains the code to detect the presence of tracepoint in a new function added to ethdev library.

v4:
- Rebased on the recent next-net branch.
- Refined logic to find function definition.
- Updated year in the license in devtools/check-tracepoint.sh.
- Removed cryptodev, added ethdev in libdir in devtools/check-tracepoint.sh.

v3:
- Split the v2 patch into 2 patches.
- The file common-func.sh is renamed to build-symbol-map.sh.
- Removed check-tracepoint.py file.
- Code improvements in check-tracepoint.sh.

v2:
- Add check for parent directory.

Ankur Dwivedi (2):
devtools: move build symbol map function
devtools: add tracepoint check in checkpatch

 devtools/build-symbol-map.sh    |  78 +++++++++++++++++
 devtools/check-symbol-change.sh |  76 +----------------
 devtools/check-tracepoint.sh    | 146 ++++++++++++++++++++++++++++++++
 devtools/checkpatches.sh        |   9 ++
 devtools/trace-skiplist.txt     |   0
 5 files changed, 235 insertions(+), 74 deletions(-)
 create mode 100755 devtools/build-symbol-map.sh
 create mode 100755 devtools/check-tracepoint.sh
 create mode 100644 devtools/trace-skiplist.txt
Signature · 1 line
2.25.1
#10 lore raw

PATCH v4 1/2 devtools: move build symbol map function

This patch moves the build_map_changes function from check-symbol-change.sh to a new build-symbol-map.sh file. This function can be used in other scripts by including build-symbol-map.sh file.

---
 devtools/build-symbol-map.sh    | 78 +++++++++++++++++++++++++++++++++
 devtools/check-symbol-change.sh | 76 +-------------------------------
 2 files changed, 80 insertions(+), 74 deletions(-)
 create mode 100755 devtools/build-symbol-map.sh
devtools/build-symbol-map.sh new file +78 -0
new file mode 100755
index 0000000000..86e4279cdc
@@ -0,0 +1,78 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Neil Horman <[email protected]>
+
+build_map_changes()
+{
+	local fname="$1"
+	local mapdb="$2"
+
+	cat "$fname" | awk '
+		# Initialize our variables
+		BEGIN {map="";sym="";ar="";sec=""; in_sec=0; in_map=0}
+
+		# Anything that starts with + or -, followed by an a
+		# and ends in the string .map is the name of our map file
+		# This may appear multiple times in a patch if multiple
+		# map files are altered, and all section/symbol names
+		# appearing between a triggering of this rule and the
+		# next trigger of this rule are associated with this file
+		/[-+] [ab]\/.*\.map/ {map=$2; in_map=1; next}
+
+		# The previous rule catches all .map files, anything else
+		# indicates we left the map chunk.
+		/[-+] [ab]\// {in_map=0}
+
+		# Triggering this rule, which starts a line and ends it
+		# with a { identifies a versioned section.  The section name is
+		# the rest of the line with the + and { symbols removed.
+		# Triggering this rule sets in_sec to 1, which actives the
+		# symbol rule below
+		/^.*{/ {
+			gsub("+", "");
+			if (in_map == 1) {
+				sec=$(NF-1); in_sec=1;
+			}
+		}
+
+		# This rule identifies the end of a section, and disables the
+		# symbol rule
+		/.*}/ {in_sec=0}
+
+		# This rule matches on a + followed by any characters except a :
+		# (which denotes a global vs local segment), and ends with a ;.
+		# The semicolon is removed and the symbol is printed with its
+		# association file name and version section, along with an
+		# indicator that the symbol is a new addition.  Note this rule
+		# only works if we have found a version section in the rule
+		# above (hence the in_sec check) And found a map file (the
+		# in_map check).  If we are not in a map chunk, do nothing.  If
+		# we are in a map chunk but not a section chunk, record it as
+		# unknown.
+		/^+[^}].*[^:*];/ {gsub(";","");sym=$2;
+			if (in_map == 1) {
+				if (in_sec == 1) {
+					print map " " sym " " sec " add"
+				} else {
+					print map " " sym " unknown add"
+				}
+			}
+		}
+
+		# This is the same rule as above, but the rule matches on a
+		# leading - rather than a +, denoting that the symbol is being
+		# removed.
+		/^-[^}].*[^:*];/ {gsub(";","");sym=$2;
+			if (in_map == 1) {
+				if (in_sec == 1) {
+					print map " " sym " " sec " del"
+				} else {
+					print map " " sym " unknown del"
+				}
+			}
+		}' > "$mapdb"
+
+		sort -u "$mapdb" > "$mapdb.2"
+		mv -f "$mapdb.2" "$mapdb"
+
+}
devtools/check-symbol-change.sh +2 -74

82 lines not on this page · raw message

Signature · 1 line
2.25.1
#11 lore raw

PATCH v4 2/2 devtools: add tracepoint check in checkpatch

In reply to Ankur Dwivedi

This patch adds a validation in checkpatch tool, to check if a tracepoint is present in any new function added in ethdev library.

It uses the existing build_map_changes function to create a map of functions. In the map, the newly added functions, added in the experimental section are identified and their definition are checked for the presence of tracepoint. The checkpatch return error if the tracepoint is not present.

For functions for which trace is not needed, they can be added to devtools/trace-skiplist.txt file. The above tracepoint check will be skipped for them.

---
 devtools/check-tracepoint.sh | 146 +++++++++++++++++++++++++++++++++++
 devtools/checkpatches.sh     |   9 +++
 devtools/trace-skiplist.txt  |   0
 3 files changed, 155 insertions(+)
 create mode 100755 devtools/check-tracepoint.sh
 create mode 100644 devtools/trace-skiplist.txt
devtools/check-tracepoint.sh new file +146 -0
new file mode 100755
index 0000000000..591d5cd397
@@ -0,0 +1,146 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (C) 2023 Marvell.
+
+selfdir=$(dirname $(readlink -f $0))
+. $selfdir/build-symbol-map.sh
+
+# Library for trace check
+libdir="ethdev"
+
+# Functions for which the trace check can be skipped
+skiplist="$selfdir/trace-skiplist.txt"
+
+find_trace_fn()
+{
+	local fname="$1"
+
+	cat "$fname" | awk -v symname="$2 *\\\(" '
+		# Initialize the variables.
+		# The variable symname provides a pattern to match
+		# "function_name(", zero or more spaces can be present
+		# between function_name and (.
+		BEGIN {found=0}
+
+		# Matches the function name, set found=1.
+		$0 ~ symname {found=1}
+
+		# If closing parentheses with semicolon ");" is found, then it
+		# is not the function definition.
+		/) *;/ {
+			if (found == 1) {
+				found=0
+			}
+		}
+
+		/)/ {
+			if (found == 1) {
+				ln_pth = NR
+			}
+		}
+
+		# If closing parentheses and then opening braces is found in
+		# adjacent line, then this is the start of function
+		# definition. Check for tracepoint in the function definition.
+		# The tracepoint has _trace_ in its name.
+		/{/ {
+			if (found == 1) {
+				if (ln_pth != NR - 1) {
+					found = 0
+					next
+				}
+				while (index($0, "}") != 2) {
+					if (index($0, "_trace_") != 0) {
+						exit 0
+					}
+					if (getline <= 0) {
+						break
+					}
+				}
+				exit 1
+			}
+		}
+	'
+}
+
+check_for_tracepoint()
+{
+	local patch="$1"
+	local mapdb="$2"
+	local skip_sym
+	local libname
+	local secname
+	local mname
+	local ret=0
+	local pdir
+	local libp
+	local libn
+	local sym
+	local ar
+
+	while read -r mname symname secname ar; do
+		pdir=$(echo $mname | awk 'BEGIN {FS="/"};{print $2}')
+		libname=$(echo $mname | awk 'BEGIN {FS="/"};{print $3}')
+		skip_sym=0
+		libp=0
+
+		if [ "$pdir" != "lib" ]; then
+			continue
+		fi
+
+		for libn in $libdir; do
+			if [ $libn = $libname ]; then
+				libp=1
+				break
+			fi
+		done
+
+		if [ $libp -eq 0 ]; then
+			continue
+		fi
+
+		for sym in $(cat $skiplist); do
+			if [ $sym = $symname ]; then
+				skip_sym=1
+				break
+			fi
+		done
+
+		if [ $skip_sym -eq 1 ]; then
+			continue
+		fi
+
+		if [ "$ar" = "add" ] && [ "$secname" = "EXPERIMENTAL" ]; then
+			# Check if new API is added with tracepoint
+			find_trace_fn $patch $symname
+			if [ $? -eq 1 ]; then
+				ret=1
+				echo -n "ERROR: New function $symname is added "
+				echo -n "without a tracepoint. Please add a tracepoint "
+				echo -n "or add the function $symname in "
+				echo "devtools/trace-skiplist.txt to skip this error."
+			fi
+		fi
+	done < "$mapdb"
+
+	return $ret
+}
+
+trap clean_and_exit_on_sig EXIT
+
+mapfile=`mktemp -t dpdk.mapdb.XXXXXX`
+patch=$1
+exit_code=1
+
+clean_and_exit_on_sig()
+{
+	rm -f "$mapfile"
+	exit $exit_code
+}
+
+build_map_changes "$patch" "$mapfile"
+check_for_tracepoint "$patch" "$mapfile"
+exit_code=$?
+rm -f "$mapfile"
+
+exit $exit_code
devtools/checkpatches.sh +9 -0
index 1dee094c7a..471db1d21b 100755
@@ -10,6 +10,7 @@
 . $(dirname $(readlink -f $0))/load-devel-config
 
 VALIDATE_NEW_API=$(dirname $(readlink -f $0))/check-symbol-change.sh
+VALIDATE_TRACEPOINT=$(dirname $(readlink -f $0))/check-tracepoint.sh
 
 # Enable codespell by default. This can be overwritten from a config file.
 # Codespell can also be enabled by setting DPDK_CHECKPATCH_CODESPELL to a valid path
@@ -386,6 +387,14 @@ check () { # <patch-file> <commit>
 		ret=1
 	fi
 
+	! $verbose || printf '\nChecking API additions with tracepoint :\n'
+	report=$($VALIDATE_TRACEPOINT "$tmpinput")
+	if [ $? -ne 0 ] ; then
+		$headline_printed || print_headline "$subject"
+		printf '%s\n' "$report"
+		ret=1
+	fi
+
 	if [ "$tmpinput" != "$1" ]; then
 		rm -f "$tmpinput"
 		trap - INT
devtools/trace-skiplist.txt new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
Signature · 1 line
2.25.1
#12 lore raw

v5 cover devtools: add tracepoint check in checkpatch

In reply to Ankur Dwivedi

This patch series adds a validation in checkpatch tool to check if tracepoint is present in any new function added in ethdev, eventdev cryptodev and mempool library.

v5:
- Copied the build_map_changes function from check-symbol-change.sh to check-tracepoint.sh.
- Added eventdev, cryptodev and mempool in libdir in check-tracepoint.sh.

v4:
- Rebased on the recent next-net branch.
- Refined logic to find function definition.
- Updated year in the license in devtools/check-tracepoint.sh.
- Removed cryptodev, added ethdev in libdir in devtools/check-tracepoint.sh.

v3:
- Split the v2 patch into 2 patches.
- The file common-func.sh is renamed to build-symbol-map.sh.
- Removed check-tracepoint.py file.
- Code improvements in check-tracepoint.sh.

v2:
- Add check for parent directory.

Ankur Dwivedi (1):
devtools: add tracepoint check in checkpatch

 devtools/check-tracepoint.sh | 223 +++++++++++++++++++++++++++++++++++
 devtools/checkpatches.sh     |   9 ++
 devtools/trace-skiplist.txt  |   0
 3 files changed, 232 insertions(+)
 create mode 100755 devtools/check-tracepoint.sh
 create mode 100644 devtools/trace-skiplist.txt
Signature · 1 line
2.25.1
#13 lore raw

PATCH v5 1/1 devtools: add tracepoint check in checkpatch

This patch adds a validation in checkpatch tool, to check if a tracepoint is present in any new function added in cryptodev, ethdev, eventdev and mempool library.

In this patch, the build_map_changes function is copied from check-symbol-change.sh to check-tracepoint.sh. The check-tracepoint.sh script uses build_map_changes function to create a map of functions. In the map, the newly added functions, added in the experimental section are identified and their definition are checked for the presence of tracepoint. The checkpatch return error if the tracepoint is not present.

For functions for which trace is not needed, they can be added to devtools/trace-skiplist.txt file. The above tracepoint check will be skipped for them.

---
 devtools/check-tracepoint.sh | 223 +++++++++++++++++++++++++++++++++++
 devtools/checkpatches.sh     |   9 ++
 devtools/trace-skiplist.txt  |   0
 3 files changed, 232 insertions(+)
 create mode 100755 devtools/check-tracepoint.sh
 create mode 100644 devtools/trace-skiplist.txt
devtools/check-tracepoint.sh new file +223 -0
new file mode 100755
index 0000000000..88d6b1fd53
@@ -0,0 +1,223 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Neil Horman <[email protected]>
+# Copyright(C) 2023 Marvell.
+
+selfdir=$(dirname $(readlink -f $0))
+
+# Library for trace check
+libdir="cryptodev ethdev eventdev mempool"
+
+# Functions for which the trace check can be skipped
+skiplist="$selfdir/trace-skiplist.txt"
+
+build_map_changes()
+{
+	local fname="$1"
+	local mapdb="$2"
+
+	cat "$fname" | awk '
+		# Initialize our variables
+		BEGIN {map="";sym="";ar="";sec=""; in_sec=0; in_map=0}
+
+		# Anything that starts with + or -, followed by an a
+		# and ends in the string .map is the name of our map file
+		# This may appear multiple times in a patch if multiple
+		# map files are altered, and all section/symbol names
+		# appearing between a triggering of this rule and the
+		# next trigger of this rule are associated with this file
+		/[-+] [ab]\/.*\.map/ {map=$2; in_map=1; next}
+
+		# The previous rule catches all .map files, anything else
+		# indicates we left the map chunk.
+		/[-+] [ab]\// {in_map=0}
+
+		# Triggering this rule, which starts a line and ends it
+		# with a { identifies a versioned section.  The section name is
+		# the rest of the line with the + and { symbols removed.
+		# Triggering this rule sets in_sec to 1, which actives the
+		# symbol rule below
+		/^.*{/ {
+			gsub("+", "");
+			if (in_map == 1) {
+				sec=$(NF-1); in_sec=1;
+			}
+		}
+
+		# This rule identifies the end of a section, and disables the
+		# symbol rule
+		/.*}/ {in_sec=0}
+
+		# This rule matches on a + followed by any characters except a :
+		# (which denotes a global vs local segment), and ends with a ;.
+		# The semicolon is removed and the symbol is printed with its
+		# association file name and version section, along with an
+		# indicator that the symbol is a new addition.  Note this rule
+		# only works if we have found a version section in the rule
+		# above (hence the in_sec check) And found a map file (the
+		# in_map check).  If we are not in a map chunk, do nothing.  If
+		# we are in a map chunk but not a section chunk, record it as
+		# unknown.
+		/^+[^}].*[^:*];/ {gsub(";","");sym=$2;
+			if (in_map == 1) {
+				if (in_sec == 1) {
+					print map " " sym " " sec " add"
+				} else {
+					print map " " sym " unknown add"
+				}
+			}
+		}
+
+		# This is the same rule as above, but the rule matches on a
+		# leading - rather than a +, denoting that the symbol is being
+		# removed.
+		/^-[^}].*[^:*];/ {gsub(";","");sym=$2;
+			if (in_map == 1) {
+				if (in_sec == 1) {
+					print map " " sym " " sec " del"
+				} else {
+					print map " " sym " unknown del"
+				}
+			}
+		}' > "$mapdb"
+
+		sort -u "$mapdb" > "$mapdb.2"
+		mv -f "$mapdb.2" "$mapdb"
+
+}
+
+find_trace_fn()
+{
+	local fname="$1"
+
+	cat "$fname" | awk -v symname="$2 *\\\(" '
+		# Initialize the variables.
+		# The variable symname provides a pattern to match
+		# "function_name(", zero or more spaces can be present
+		# between function_name and (.
+		BEGIN {state=0; ln_pth=0}
+
+		# Matches the function name, set state=1.
+		$0 ~ symname {state=1}
+
+		# If closing parentheses with semicolon ");" is found, then it
+		# is not the function definition.
+		/) *;/ {
+			if (state == 1) {
+				state=0
+			}
+		}
+
+		/)/ {
+			if (state == 1) {
+				state=2
+				ln_pth=NR
+				next
+			}
+		}
+
+		# If closing parentheses and then opening braces is found in
+		# adjacent line, then this is the start of function
+		# definition. Check for tracepoint in the function definition.
+		# The tracepoint has _trace_ in its name.
+		/{/ {
+			if (state == 2) {
+				if (ln_pth != NR - 1) {
+					state=0
+					next
+				}
+				while (index($0, "}") != 2) {
+					if (index($0, "_trace_") != 0) {
+						exit 0
+					}
+					if (getline <= 0) {
+						break
+					}
+				}
+				exit 1
+			}
+		}
+	'
+}
+
+check_for_tracepoint()
+{
+	local patch="$1"
+	local mapdb="$2"
+	local skip_sym
+	local libname
+	local secname
+	local mname
+	local ret=0
+	local pdir
+	local libp
+	local libn
+	local sym
+	local ar
+
+	while read -r mname symname secname ar; do
+		pdir=$(echo $mname | awk 'BEGIN {FS="/"};{print $2}')
+		libname=$(echo $mname | awk 'BEGIN {FS="/"};{print $3}')
+		skip_sym=0
+		libp=0
+
+		if [ "$pdir" != "lib" ]; then
+			continue
+		fi
+
+		for libn in $libdir; do
+			if [ $libn = $libname ]; then
+				libp=1
+				break
+			fi
+		done
+
+		if [ $libp -eq 0 ]; then
+			continue
+		fi
+
+		for sym in $(cat $skiplist); do
+			if [ $sym = $symname ]; then
+				skip_sym=1
+				break
+			fi
+		done
+
+		if [ $skip_sym -eq 1 ]; then
+			continue
+		fi
+
+		if [ "$ar" = "add" ] && [ "$secname" = "EXPERIMENTAL" ]; then
+			# Check if new API is added with tracepoint
+			find_trace_fn $patch $symname
+			if [ $? -eq 1 ]; then
+				ret=1
+				echo -n "ERROR: New function $symname is added "
+				echo -n "without a tracepoint. Please add a tracepoint "
+				echo -n "or add the function $symname in "
+				echo "devtools/trace-skiplist.txt to skip this error."
+			fi
+		fi
+	done < "$mapdb"
+
+	return $ret
+}
+
+trap clean_and_exit_on_sig EXIT
+
+mapfile=`mktemp -t dpdk.mapdb.XXXXXX`
+patch=$1
+exit_code=1
+
+clean_and_exit_on_sig()
+{
+	rm -f "$mapfile"
+	exit $exit_code
+}
+
+build_map_changes "$patch" "$mapfile"
+check_for_tracepoint "$patch" "$mapfile"
+exit_code=$?
+rm -f "$mapfile"
+
+exit $exit_code
devtools/checkpatches.sh +9 -0
index 1dee094c7a..471db1d21b 100755
@@ -10,6 +10,7 @@
 . $(dirname $(readlink -f $0))/load-devel-config
 
 VALIDATE_NEW_API=$(dirname $(readlink -f $0))/check-symbol-change.sh
+VALIDATE_TRACEPOINT=$(dirname $(readlink -f $0))/check-tracepoint.sh
 
 # Enable codespell by default. This can be overwritten from a config file.
 # Codespell can also be enabled by setting DPDK_CHECKPATCH_CODESPELL to a valid path
@@ -386,6 +387,14 @@ check () { # <patch-file> <commit>
 		ret=1
 	fi
 
+	! $verbose || printf '\nChecking API additions with tracepoint :\n'
+	report=$($VALIDATE_TRACEPOINT "$tmpinput")
+	if [ $? -ne 0 ] ; then
+		$headline_printed || print_headline "$subject"
+		printf '%s\n' "$report"
+		ret=1
+	fi
+
 	if [ "$tmpinput" != "$1" ]; then
 		rm -f "$tmpinput"
 		trap - INT
devtools/trace-skiplist.txt new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
Signature · 1 line
2.25.1
#14 lore raw

Hi Thomas,

Please let me know if there is any feedback on this patch.

Regards,
Ankur

Quoted 294 lines

-----Original Message-----
From: Ankur Dwivedi <[email protected]>
Sent: Tuesday, March 7, 2023 5:35 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Ankur Dwivedi <[email protected]>
Subject: [PATCH v5 1/1] devtools: add tracepoint check in checkpatch

This patch adds a validation in checkpatch tool, to check if a tracepoint is present in any new function added in cryptodev, ethdev, eventdev and mempool library.

In this patch, the build_map_changes function is copied from check-symbol- change.sh to check-tracepoint.sh. The check-tracepoint.sh script uses build_map_changes function to create a map of functions.
In the map, the newly added functions, added in the experimental section are identified and their definition are checked for the presence of tracepoint. The checkpatch return error if the tracepoint is not present.

For functions for which trace is not needed, they can be added to devtools/trace-skiplist.txt file. The above tracepoint check will be skipped for them.

---

devtools/check-tracepoint.sh | 223 +++++++++++++++++++++++++++++++++++
devtools/checkpatches.sh     |   9 ++
devtools/trace-skiplist.txt  |   0
3 files changed, 232 insertions(+)

create mode 100755 devtools/check-tracepoint.sh create mode 100644 devtools/trace-skiplist.txt

devtools/check-tracepoint.sh new renamed from devtools/check-tracepoint.sh +0 -0

file mode 100755 index 0000000000..88d6b1fd53

devtools/check-tracepoint.sh new file +50 -0
@@ -0,0 +1,223 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Neil Horman
+<[email protected]> # Copyright(C) 2023 Marvell.
+
+selfdir=$(dirname $(readlink -f $0))
+
+# Library for trace check
+libdir="cryptodev ethdev eventdev mempool"
+
+# Functions for which the trace check can be skipped
+skiplist="$selfdir/trace-skiplist.txt"
+
+build_map_changes()
+{
+	local fname="$1"
+	local mapdb="$2"
+
+	cat "$fname" | awk '
+		# Initialize our variables
+		BEGIN {map="";sym="";ar="";sec=""; in_sec=0; in_map=0}
+
+		# Anything that starts with + or -, followed by an a
+		# and ends in the string .map is the name of our map file
+		# This may appear multiple times in a patch if multiple
+		# map files are altered, and all section/symbol names
+		# appearing between a triggering of this rule and the
+		# next trigger of this rule are associated with this file
+		/[-+] [ab]\/.*\.map/ {map=$2; in_map=1; next}
+
+		# The previous rule catches all .map files, anything else
+		# indicates we left the map chunk.
+		/[-+] [ab]\// {in_map=0}
+
+		# Triggering this rule, which starts a line and ends it
+		# with a { identifies a versioned section.  The section name is
+		# the rest of the line with the + and { symbols removed.
+		# Triggering this rule sets in_sec to 1, which actives the
+		# symbol rule below
+		/^.*{/ {
+			gsub("+", "");
+			if (in_map == 1) {
+				sec=$(NF-1); in_sec=1;
+			}
+		}
+
+		# This rule identifies the end of a section, and disables the
+		# symbol rule
+		/.*}/ {in_sec=0}
+
+		# This rule matches on a + followed by any characters except a

:

devtools/check-tracepoint.sh new file +144 -0
+		# (which denotes a global vs local segment), and ends with a ;.
+		# The semicolon is removed and the symbol is printed with its
+		# association file name and version section, along with an
+		# indicator that the symbol is a new addition.  Note this rule
+		# only works if we have found a version section in the rule
+		# above (hence the in_sec check) And found a map file (the
+		# in_map check).  If we are not in a map chunk, do nothing.  If
+		# we are in a map chunk but not a section chunk, record it as
+		# unknown.
+		/^+[^}].*[^:*];/ {gsub(";","");sym=$2;
+			if (in_map == 1) {
+				if (in_sec == 1) {
+					print map " " sym " " sec " add"
+				} else {
+					print map " " sym " unknown add"
+				}
+			}
+		}
+
+		# This is the same rule as above, but the rule matches on a
+		# leading - rather than a +, denoting that the symbol is being
+		# removed.
+		/^-[^}].*[^:*];/ {gsub(";","");sym=$2;
+			if (in_map == 1) {
+				if (in_sec == 1) {
+					print map " " sym " " sec " del"
+				} else {
+					print map " " sym " unknown del"
+				}
+			}
+		}' > "$mapdb"
+
+		sort -u "$mapdb" > "$mapdb.2"
+		mv -f "$mapdb.2" "$mapdb"
+
+}
+
+find_trace_fn()
+{
+	local fname="$1"
+
+	cat "$fname" | awk -v symname="$2 *\\\(" '
+		# Initialize the variables.
+		# The variable symname provides a pattern to match
+		# "function_name(", zero or more spaces can be present
+		# between function_name and (.
+		BEGIN {state=0; ln_pth=0}
+
+		# Matches the function name, set state=1.
+		$0 ~ symname {state=1}
+
+		# If closing parentheses with semicolon ");" is found, then it
+		# is not the function definition.
+		/) *;/ {
+			if (state == 1) {
+				state=0
+			}
+		}
+
+		/)/ {
+			if (state == 1) {
+				state=2
+				ln_pth=NR
+				next
+			}
+		}
+
+		# If closing parentheses and then opening braces is found in
+		# adjacent line, then this is the start of function
+		# definition. Check for tracepoint in the function definition.
+		# The tracepoint has _trace_ in its name.
+		/{/ {
+			if (state == 2) {
+				if (ln_pth != NR - 1) {
+					state=0
+					next
+				}
+				while (index($0, "}") != 2) {
+					if (index($0, "_trace_") != 0) {
+						exit 0
+					}
+					if (getline <= 0) {
+						break
+					}
+				}
+				exit 1
+			}
+		}
+	'
+}
+
+check_for_tracepoint()
+{
+	local patch="$1"
+	local mapdb="$2"
+	local skip_sym
+	local libname
+	local secname
+	local mname
+	local ret=0
+	local pdir
+	local libp
+	local libn
+	local sym
+	local ar
+
+	while read -r mname symname secname ar; do
+		pdir=$(echo $mname | awk 'BEGIN {FS="/"};{print $2}')
+		libname=$(echo $mname | awk 'BEGIN {FS="/"};{print $3}')
+		skip_sym=0
+		libp=0
+
+		if [ "$pdir" != "lib" ]; then
+			continue
+		fi
+
+		for libn in $libdir; do
+			if [ $libn = $libname ]; then
+				libp=1
+				break
+			fi
+		done
+
+		if [ $libp -eq 0 ]; then
+			continue
+		fi
+
+		for sym in $(cat $skiplist); do
+			if [ $sym = $symname ]; then
+				skip_sym=1
+				break
+			fi
+		done
+
+		if [ $skip_sym -eq 1 ]; then
+			continue
+		fi
+
+		if [ "$ar" = "add" ] && [ "$secname" = "EXPERIMENTAL" ]; then
+			# Check if new API is added with tracepoint
+			find_trace_fn $patch $symname
+			if [ $? -eq 1 ]; then
+				ret=1
+				echo -n "ERROR: New function $symname is

added "

devtools/check-tracepoint.sh new file +1 -0
+				echo -n "without a tracepoint. Please add a

tracepoint "

devtools/check-tracepoint.sh new file +2 -0
+				echo -n "or add the function $symname in "
+				echo "devtools/trace-skiplist.txt to skip this

error."

devtools/check-tracepoint.sh new file +25 -0
+			fi
+		fi
+	done < "$mapdb"
+
+	return $ret
+}
+
+trap clean_and_exit_on_sig EXIT
+
+mapfile=`mktemp -t dpdk.mapdb.XXXXXX`
+patch=$1
+exit_code=1
+
+clean_and_exit_on_sig()
+{
+	rm -f "$mapfile"
+	exit $exit_code
+}
+
+build_map_changes "$patch" "$mapfile"
+check_for_tracepoint "$patch" "$mapfile"
+exit_code=$?
+rm -f "$mapfile"
+
+exit $exit_code
devtools/checkpatches.sh index renamed from devtools/checkpatches.sh +0 -0

1dee094c7a..471db1d21b 100755

devtools/checkpatches.sh +0 -0
@@ -10,6 +10,7 @@

. $(dirname $(readlink -f $0))/load-devel-config

VALIDATE_NEW_API=$(dirname $(readlink -f $0))/check-symbol-change.sh +VALIDATE_TRACEPOINT=$(dirname $(readlink -f $0))/check-tracepoint.sh

# Enable codespell by default. This can be overwritten from a config file. # Codespell can also be enabled by setting DPDK_CHECKPATCH_CODESPELL to a valid path @@ -386,6 +387,14 @@ check () { # <patch-file> <commit>

		ret=1
	fi
devtools/checkpatches.sh +8 -0
+	! $verbose || printf '\nChecking API additions with tracepoint :\n'
+	report=$($VALIDATE_TRACEPOINT "$tmpinput")
+	if [ $? -ne 0 ] ; then
+		$headline_printed || print_headline "$subject"
+		printf '%s\n' "$report"
+		ret=1
+	fi
+

if [ "$tmpinput" != "$1" ]; then
rm -f "$tmpinput"
trap - INT

devtools/trace-skiplist.txt new file renamed from devtools/trace-skiplist.txt +0 -0

mode 100644 index 0000000000..e69de29bb2
--
2.25.1

#15 lore raw
Quoted 19 lines · On Thu, 18 May 2023 13:45:29 +0000 Ankur Dwivedi <[email protected]> wrote:
Quoted 19 lines

-----Original Message-----
From: Ankur Dwivedi <[email protected]>
Sent: Tuesday, March 7, 2023 5:35 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Ankur Dwivedi <[email protected]>
Subject: [PATCH v5 1/1] devtools: add tracepoint check in checkpatch

This patch adds a validation in checkpatch tool, to check if a tracepoint is present in any new function added in cryptodev, ethdev, eventdev and mempool library.

In this patch, the build_map_changes function is copied from check-symbol- change.sh to check-tracepoint.sh. The check-tracepoint.sh script uses build_map_changes function to create a map of functions.
In the map, the newly added functions, added in the experimental section are identified and their definition are checked for the presence of tracepoint. The checkpatch return error if the tracepoint is not present.

Quoted 5 lines
Quoted 5 lines

For functions for which trace is not needed, they can be added to devtools/trace-skiplist.txt file. The above tracepoint check will be skipped for them.

Given the amount of string processing, it would be more readable in python. That is not a show stopper, just a suggestion.

#16 lore raw
Quoted 35 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Thursday, May 18, 2023 9:04 PM
To: Ankur Dwivedi <[email protected]>
Cc: Thomas Monjalon <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]
Subject: [EXT] Re: [PATCH v5 1/1] devtools: add tracepoint check in checkpatch

External Email

----------------------------------------------------------------------

Quoted 8 lines · On Thu, 18 May 2023 13:45:29 +0000 Ankur Dwivedi <[email protected]> wrote:
Quoted 8 lines

-----Original Message-----
From: Ankur Dwivedi <[email protected]>
Sent: Tuesday, March 7, 2023 5:35 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Ankur Dwivedi <[email protected]>
Subject: [PATCH v5 1/1] devtools: add tracepoint check in checkpatch

Quoted 7 lines
Quoted 7 lines

This patch adds a validation in checkpatch tool, to check if a tracepoint is present in any new function added in cryptodev, ethdev, eventdev and mempool library.

In this patch, the build_map_changes function is copied from check-symbol- change.sh to check-tracepoint.sh. The check-tracepoint.sh script uses build_map_changes function to create a

map of functions.

Quoted 3 lines
Quoted 3 lines

In the map, the newly added functions, added in the experimental section are identified and their definition are checked for the presence of tracepoint. The checkpatch return error if the tracepoint is not

present.

Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

For functions for which trace is not needed, they can be added to devtools/trace-skiplist.txt file. The above tracepoint check will be skipped for them.

Given the amount of string processing, it would be more readable in python. That is not a show stopper, just a suggestion.

Hi Thomas,

Please let me know if the shell script in this patch is fine or would a python implementation would be more preferable.

Regards,
Ankur

#17 lore raw
Quoted 39 lines

From: Ankur Dwivedi [mailto:[email protected]]
Sent: Monday, 21 August 2023 15.54

Quoted 12 lines

From: Stephen Hemminger <[email protected]>
Sent: Thursday, May 18, 2023 9:04 PM

----------------------------------------------------------------------

Quoted 5 lines · On Thu, 18 May 2023 13:45:29 +0000 Ankur Dwivedi <[email protected]> wrote:
Quoted 5 lines

From: Ankur Dwivedi <[email protected]>
Sent: Tuesday, March 7, 2023 5:35 PM

This patch adds a validation in checkpatch tool, to check if a tracepoint is present in any new function added in cryptodev,

ethdev,

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

eventdev and mempool library.

In this patch, the build_map_changes function is copied from check-symbol- change.sh to check-tracepoint.sh. The check-tracepoint.sh script uses build_map_changes function to create

a

Quoted 4 lines

map of functions.

Quoted 3 lines
Quoted 3 lines

In the map, the newly added functions, added in the experimental section are identified and their definition are checked for the presence of tracepoint. The checkpatch return error if the

tracepoint is not

Quoted 9 lines

present.

Quoted 6 lines
Quoted 6 lines

For functions for which trace is not needed, they can be added to devtools/trace-skiplist.txt file. The above tracepoint check will be skipped for them.

Given the amount of string processing, it would be more readable in

python.

Quoted 1 line

That is not a show stopper, just a suggestion.

Quoted 7 lines

Hi Thomas,

Please let me know if the shell script in this patch is fine or would a python implementation would be more preferable.

Regards,
Ankur

The bigger question is: Do we really want to change tracepoints in functions from opt-in to opt-out?

In my opinion, opt-in for trace is more appropriate.

Nonetheless, having a tool to check for tracepoint presence might still be useful for library reviewers and maintainers. And such a tool might be useful for any library, not just the few libraries suggested by this patch.

#18 lore raw

21/08/2023 16:46, Morten Brørup:

Quoted 35 lines
Quoted 35 lines

From: Ankur Dwivedi [mailto:[email protected]]
Sent: Monday, 21 August 2023 15.54

Quoted 12 lines

From: Stephen Hemminger <[email protected]>
Sent: Thursday, May 18, 2023 9:04 PM

----------------------------------------------------------------------

Quoted 5 lines · On Thu, 18 May 2023 13:45:29 +0000 Ankur Dwivedi <[email protected]> wrote:
Quoted 5 lines

From: Ankur Dwivedi <[email protected]>
Sent: Tuesday, March 7, 2023 5:35 PM

This patch adds a validation in checkpatch tool, to check if a tracepoint is present in any new function added in cryptodev,

ethdev,

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

eventdev and mempool library.

In this patch, the build_map_changes function is copied from check-symbol- change.sh to check-tracepoint.sh. The check-tracepoint.sh script uses build_map_changes function to create

a

Quoted 4 lines

map of functions.

Quoted 3 lines
Quoted 3 lines

In the map, the newly added functions, added in the experimental section are identified and their definition are checked for the presence of tracepoint. The checkpatch return error if the

tracepoint is not

Quoted 8 lines

present.

Quoted 6 lines
Quoted 6 lines

For functions for which trace is not needed, they can be added to devtools/trace-skiplist.txt file. The above tracepoint check will be skipped for them.

Quoted 8 lines
Quoted 8 lines
Quoted 1 line

Given the amount of string processing, it would be more readable in

python.

Quoted 1 line

That is not a show stopper, just a suggestion.

Hi Thomas,

Please let me know if the shell script in this patch is fine or would a python implementation would be more preferable.

In general, I wonder how much the check is useful compared to the complexity.

Quoted 1 line

The bigger question is: Do we really want to change tracepoints in functions from opt-in to opt-out?

Yes that's the question: should traces be mandatory in some libs?

Quoted 1 line

In my opinion, opt-in for trace is more appropriate.

There was some work to add traces everywhere in few libs, so why not maintaining this state? I don't really like adding a skip list as one more burden for future authors.

Quoted 1 line

Nonetheless, having a tool to check for tracepoint presence might still be useful for library reviewers and maintainers. And such a tool might be useful for any library, not just the few libraries suggested by this patch.

#19 lore raw
Quoted 58 lines

From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, 30 August 2023 18.24

21/08/2023 16:46, Morten Brørup:

Quoted 7 lines
Quoted 7 lines

From: Ankur Dwivedi [mailto:[email protected]]
Sent: Monday, 21 August 2023 15.54

Quoted 4 lines

From: Stephen Hemminger <[email protected]>
Sent: Thursday, May 18, 2023 9:04 PM

-------------------------------------------------------------------

---

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines · On Thu, 18 May 2023 13:45:29 +0000 Ankur Dwivedi <[email protected]> wrote:
Quoted 3 lines

From: Ankur Dwivedi <[email protected]>
Sent: Tuesday, March 7, 2023 5:35 PM

Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

This patch adds a validation in checkpatch tool, to check if a tracepoint is present in any new function added in cryptodev,

ethdev,

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

eventdev and mempool library.

In this patch, the build_map_changes function is copied from check-symbol- change.sh to check-tracepoint.sh. The check-tracepoint.sh script uses build_map_changes function to

create

Quoted 9 lines
Quoted 9 lines

a

Quoted 4 lines

map of functions.

Quoted 3 lines
Quoted 3 lines

In the map, the newly added functions, added in the experimental section are identified and their definition are checked for the presence of tracepoint. The checkpatch return error if the

tracepoint is not

Quoted 3 lines

present.

Quoted 2 lines
Quoted 2 lines

For functions for which trace is not needed, they can be added

to

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

devtools/trace-skiplist.txt file. The above tracepoint check

will be

Quoted 11 lines
Quoted 11 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

skipped for them.

Given the amount of string processing, it would be more readable in

python.

Quoted 1 line

That is not a show stopper, just a suggestion.

Hi Thomas,

Please let me know if the shell script in this patch is fine or

would a

Quoted 1 line
Quoted 1 line

python implementation would be more preferable.

In general, I wonder how much the check is useful compared to the complexity.

Quoted 1 line

The bigger question is: Do we really want to change tracepoints in

Quoted 8 lines

functions from opt-in to opt-out?

Yes that's the question: should traces be mandatory in some libs?

Quoted 1 line

In my opinion, opt-in for trace is more appropriate.

There was some work to add traces everywhere in few libs, so why not maintaining this state?

I still think it's a silly and burdening requirement, but I'm not against it for the libs where it is already a de facto standard.

<irony>
I can imagine similar requirements regarding logging, telemetry and dump functions being imposed on select libs.

Perhaps we should also require that new libs implement all four types of instrumentation, to ensure that only high quality (i.e. fully instrumented) libs are accepted into DPDK. </irony>

Quoted 2 lines

I don't really like adding a skip list as one more burden for future authors.

If the warning omitted from checkpatches refers to the skip list and its location, it is relatively easy for developers to manage.

And reviewers will notice if new functions have been added to the skip list, indicating that trace has been omitted. So there are also advantages to the skip list.

Quoted 9 lines
Quoted 3 lines

Nonetheless, having a tool to check for tracepoint presence might

still be useful for library reviewers and maintainers. And such a tool might be useful for any library, not just the few libraries suggested by this patch.

#20 lore raw
Quoted 23 lines · Morten Brørup
Quoted 14 lines

From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, 30 August 2023 18.24

21/08/2023 16:46, Morten Brørup:

Quoted 2 lines
Quoted 2 lines

From: Ankur Dwivedi [mailto:[email protected]]
Sent: Monday, 21 August 2023 15.54

In general, I wonder how much the check is useful compared to the complexity.

Quoted 1 line

The bigger question is: Do we really want to change tracepoints in

Quoted 8 lines

functions from opt-in to opt-out?

Yes that's the question: should traces be mandatory in some libs?

Quoted 1 line

In my opinion, opt-in for trace is more appropriate.

There was some work to add traces everywhere in few libs, so why not maintaining this state?

Quoted 6 lines

I still think it's a silly and burdening requirement, but I'm not against it for the libs where it is already a de facto standard.

<irony>
I can imagine similar requirements regarding logging, telemetry and dump functions being imposed on select libs.

Perhaps we should also require that new libs implement all four types of instrumentation, to ensure that only high quality (i.e. fully instrumented) libs are accepted into DPDK.

IMO, There is a lot of effort to put trace points to existing libraries, without these check, soon the disparity shows up when someone adds new APIs to library and forget
to add trace points.

It is pretty easy to add trace point and there are a lot of references, so I don't think there is burden for a developer comparing to the effort of adding a new API.

Most of the time, contributors forgets to add trace point because there is no automatic way to find it.
Also, additional git commits are needs if some decide to add it later.

No strong opinion, If not find not useful, we could mark this patch is not appliable. Keeping the patch is limbo state is the issue. It is already reached to v5.
So please decide one way or another.

Quoted 9 lines

</irony>

Quoted 2 lines

I don't really like adding a skip list as one more burden for future authors.

If the warning omitted from checkpatches refers to the skip list and its location, it is relatively easy for developers to manage.

And reviewers will notice if new functions have been added to the skip list, indicating that trace has been omitted. So there are also advantages to the skip list.

#21 lore raw

Let's decide in a techboard meeting whether traces are mandatory or not.

01/09/2023 04:32, Jerin Jacob:

Quoted 60 lines · Morten Brørup
Quoted 23 lines
Quoted 14 lines

From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, 30 August 2023 18.24

21/08/2023 16:46, Morten Brørup:

Quoted 2 lines
Quoted 2 lines

From: Ankur Dwivedi [mailto:[email protected]]
Sent: Monday, 21 August 2023 15.54

In general, I wonder how much the check is useful compared to the complexity.

Quoted 1 line

The bigger question is: Do we really want to change tracepoints in

Quoted 8 lines

functions from opt-in to opt-out?

Yes that's the question: should traces be mandatory in some libs?

Quoted 1 line

In my opinion, opt-in for trace is more appropriate.

There was some work to add traces everywhere in few libs, so why not maintaining this state?

Quoted 6 lines

I still think it's a silly and burdening requirement, but I'm not against it for the libs where it is already a de facto standard.

<irony>
I can imagine similar requirements regarding logging, telemetry and dump functions being imposed on select libs.

Perhaps we should also require that new libs implement all four types of instrumentation, to ensure that only high quality (i.e. fully instrumented) libs are accepted into DPDK.

IMO, There is a lot of effort to put trace points to existing libraries, without these check, soon the disparity shows up when someone adds new APIs to library and forget
to add trace points.

It is pretty easy to add trace point and there are a lot of references, so I don't think there is burden for a developer comparing to the effort of adding a new API.

Most of the time, contributors forgets to add trace point because there is no automatic way to find it.
Also, additional git commits are needs if some decide to add it later.

No strong opinion, If not find not useful, we could mark this patch is not appliable. Keeping the patch is limbo state is the issue. It is already reached to v5.
So please decide one way or another.

Quoted 8 lines

</irony>

Quoted 2 lines

I don't really like adding a skip list as one more burden for future authors.

If the warning omitted from checkpatches refers to the skip list and its location, it is relatively easy for developers to manage.

And reviewers will notice if new functions have been added to the skip list, indicating that trace has been omitted. So there are also advantages to the skip list.

#22 lore raw
Quoted 13 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Friday, September 1, 2023 12:59 PM
To: Morten Brørup <[email protected]>; Jerin Jacob <[email protected]>
Cc: Ankur Dwivedi <[email protected]>; Stephen Hemminger <[email protected]>; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]; [email protected]
Subject: Re: [EXT] Re: [PATCH v5 1/1] devtools: add tracepoint check in checkpatch

Quoted 1 line

Let's decide in a techboard meeting whether traces are mandatory or not.

It was agreed in techboard meeting in September, that tracepoints needs to be present for new public API functions in cryptodev, ethdev, eventdev, mempool. Can this patch which automates the check for presence of tracepoint be reviewed and merged if its fine?

Quoted 74 lines

01/09/2023 04:32, Jerin Jacob:

Quoted 1 line

On Thu, Aug 31, 2023 at 12:08 AM Morten Brørup

Quoted 17 lines · <[email protected]> wrote:
Quoted 17 lines
Quoted 17 lines

From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, 30 August 2023 18.24

21/08/2023 16:46, Morten Brørup:

Quoted 2 lines
Quoted 2 lines

From: Ankur Dwivedi [mailto:[email protected]]
Sent: Monday, 21 August 2023 15.54

In general, I wonder how much the check is useful compared to the complexity.

Quoted 2 lines

The bigger question is: Do we really want to change tracepoints in

functions from opt-in to opt-out?

Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

Yes that's the question: should traces be mandatory in some libs?

Quoted 1 line

In my opinion, opt-in for trace is more appropriate.

There was some work to add traces everywhere in few libs, so why not maintaining this state?

I still think it's a silly and burdening requirement, but I'm not against it for

the libs where it is already a de facto standard.

Quoted 3 lines
Quoted 3 lines

<irony>
I can imagine similar requirements regarding logging, telemetry and dump

functions being imposed on select libs.

Quoted 2 lines
Quoted 2 lines

Perhaps we should also require that new libs implement all four types of

instrumentation, to ensure that only high quality (i.e. fully instrumented) libs are accepted into DPDK.

Quoted 9 lines

IMO, There is a lot of effort to put trace points to existing libraries, without these check, soon the disparity shows up when someone adds new APIs to library and forget to add trace points.

It is pretty easy to add trace point and there are a lot of references, so I don't think there is burden for a developer comparing to the effort of adding a new API.

Quoted 18 lines

Most of the time, contributors forgets to add trace point because there is no automatic way to find it.
Also, additional git commits are needs if some decide to add it later.

No strong opinion, If not find not useful, we could mark this patch is not appliable. Keeping the patch is limbo state is the issue. It is already reached to v5.
So please decide one way or another.

Quoted 6 lines

</irony>

Quoted 2 lines

I don't really like adding a skip list as one more burden for future authors.

If the warning omitted from checkpatches refers to the skip list and its

location, it is relatively easy for developers to manage.

Quoted 2 lines
Quoted 2 lines

And reviewers will notice if new functions have been added to the skip list,

indicating that trace has been omitted. So there are also advantages to the skip list.

#23 lore raw
In reply to Ankur Dwivedi

07/03/2023 13:05, Ankur Dwivedi:

Quoted 8 lines

This patch series adds a validation in checkpatch tool to check if tracepoint is present in any new function added in ethdev, eventdev cryptodev and mempool library.

v5:
- Copied the build_map_changes function from check-symbol-change.sh to check-tracepoint.sh.
- Added eventdev, cryptodev and mempool in libdir in check-tracepoint.sh.

Why did you decide to copy the function in v5, instead of having a common file usable by different scripts?

#24 lore raw
Quoted 5 lines

07/03/2023 13:05, Ankur Dwivedi:

Quoted 4 lines

This patch series adds a validation in checkpatch tool to check if tracepoint is present in any new function added in ethdev, eventdev cryptodev and mempool library.

Quoted 8 lines
Quoted 4 lines

v5:
- Copied the build_map_changes function from check-symbol-change.sh to check-tracepoint.sh.
- Added eventdev, cryptodev and mempool in libdir in check-tracepoint.sh.

Why did you decide to copy the function in v5, instead of having a common file usable by different scripts?

There was comments in v2 of the patch that common scripts may not work well and to keep the scripts specialized.

#25 lore raw

28/11/2023 15:07, Ankur Dwivedi:

Quoted 10 lines
Quoted 10 lines

07/03/2023 13:05, Ankur Dwivedi:

Quoted 8 lines

This patch series adds a validation in checkpatch tool to check if tracepoint is present in any new function added in ethdev, eventdev cryptodev and mempool library.

v5:
- Copied the build_map_changes function from check-symbol-change.sh to check-tracepoint.sh.
- Added eventdev, cryptodev and mempool in libdir in check-tracepoint.sh.

Quoted 4 lines
Quoted 3 lines

Why did you decide to copy the function in v5, instead of having a common file usable by different scripts?

There was comments in v2 of the patch that common scripts may not work well and to keep the scripts specialized.

I meant you can have a common file specialized in symbols.
In general, you should reply, establish a discussion, so we share the same understanding.

#26 lore raw
Quoted 23 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Tuesday, November 28, 2023 9:25 PM
To: Ankur Dwivedi <[email protected]>
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>
Subject: Re: [EXT] Re: [PATCH v5 0/1] devtools: add tracepoint check in checkpatch

28/11/2023 15:07, Ankur Dwivedi:

Quoted 7 lines
Quoted 7 lines

07/03/2023 13:05, Ankur Dwivedi:

Quoted 6 lines

This patch series adds a validation in checkpatch tool to check if tracepoint is present in any new function added in ethdev, eventdev cryptodev and mempool library.

v5:
- Copied the build_map_changes function from check-symbol-change.sh

to

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

check-tracepoint.sh.
- Added eventdev, cryptodev and mempool in libdir in check-

tracepoint.sh.

Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines

Why did you decide to copy the function in v5, instead of having a common file usable by different scripts?

There was comments in v2 of the patch that common scripts may not work

well and to keep the scripts specialized.

I meant you can have a common file specialized in symbols.

The build_map_changes() (in devtools/check-symbol-change.sh) which is a common function can be moved to a new file named devtools/build-symbol-map.sh. The build-symbol-map.sh can be included in check-symbol-change.sh and check-tracepoint.sh.
Please let me know if this is fine.

Quoted 3 lines

In general, you should reply, establish a discussion, so we share the same understanding.

#27 lore raw

30/11/2023 06:56, Ankur Dwivedi:

Quoted 17 lines

From: Thomas Monjalon <[email protected]>

Quoted 16 lines

28/11/2023 15:07, Ankur Dwivedi:

Quoted 7 lines
Quoted 7 lines

07/03/2023 13:05, Ankur Dwivedi:

Quoted 6 lines

This patch series adds a validation in checkpatch tool to check if tracepoint is present in any new function added in ethdev, eventdev cryptodev and mempool library.

v5:
- Copied the build_map_changes function from check-symbol-change.sh

to

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

check-tracepoint.sh.
- Added eventdev, cryptodev and mempool in libdir in check-

tracepoint.sh.

Quoted 4 lines
Quoted 4 lines

Why did you decide to copy the function in v5, instead of having a common file usable by different scripts?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

There was comments in v2 of the patch that common scripts may not work

well and to keep the scripts specialized.

I meant you can have a common file specialized in symbols.

The build_map_changes() (in devtools/check-symbol-change.sh) which is a common function can be moved to a new file named devtools/build-symbol-map.sh. The build-symbol-map.sh can be included in check-symbol-change.sh and check-tracepoint.sh.
Please let me know if this is fine.

Yes
We can imagine moving more symbol map related funtions in this new file. What about symbol-map-util.sh as filename?

#28 lore raw
Quoted 35 lines

-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Thursday, November 30, 2023 2:11 PM
To: Ankur Dwivedi <[email protected]>
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>
Subject: Re: [EXT] Re: [PATCH v5 0/1] devtools: add tracepoint check in checkpatch

30/11/2023 06:56, Ankur Dwivedi:

Quoted 18 lines

From: Thomas Monjalon <[email protected]>

Quoted 17 lines

28/11/2023 15:07, Ankur Dwivedi:

Quoted 8 lines
Quoted 8 lines

07/03/2023 13:05, Ankur Dwivedi:

Quoted 7 lines

This patch series adds a validation in checkpatch tool to check if tracepoint is present in any new function added in ethdev, eventdev cryptodev and mempool library.

v5:
- Copied the build_map_changes function from
check-symbol-change.sh

to

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

check-tracepoint.sh.
- Added eventdev, cryptodev and mempool in libdir in check-

tracepoint.sh.

Quoted 4 lines
Quoted 4 lines

Why did you decide to copy the function in v5, instead of having a common file usable by different scripts?

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

There was comments in v2 of the patch that common scripts may not work

well and to keep the scripts specialized.

I meant you can have a common file specialized in symbols.

The build_map_changes() (in devtools/check-symbol-change.sh) which is a

common function can be moved to a new file named devtools/build-symbol- map.sh.

Quoted 7 lines
Quoted 1 line

The build-symbol-map.sh can be included in check-symbol-change.sh and

check-tracepoint.sh.

Quoted 1 line

Please let me know if this is fine.

Yes
We can imagine moving more symbol map related funtions in this new file. What about symbol-map-util.sh as filename?

I am ok with this filename.

Quoted 1 line
#29 lore raw

v6 cover devtools: add tracepoint check in checkpatch

In reply to Ankur Dwivedi

This patch series adds a validation in checkpatch tool to check if tracepoint is present in any new function added in ethdev, eventdev cryptodev and mempool library.

v6:
- The build_map_changes function is moved from check-symbol-change.sh to a new symbol-map-util.sh file. This function can be used in other scripts by including symbol-map-util.sh file.

v5:
- Copied the build_map_changes function from check-symbol-change.sh to check-tracepoint.sh.
- Added eventdev, cryptodev and mempool in libdir in check-tracepoint.sh.

v4:
- Rebased on the recent next-net branch.
- Refined logic to find function definition.
- Updated year in the license in devtools/check-tracepoint.sh.
- Removed cryptodev, added ethdev in libdir in devtools/check-tracepoint.sh.

v3:
- Split the v2 patch into 2 patches.
- The file common-func.sh is renamed to build-symbol-map.sh.
- Removed check-tracepoint.py file.
- Code improvements in check-tracepoint.sh.

v2:
- Add check for parent directory.

Ankur Dwivedi (2):
devtools: move build map changes function
devtools: add tracepoint check in checkpatch

 devtools/check-symbol-change.sh |  76 +---------------
 devtools/check-tracepoint.sh    | 148 ++++++++++++++++++++++++++++++++
 devtools/checkpatches.sh        |   9 ++
 devtools/symbol-map-util.sh     |  78 +++++++++++++++++
 devtools/trace-skiplist.txt     |   0
 5 files changed, 237 insertions(+), 74 deletions(-)
 create mode 100755 devtools/check-tracepoint.sh
 create mode 100644 devtools/symbol-map-util.sh
 create mode 100644 devtools/trace-skiplist.txt
Signature · 1 line
2.25.1
#30 lore raw

PATCH v6 1/2 devtools: move build map changes function

This patch moves the build_map_changes function from check-symbol-change.sh to a new symbol-map-util.sh file. This function can be used in other scripts by including symbol-map-util.sh file. The license in check-symbol-change.sh is copied to symbol-map-util.sh.

---
 devtools/check-symbol-change.sh | 76 +-------------------------------
 devtools/symbol-map-util.sh     | 78 +++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+), 74 deletions(-)
 create mode 100644 devtools/symbol-map-util.sh
devtools/check-symbol-change.sh +2 -74
index 8992214ac8..68613f63cc 100755
@@ -2,80 +2,8 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Neil Horman <[email protected]>
 
-build_map_changes()
-{
-	local fname="$1"
-	local mapdb="$2"
-
-	cat "$fname" | awk '
-		# Initialize our variables
-		BEGIN {map="";sym="";ar="";sec=""; in_sec=0; in_map=0}
-
-		# Anything that starts with + or -, followed by an a
-		# and ends in the string .map is the name of our map file
-		# This may appear multiple times in a patch if multiple
-		# map files are altered, and all section/symbol names
-		# appearing between a triggering of this rule and the
-		# next trigger of this rule are associated with this file
-		/[-+] [ab]\/.*\.map/ {map=$2; in_map=1; next}
-
-		# The previous rule catches all .map files, anything else
-		# indicates we left the map chunk.
-		/[-+] [ab]\// {in_map=0}
-
-		# Triggering this rule, which starts a line and ends it
-		# with a { identifies a versioned section.  The section name is
-		# the rest of the line with the + and { symbols removed.
-		# Triggering this rule sets in_sec to 1, which actives the
-		# symbol rule below
-		/^.*{/ {
-			gsub("+", "");
-			if (in_map == 1) {
-				sec=$(NF-1); in_sec=1;
-			}
-		}
-
-		# This rule identifies the end of a section, and disables the
-		# symbol rule
-		/.*}/ {in_sec=0}
-
-		# This rule matches on a + followed by any characters except a :
-		# (which denotes a global vs local segment), and ends with a ;.
-		# The semicolon is removed and the symbol is printed with its
-		# association file name and version section, along with an
-		# indicator that the symbol is a new addition.  Note this rule
-		# only works if we have found a version section in the rule
-		# above (hence the in_sec check) And found a map file (the
-		# in_map check).  If we are not in a map chunk, do nothing.  If
-		# we are in a map chunk but not a section chunk, record it as
-		# unknown.
-		/^+[^}].*[^:*];/ {gsub(";","");sym=$2;
-			if (in_map == 1) {
-				if (in_sec == 1) {
-					print map " " sym " " sec " add"
-				} else {
-					print map " " sym " unknown add"
-				}
-			}
-		}
-
-		# This is the same rule as above, but the rule matches on a
-		# leading - rather than a +, denoting that the symbol is being
-		# removed.
-		/^-[^}].*[^:*];/ {gsub(";","");sym=$2;
-			if (in_map == 1) {
-				if (in_sec == 1) {
-					print map " " sym " " sec " del"
-				} else {
-					print map " " sym " unknown del"
-				}
-			}
-		}' > "$mapdb"
-
-		sort -u "$mapdb" > "$mapdb.2"
-		mv -f "$mapdb.2" "$mapdb"
-
-}
+selfdir=$(dirname $(readlink -f $0))
+. $selfdir/symbol-map-util.sh
 
 is_stable_section() {
 	[ "$1" != 'EXPERIMENTAL' ] && [ "$1" != 'INTERNAL' ]
devtools/symbol-map-util.sh new file +78 -0

78 lines not on this page · raw message

Signature · 1 line
2.25.1
#31 lore raw

PATCH v6 2/2 devtools: add tracepoint check in checkpatch

In reply to Ankur Dwivedi

This patch adds a validation in checkpatch tool, to check if a tracepoint is present in any new function added in cryptodev, ethdev, eventdev and mempool library.

It uses the existing build_map_changes function to create a map of functions. In the map, the newly added functions, added in the experimental section are identified and their definition are checked for the presence of tracepoint. The checkpatch return error if the tracepoint is not present.

For functions for which trace is not needed, they can be added to devtools/trace-skiplist.txt file. The above tracepoint check will be skipped for them.

---
 devtools/check-tracepoint.sh | 148 +++++++++++++++++++++++++++++++++++
 devtools/checkpatches.sh     |   9 +++
 devtools/trace-skiplist.txt  |   0
 3 files changed, 157 insertions(+)
 create mode 100755 devtools/check-tracepoint.sh
 create mode 100644 devtools/trace-skiplist.txt
devtools/check-tracepoint.sh new file +148 -0
new file mode 100755
index 0000000000..f957ff780c
@@ -0,0 +1,148 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(C) 2023 Marvell.
+
+selfdir=$(dirname $(readlink -f $0))
+. $selfdir/symbol-map-util.sh
+
+# Library for trace check
+libdir="cryptodev ethdev eventdev mempool"
+
+# Functions for which the trace check can be skipped
+skiplist="$selfdir/trace-skiplist.txt"
+
+find_trace_fn()
+{
+	local fname="$1"
+
+	cat "$fname" | awk -v symname="$2 *\\\(" '
+		# Initialize the variables.
+		# The variable symname provides a pattern to match
+		# "function_name(", zero or more spaces can be present
+		# between function_name and (.
+		BEGIN {state=0; ln_pth=0}
+
+		# Matches the function name, set state=1.
+		$0 ~ symname {state=1}
+
+		# If closing parentheses with semicolon ");" is found, then it
+		# is not the function definition.
+		/) *;/ {
+			if (state == 1) {
+				state=0
+			}
+		}
+
+		/)/ {
+			if (state == 1) {
+				state=2
+				ln_pth=NR
+				next
+			}
+		}
+
+		# If closing parentheses and then opening braces is found in
+		# adjacent line, then this is the start of function
+		# definition. Check for tracepoint in the function definition.
+		# The tracepoint has _trace_ in its name.
+		/{/ {
+			if (state == 2) {
+				if (ln_pth != NR - 1) {
+					state=0
+					next
+				}
+				while (index($0, "}") != 2) {
+					if (index($0, "_trace_") != 0) {
+						exit 0
+					}
+					if (getline <= 0) {
+						break
+					}
+				}
+				exit 1
+			}
+		}
+	'
+}
+
+check_for_tracepoint()
+{
+	local patch="$1"
+	local mapdb="$2"
+	local skip_sym
+	local libname
+	local secname
+	local mname
+	local ret=0
+	local pdir
+	local libp
+	local libn
+	local sym
+	local ar
+
+	while read -r mname symname secname ar; do
+		pdir=$(echo $mname | awk 'BEGIN {FS="/"};{print $2}')
+		libname=$(echo $mname | awk 'BEGIN {FS="/"};{print $3}')
+		skip_sym=0
+		libp=0
+
+		if [ "$pdir" != "lib" ]; then
+			continue
+		fi
+
+		for libn in $libdir; do
+			if [ $libn = $libname ]; then
+				libp=1
+				break
+			fi
+		done
+
+		if [ $libp -eq 0 ]; then
+			continue
+		fi
+
+		for sym in $(cat $skiplist); do
+			if [ $sym = $symname ]; then
+				skip_sym=1
+				break
+			fi
+		done
+
+		if [ $skip_sym -eq 1 ]; then
+			continue
+		fi
+
+		if [ "$ar" = "add" ] && [ "$secname" = "EXPERIMENTAL" ]; then
+			# Check if new API is added with tracepoint
+			find_trace_fn $patch $symname
+			if [ $? -eq 1 ]; then
+				ret=1
+				echo -n "ERROR: New function $symname is added "
+				echo -n "without a tracepoint. Please add a tracepoint "
+				echo -n "or add the function $symname in "
+				echo "devtools/trace-skiplist.txt to skip this error."
+			fi
+		fi
+	done < "$mapdb"
+
+	return $ret
+}
+
+trap clean_and_exit_on_sig EXIT
+
+mapfile=`mktemp -t dpdk.mapdb.XXXXXX`
+patch=$1
+exit_code=1
+
+clean_and_exit_on_sig()
+{
+	rm -f "$mapfile"
+	exit $exit_code
+}
+
+build_map_changes "$patch" "$mapfile"
+check_for_tracepoint "$patch" "$mapfile"
+exit_code=$?
+rm -f "$mapfile"
+
+exit $exit_code
devtools/checkpatches.sh +9 -0
index 10b79ca2bc..d74e541c9f 100755
@@ -10,6 +10,7 @@
 . $(dirname $(readlink -f $0))/load-devel-config
 
 VALIDATE_NEW_API=$(dirname $(readlink -f $0))/check-symbol-change.sh
+VALIDATE_TRACEPOINT=$(dirname $(readlink -f $0))/check-tracepoint.sh
 
 # Enable codespell by default. This can be overwritten from a config file.
 # Codespell can also be enabled by setting DPDK_CHECKPATCH_CODESPELL to a valid path
@@ -413,6 +414,14 @@ check () { # <patch-file> <commit>
 		ret=1
 	fi
 
+	! $verbose || printf '\nChecking API additions with tracepoint:\n'
+	report=$($VALIDATE_TRACEPOINT "$tmpinput")
+	if [ $? -ne 0 ] ; then
+		$headline_printed || print_headline "$subject"
+		printf '%s\n' "$report"
+		ret=1
+	fi
+
 	if [ "$tmpinput" != "$1" ]; then
 		rm -f "$tmpinput"
 		trap - INT
devtools/trace-skiplist.txt new file +0 -0
new file mode 100644
index 0000000000..e69de29bb2
Signature · 1 line
2.25.1
#32 lore raw
In reply to Ankur Dwivedi
Quoted 11 lines

-----Original Message-----
From: Ankur Dwivedi <[email protected]>
Sent: Friday, December 15, 2023 12:14 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Ankur Dwivedi <[email protected]>
Subject: [PATCH v6 0/2] devtools: add tracepoint check in checkpatch

This patch series adds a validation in checkpatch tool to check if tracepoint is present in any new function added in ethdev, eventdev cryptodev and mempool library.

Please let me know if this patch series can be merged in DPDK or if there are any comments.

Quoted 42 lines

v6:
- The build_map_changes function is moved from check-symbol-change.sh to a new symbol-map-util.sh file. This function can be used in other scripts by including symbol-map-util.sh file.

v5:
- Copied the build_map_changes function from check-symbol-change.sh to check-tracepoint.sh.
- Added eventdev, cryptodev and mempool in libdir in check-tracepoint.sh.

v4:
- Rebased on the recent next-net branch.
- Refined logic to find function definition.
- Updated year in the license in devtools/check-tracepoint.sh.
- Removed cryptodev, added ethdev in libdir in devtools/check-tracepoint.sh.

v3:
- Split the v2 patch into 2 patches.
- The file common-func.sh is renamed to build-symbol-map.sh.
- Removed check-tracepoint.py file.
- Code improvements in check-tracepoint.sh.

v2:
- Add check for parent directory.

Ankur Dwivedi (2):
devtools: move build map changes function
devtools: add tracepoint check in checkpatch

devtools/check-symbol-change.sh |  76 +---------------
devtools/check-tracepoint.sh    | 148 ++++++++++++++++++++++++++++++++
devtools/checkpatches.sh        |   9 ++
devtools/symbol-map-util.sh     |  78 +++++++++++++++++
devtools/trace-skiplist.txt     |   0
5 files changed, 237 insertions(+), 74 deletions(-)  create mode 100755

devtools/check-tracepoint.sh create mode 100644 devtools/symbol-map- util.sh create mode 100644 devtools/trace-skiplist.txt

--
2.25.1

#33 lore raw
Quoted 8 lines · On Wed, 17 Jul 2024 12:09:53 +0000 Ankur Dwivedi <[email protected]> wrote:
Quoted 8 lines

-----Original Message-----
From: Ankur Dwivedi <[email protected]>
Sent: Friday, December 15, 2023 12:14 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Ankur Dwivedi <[email protected]>
Subject: [PATCH v6 0/2] devtools: add tracepoint check in checkpatch

Quoted 5 lines
Quoted 3 lines

This patch series adds a validation in checkpatch tool to check if tracepoint is present in any new function added in ethdev, eventdev cryptodev and mempool library.

Please let me know if this patch series can be merged in DPDK or if there are any comments.

Not sure why the patch got ignored.
Perhaps if check-tracepoint was run first against existing code; add to check-patch later.

And the skip list is empty, is that right? is all of existing cryptodev ethdev ... ok now?

#34 lore raw
Quoted 29 lines

-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Tuesday, October 8, 2024 6:11 AM
To: Ankur Dwivedi <[email protected]>
Cc: [email protected]; [email protected]; Jerin Jacob <[email protected]>
Subject: [EXTERNAL] Re: [PATCH v6 0/2] devtools: add tracepoint check in checkpatch

On Wed, 17 Jul 2024 12: 09: 53 +0000 Ankur Dwivedi
<adwivedi@ marvell. com> wrote: > >-----Original Message----- > >From: Ankur Dwivedi <adwivedi@ marvell. com> > >Sent: Friday, December 15, 2023 12: 14 PM > >To:

Quoted 12 lines · On Wed, 17 Jul 2024 12:09:53 +0000 Ankur Dwivedi <[email protected]> wrote:
Quoted 11 lines

-----Original Message-----
From: Ankur Dwivedi <[email protected]>
Sent: Friday, December 15, 2023 12:14 PM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; Ankur Dwivedi <[email protected]>
Subject: [PATCH v6 0/2] devtools: add tracepoint check in checkpatch

This patch series adds a validation in checkpatch tool to check if tracepoint is present in any new function added in ethdev, eventdev cryptodev and mempool library.

Quoted 6 lines
Quoted 1 line

Please let me know if this patch series can be merged in DPDK or if there are

any comments.

Not sure why the patch got ignored.
Perhaps if check-tracepoint was run first against existing code; add to check- patch later.

check-tracepoint reads a patch and checks if a newly added function in a library has the trace in it or not. For existing code trace can be added manually. Trace was added for existing functions in 23.03 release.

Quoted 2 lines

And the skip list is empty, is that right?

Yes.
If trace is not required for a new library function, the function name can be added in skiplist. The checkpatch will ignore trace check for that function.

Quoted 2 lines

is all of existing cryptodev ethdev ... ok
now?

No, it's not completely ok. Few functions does not have trace added. Majority have trace added.

#35 lore raw
Quoted 10 lines · On Wed, 9 Oct 2024 06:03:58 +0000 Ankur Dwivedi <[email protected]> wrote:
Quoted 6 lines
Quoted 1 line

Please let me know if this patch series can be merged in DPDK or if there are

any comments.

Not sure why the patch got ignored.
Perhaps if check-tracepoint was run first against existing code; add to check- patch later.

check-tracepoint reads a patch and checks if a newly added function in a library has the trace in it or not. For existing code trace can be added manually. Trace was added for existing functions in 23.03 release.

Quoted 1 line
Quoted 8 lines
Quoted 1 line

And the skip list is empty, is that right?

Yes.
If trace is not required for a new library function, the function name can be added in skiplist. The checkpatch will ignore trace check for that function.

Quoted 2 lines

is all of existing cryptodev ethdev ... ok
now?

No, it's not completely ok. Few functions does not have trace added. Majority have trace added.

I wonder if a coccinelle script might be better for this. Rather than adding more checks to already annoying checkpatch.

#36 lore raw
Quoted 20 lines
Quoted 9 lines · On Wed, 9 Oct 2024 06:03:58 +0000 Ankur Dwivedi <[email protected]> wrote:
Quoted 7 lines
Quoted 2 lines

Please let me know if this patch series can be merged in DPDK or if there are

any comments.

Not sure why the patch got ignored.
Perhaps if check-tracepoint was run first against existing code; add to check- patch later.

check-tracepoint reads a patch and checks if a newly added function in a

library has the trace in it or not.

Quoted 1 line

For existing code trace can be added manually. Trace was added for existing

functions in 23.03 release.

Quoted 4 lines
Quoted 2 lines

And the skip list is empty, is that right?

Yes.
If trace is not required for a new library function, the function name can be

added in skiplist.

Quoted 8 lines
Quoted 4 lines

The checkpatch will ignore trace check for that function.

Quoted 1 line

is all of existing cryptodev ethdev ... ok now?

No, it's not completely ok. Few functions does not have trace added.

Majority have trace added.

I wonder if a coccinelle script might be better for this.

Not sure if newly added functions can be detected in coccinelle script. In this patch the already existing build_map_changes shell function was detecting this.

Quoted 1 line

Rather than adding more checks to already annoying checkpatch.

#37 lore raw
Quoted 37 lines

-----Original Message-----
From: Ankur Dwivedi
Sent: Monday, October 21, 2024 7:37 PM
To: Stephen Hemminger <[email protected]>
Cc: [email protected]; [email protected]; Jerin Jacob <[email protected]>
Subject: RE: [EXTERNAL] Re: [PATCH v6 0/2] devtools: add tracepoint check in checkpatch

Quoted 27 lines
Quoted 10 lines · On Wed, 9 Oct 2024 06:03:58 +0000 Ankur Dwivedi <[email protected]> wrote:
Quoted 7 lines
Quoted 2 lines

Please let me know if this patch series can be merged in DPDK or if there are

any comments.

Not sure why the patch got ignored.
Perhaps if check-tracepoint was run first against existing code; add to check- patch later.

check-tracepoint reads a patch and checks if a newly added function in a

library has the trace in it or not.

Quoted 2 lines

For existing code trace can be added manually. Trace was added for existing

functions in 23.03 release.

Quoted 5 lines
Quoted 2 lines

And the skip list is empty, is that right?

Yes.
If trace is not required for a new library function, the function name can be

added in skiplist.

Quoted 4 lines

The checkpatch will ignore trace check for that function.

Quoted 1 line

is all of existing cryptodev ethdev ... ok now?

No, it's not completely ok. Few functions does not have trace added.

Quoted 8 lines
Quoted 4 lines

Majority have trace added.

I wonder if a coccinelle script might be better for this.

Not sure if newly added functions can be detected in coccinelle script. In this patch the already existing build_map_changes shell function was detecting this.

Let me know if any more comments or changes are required in this patch.

Quoted 2 lines
Quoted 2 lines

Rather than adding more checks to already annoying checkpatch.

#38 lore raw
Quoted 51 lines

-----Original Message-----
From: Ankur Dwivedi
Sent: Tuesday, November 5, 2024 12:37 PM
To: Stephen Hemminger <[email protected]>
Cc: [email protected]; [email protected]; Jerin Jacob <[email protected]>
Subject: RE: [EXTERNAL] Re: [PATCH v6 0/2] devtools: add tracepoint check in checkpatch

Quoted 5 lines

-----Original Message-----
From: Ankur Dwivedi
Sent: Monday, October 21, 2024 7:37 PM
To: Stephen Hemminger <[email protected]>
Cc: [email protected]; [email protected]; Jerin Jacob

<[email protected]>

Quoted 33 lines

Subject: RE: [EXTERNAL] Re: [PATCH v6 0/2] devtools: add tracepoint check in checkpatch

Quoted 30 lines
Quoted 10 lines · On Wed, 9 Oct 2024 06:03:58 +0000 Ankur Dwivedi <[email protected]> wrote:
Quoted 7 lines
Quoted 2 lines

Please let me know if this patch series can be merged in DPDK or if there are

any comments.

Not sure why the patch got ignored.
Perhaps if check-tracepoint was run first against existing code; add to check- patch later.

check-tracepoint reads a patch and checks if a newly added function in a

library has the trace in it or not.

Quoted 2 lines

For existing code trace can be added manually. Trace was added for existing

functions in 23.03 release.

Quoted 5 lines
Quoted 2 lines

And the skip list is empty, is that right?

Yes.
If trace is not required for a new library function, the function name can be

added in skiplist.

Quoted 4 lines

The checkpatch will ignore trace check for that function.

Quoted 1 line

is all of existing cryptodev ethdev ... ok now?

No, it's not completely ok. Few functions does not have trace added.

Majority have trace added.

Quoted 6 lines
Quoted 5 lines
Quoted 1 line

I wonder if a coccinelle script might be better for this.

Not sure if newly added functions can be detected in coccinelle script. In this patch the already existing build_map_changes shell function was detecting this.

Let me know if any more comments or changes are required in this patch.

Please let me know if any comments on this patch.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Rather than adding more checks to already annoying checkpatch.

Reviewed-by on the v6 series
#39 lore raw
In reply to Ankur Dwivedi
Quoted 34 lines · On Fri, 15 Dec 2023 12:13:53 +0530 Ankur Dwivedi <[email protected]> wrote:

This patch series adds a validation in checkpatch tool to check if tracepoint is present in any new function added in ethdev, eventdev cryptodev and mempool library.

v6:
- The build_map_changes function is moved from check-symbol-change.sh to a new symbol-map-util.sh file. This function can be used in other scripts by including symbol-map-util.sh file.

v5:
- Copied the build_map_changes function from check-symbol-change.sh to check-tracepoint.sh.
- Added eventdev, cryptodev and mempool in libdir in check-tracepoint.sh.

v4:
- Rebased on the recent next-net branch.
- Refined logic to find function definition.
- Updated year in the license in devtools/check-tracepoint.sh.
- Removed cryptodev, added ethdev in libdir in devtools/check-tracepoint.sh.

v3:
- Split the v2 patch into 2 patches.
- The file common-func.sh is renamed to build-symbol-map.sh.
- Removed check-tracepoint.py file.
- Code improvements in check-tracepoint.sh.

v2:
- Add check for parent directory.

Ankur Dwivedi (2):
devtools: move build map changes function
devtools: add tracepoint check in checkpatch

Quoted 10 lines
 devtools/check-symbol-change.sh |  76 +---------------
 devtools/check-tracepoint.sh    | 148 ++++++++++++++++++++++++++++++++
 devtools/checkpatches.sh        |   9 ++
 devtools/symbol-map-util.sh     |  78 +++++++++++++++++
 devtools/trace-skiplist.txt     |   0
 5 files changed, 237 insertions(+), 74 deletions(-)
 create mode 100755 devtools/check-tracepoint.sh
 create mode 100644 devtools/symbol-map-util.sh
 create mode 100644 devtools/trace-skiplist.txt

This patch seems to have not been updated since build system changes around symbols. AI spotted this an other issues. If interested change and resubmit.

Review of [PATCH v6 1/2] devtools: move build map changes function
[PATCH v6 2/2] devtools: add tracepoint check in checkpatch

NOTE: This patch series (v6, Dec 2023) is based on the old version.map / check-symbol-change.sh infrastructure. Upstream has since replaced check-symbol-change.sh with check-symbol-change.py and moved to auto-generated symbol maps via RTE_EXPORT_* macros. The build_map_changes() shell function parses version.map diffs, but version.map files are no longer manually edited. This means the entire detection mechanism will never trigger on current DPDK patches. The approach needs to be redesigned around RTE_EXPORT_* annotations rather than version.map changes.

Patch 1/2 - devtools: move build map changes function
------------------------------------------------------
No issues. The function is moved verbatim and the sourcing mechanism is correct.

Patch 2/2 - devtools: add tracepoint check in checkpatch
---------------------------------------------------------

Error:

1. find_trace_fn silently passes when the function body is absent from the patch. If a symbol is added to version.map but the function definition is in a different patch or already in the tree, the awk script never matches the function name, never reaches "exit 1", and falls through with exit status 0. The check reports "tracepoint present" when it was never examined. The awk should exit with a distinct status (e.g., 2) when the function body is not found, and the caller should handle that case (skip or warn).

Warning:

2. find_trace_fn does not filter on diff line prefixes. The awk matches the function name on any line in the patch -- context lines (space prefix), added lines (+), and removed lines (-). If a function is being deleted, its body will still match on the "-" lines, and the script could incorrectly conclude that the tracepoint is present (from the old removed code). The match on the function name and the _trace_ search should both be restricted to "+" lines to avoid false results.

3. Trap is registered before the function it references is defined. The line "trap clean_and_exit_on_sig EXIT" appears before clean_and_exit_on_sig() is defined. While POSIX sh allows this (the name is resolved when the trap fires, not when registered), it is fragile and confusing. Move the trap registration after the function definition.

4. Double cleanup on normal exit. The normal code path does "rm -f $mapfile" then "exit $exit_code". The exit triggers the EXIT trap, which runs clean_and_exit_on_sig() calling rm again (harmless) and exit again. This works but is unnecessarily convoluted. Either remove the explicit rm/exit at the bottom and let the trap handle it, or remove the trap and rely on the explicit cleanup.

5. Shell variables not quoted. Multiple instances of unquoted variables that could break on paths with spaces:

     selfdir=$(dirname $(readlink -f $0))
     . $selfdir/symbol-map-util.sh
     find_trace_fn $patch $symname
     for sym in $(cat $skiplist); do
   These should use double quotes:
     selfdir=$(dirname "$(readlink -f "$0")")
     . "$selfdir/symbol-map-util.sh"
     find_trace_fn "$patch" "$symname"

The same quoting issue exists in patch 1/2 as well. Admittedly the existing DPDK scripts have similar quoting habits, but new code should set a better example.