devtools: add tracepoint check in checkpatch
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
@@ -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
@@ -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
Signature · 1 line
2.28.0
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
@@ -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
@@ -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
Signature · 1 line
2.28.0
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.shcommon-func.sh is probably a bad name.
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 checkpatchExternal 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.shalone.
Will split the patch in next version.
Quoted 4 lines
In general I see too many files added:
check-tracepoint.pyandcheck-tracepoint.shcommon-func.shis
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
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 checkpatchExternal 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 | 0Quoted 3 lines
Before diving into this proposal,
I would like a split of the patch for the rework (and move) of check-symbol-change.shalone.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.pyandcheck-tracepoint.shcommon-func.shis
probably a bad name.Regarding
common-func.shname, I am thinking of renaming it tocommon.shorhelper.sh, considering there may be more common shell routines in future. Otherwise it can be renamed tobuild-map.shconsidering it will contain onlybuild_map_changes()function. Please suggest a suitable name if my suggested names are bad.Will try to combine
check-tracepoint.pyandcheck-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.
v3 cover devtools: add tracepoint check in checkpatch
In reply to Ankur DwivediThis 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
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
@@ -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
PATCH v3 2/2 devtools: add tracepoint check in checkpatch
In reply to Ankur DwivediThis 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
@@ -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
@@ -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
Signature · 1 line
2.28.0
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 checkpatchThis 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_changesfunction from check-symbol-change.shto a new filebuild-symbol-map.sh.The second patch in the series adds a new script file
check-tracepoint.shwhich is called from checkpatch tool. Thecheck-tracepoint.shcontains 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 filecommon-func.shis renamed tobuild-symbol-map.sh.
- Removedcheck-tracepoint.pyfile.
- Code improvements incheck-tracepoint.sh.v2:
- Add check for parent directory.Ankur Dwivedi (2):
devtools: move build symbol map function
devtools: add tracepoint check in checkpatchdevtools/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.shcreate mode 100755 devtools/check-tracepoint.shcreate mode 100644devtools/trace-skiplist.txt--
2.28.0
v4 cover devtools: add tracepoint check in checkpatch
In reply to Ankur DwivediThis 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
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
@@ -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
PATCH v4 2/2 devtools: add tracepoint check in checkpatch
In reply to Ankur DwivediThis 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
@@ -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
@@ -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
Signature · 1 line
2.25.1
v5 cover devtools: add tracepoint check in checkpatch
In reply to Ankur DwivediThis 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
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
@@ -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
@@ -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
Signature · 1 line
2.25.1
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 checkpatchThis 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_changesfunction is copied from check-symbol-change.shtocheck-tracepoint.sh. Thecheck-tracepoint.shscript usesbuild_map_changesfunction 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.txtfile. The above tracepoint check will be skipped for them.Signed-off-by Ankur Dwivedi <[email protected]>---
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.shcreate mode 100644devtools/trace-skiplist.txtdevtools/check-tracepoint.sh new renamed from devtools/check-tracepoint.sh +0
-0file 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 isadded "
devtools/check-tracepoint.sh new file +1
-0+ echo -n "without a tracepoint. Please add atracepoint "
devtools/check-tracepoint.sh new file +2
-0+ echo -n "or add the function $symname in " + echo "devtools/trace-skiplist.txt to skip thiserror."
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_codedevtools/checkpatches.sh index renamed from devtools/checkpatches.sh +0
-0
1dee094c7a..471db1d21b100755devtools/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_CODESPELLto a valid path @@ -386,6 +387,14 @@ check () { # <patch-file> <commit>ret=1 fidevtools/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 - INTdevtools/trace-skiplist.txt new file renamed from devtools/trace-skiplist.txt +0
-0mode 100644 index 0000000000..e69de29bb2
--
2.25.1
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 checkpatchThis 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_changesfunction is copied from check-symbol-change.shtocheck-tracepoint.sh. Thecheck-tracepoint.shscript usesbuild_map_changesfunction 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.txtfile. The above tracepoint check will be skipped for them.Signed-off-by Ankur Dwivedi <[email protected]>
Given the amount of string processing, it would be more readable in python. That is not a show stopper, just a suggestion.
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 checkpatchExternal 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 checkpatchQuoted 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_changesfunction is copied from check-symbol-change.shtocheck-tracepoint.sh. Thecheck-tracepoint.shscript usesbuild_map_changesfunction to create amap 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.txtfile. The above tracepoint check will be skipped for them.Signed-off-by Ankur Dwivedi <[email protected]>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
Quoted 39 lines
From: Ankur Dwivedi [mailto:[email protected]]
Sent: Monday, 21 August 2023 15.54Quoted 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 PMThis 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_changesfunction is copied from check-symbol-change.shtocheck-tracepoint.sh. Thecheck-tracepoint.shscript usesbuild_map_changesfunction to createa
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.txtfile. The above tracepoint check will be skipped for them.Signed-off-by Ankur Dwivedi <[email protected]>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.
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.54Quoted 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 PMThis 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_changesfunction is copied from check-symbol-change.shtocheck-tracepoint.sh. Thecheck-tracepoint.shscript usesbuild_map_changesfunction to createa
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.txtfile. The above tracepoint check will be skipped for them.Signed-off-by Ankur Dwivedi <[email protected]>
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.
Quoted 58 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, 30 August 2023 18.2421/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.54Quoted 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 PMQuoted 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_changesfunction is copied from check-symbol-change.shtocheck-tracepoint.sh. Thecheck-tracepoint.shscript usesbuild_map_changesfunction tocreate
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.txtfile. The above tracepoint checkwill be
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
skipped for them.
Signed-off-by Ankur Dwivedi <[email protected]>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.
Quoted 23 lines · Morten Brørup
Quoted 14 lines
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, 30 August 2023 18.2421/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.54In 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.
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.2421/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.54In 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.
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.2421/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.54In 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 dumpfunctions 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.
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 thebuild_map_changesfunction fromcheck-symbol-change.shtocheck-tracepoint.sh.
- Added eventdev, cryptodev and mempool in libdir incheck-tracepoint.sh.
Why did you decide to copy the function in v5, instead of having a common file usable by different scripts?
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 thebuild_map_changesfunction fromcheck-symbol-change.shtocheck-tracepoint.sh.
- Added eventdev, cryptodev and mempool in libdir incheck-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.
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 thebuild_map_changesfunction fromcheck-symbol-change.shtocheck-tracepoint.sh.
- Added eventdev, cryptodev and mempool in libdir incheck-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.
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 checkpatch28/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 thebuild_map_changesfunction fromcheck-symbol-change.shto
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.
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 thebuild_map_changesfunction fromcheck-symbol-change.shto
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()(indevtools/check-symbol-change.sh) which is a common function can be moved to a new file nameddevtools/build-symbol-map.sh. Thebuild-symbol-map.shcan be included incheck-symbol-change.shandcheck-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?
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 checkpatch30/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 thebuild_map_changesfunction fromcheck-symbol-change.shto
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()(indevtools/check-symbol-change.sh) which is acommon function can be moved to a new file named devtools/build-symbol-
map.sh.
Quoted 7 lines
Quoted 1 line
The
build-symbol-map.shcan be included incheck-symbol-change.shand
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 aboutsymbol-map-util.shas filename?
I am ok with this filename.
Quoted 1 line
v6 cover devtools: add tracepoint check in checkpatch
In reply to Ankur DwivediThis 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
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
@@ -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
PATCH v6 2/2 devtools: add tracepoint check in checkpatch
In reply to Ankur DwivediThis 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
@@ -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
@@ -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
Signature · 1 line
2.25.1
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 checkpatchThis 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:
- Thebuild_map_changesfunction is moved fromcheck-symbol-change.shto a newsymbol-map-util.shfile. This function can be used in other scripts by includingsymbol-map-util.shfile.v5:
- Copied thebuild_map_changesfunction fromcheck-symbol-change.shtocheck-tracepoint.sh.
- Added eventdev, cryptodev and mempool in libdir incheck-tracepoint.sh.v4:
- Rebased on the recent next-net branch.
- Refined logic to find function definition.
- Updated year in the license indevtools/check-tracepoint.sh.
- Removed cryptodev, added ethdev in libdir indevtools/check-tracepoint.sh.v3:
- Split the v2 patch into 2 patches.
- The filecommon-func.shis renamed tobuild-symbol-map.sh.
- Removedcheck-tracepoint.pyfile.
- Code improvements incheck-tracepoint.sh.v2:
- Add check for parent directory.Ankur Dwivedi (2):
devtools: move build map changes function
devtools: add tracepoint check in checkpatchdevtools/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.shcreate mode 100644 devtools/symbol-map-util.shcreate mode 100644devtools/trace-skiplist.txt--
2.25.1
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?
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 checkpatchOn 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 checkpatchThis 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.
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.
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 beadded 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.
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 checkpatchQuoted 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 beadded 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_changesshell 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.
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 checkpatchQuoted 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 JacobQuoted 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 beadded 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_changesshell 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.
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:
- Thebuild_map_changesfunction is moved fromcheck-symbol-change.shto a newsymbol-map-util.shfile. This function can be used in other scripts by includingsymbol-map-util.shfile.v5:
- Copied thebuild_map_changesfunction fromcheck-symbol-change.shtocheck-tracepoint.sh.
- Added eventdev, cryptodev and mempool in libdir incheck-tracepoint.sh.v4:
- Rebased on the recent next-net branch.
- Refined logic to find function definition.
- Updated year in the license indevtools/check-tracepoint.sh.
- Removed cryptodev, added ethdev in libdir indevtools/check-tracepoint.sh.v3:
- Split the v2 patch into 2 patches.
- The filecommon-func.shis renamed tobuild-symbol-map.sh.
- Removedcheck-tracepoint.pyfile.
- Code improvements incheck-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.