Skip to contentSkip to conversation

check_headers.sh with hunk exceptions (lib/list_sort.c tools/ copy)

PATCH In review Arnaldo Carvalho de Melo 3 participants 9 messages Sep 30, 2024 – Oct 2, 2024 perf events

lore
Share & tools
lore

Arnaldo Carvalho de Melo

author maintainer
#0 lore raw

cover check_headers.sh with hunk exceptions (lib/list_sort.c tools/ copy)

From: Arnaldo Carvalho de Melo <[email protected]>

Hi,

Please take a look, as per tools/include/uapi/README we carry
copies of kernel files for various reasons and check when it drifts, in this case we need another way to accept diffs while checking, its all spelled out in the individual patches, please ack.

- Arnaldo

Arnaldo Carvalho de Melo (2):
tools check_headers.sh: Add check variant that excludes some hunks perf tools: Cope with differences for lib/list_sort.c copy from the kernel

 .../check-header_ignore_hunks/lib/list_sort.c | 31 +++++++++++++++++++
 tools/perf/check-headers.sh                   | 29 ++++++++++++++++-
 2 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100644 tools/perf/check-header_ignore_hunks/lib/list_sort.c
Signature · 1 line
2.46.0
author maintainer
#1 lore raw

PATCH 1/2 tools check_headers.sh: Add check variant that excludes some hunks

From: Arnaldo Carvalho de Melo <[email protected]>

With 6d74e1e371d43a7b ("tools/lib/list_sort: remove redundant code for cond_resched handling") we end up with a multi-line variation in the merge_final() implementation, one that the simple line based exceptions we had so far can't cope.

Thus this check has been failing:

Warning: Kernel ABI header differences:
diff -u tools/lib/list_sort.c lib/list_sort.c

So add a new check routine that uses grep -vf to exclude some hunks that we store in the tools/perf/check-header_ignore_hunks/ directory.

This first patch is just the new check routine, the next one will use it to check lib/list_sort.c.

Cc Adrian Hunter <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Ian Rogers <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Kuan-Wei Chiu <[email protected]>
Cc Namhyung Kim <[email protected]>
---
 tools/perf/check-headers.sh | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
tools/perf/check-headers.sh +24 -0
index 714c78e5da07c163..55aba47e5aec9292 100755
@@ -136,6 +136,30 @@ beauty_check () {
   check_2 "tools/perf/trace/beauty/$file" "$file" "$@"
 }
 
+check_ignore_some_hunks () {
+  orig_file="$1"
+  tools_file="tools/$orig_file"
+  hunks_to_ignore="tools/perf/check-header_ignore_hunks/$orig_file"
+
+  if [ ! -f "$hunks_to_ignore" ]; then
+    echo "$hunks_to_ignore not found. Skipping $orig_file check."
+    FAILURES+=(
+      "$tools_file $orig_file"
+    )
+    return
+  fi
+
+  cmd="diff -u \"$tools_file\" \"$orig_file\" | grep -vf \"$hunks_to_ignore\" | wc -l | grep -qw 0"
+
+  if [ -f "$orig_file" ] && ! eval "$cmd"
+  then
+    FAILURES+=(
+      "$tools_file $orig_file"
+    )
+  fi
+}
+
+
 # Check if we have the kernel headers (tools/perf/../../include), else
 # we're probably on a detached tarball, so no point in trying to check
 # differences.
Signature · 1 line
2.46.0
author maintainer
#2 lore raw

PATCH 2/2 perf tools: Cope with differences for lib/list_sort.c copy from the kernel

In reply to Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

With 6d74e1e371d43a7b ("tools/lib/list_sort: remove redundant code for cond_resched handling") we need to use the newly added hunk based exceptions when comparing the copy we carry in tools/lib/ to the original file, do it by adding the hunks that we know will be the expected diff.

If at some point the original file is updated in other parts, then we should flag and check the file for update.

Cc Adrian Hunter <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Ian Rogers <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Kuan-Wei Chiu <[email protected]>
Cc Namhyung Kim <[email protected]>
---
 .../check-header_ignore_hunks/lib/list_sort.c | 31 +++++++++++++++++++
 tools/perf/check-headers.sh                   |  5 ++-
 2 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 tools/perf/check-header_ignore_hunks/lib/list_sort.c
tools/perf/check-header_ignore_hunks/lib/list_sort.c new file +31 -0
new file mode 100644
index 0000000000000000..32d98cb34f80a987
@@ -0,0 +1,31 @@
+@@ -1,5 +1,6 @@
+ // SPDX-License-Identifier: GPL-2.0
+ #include <linux/kernel.h>
++#include <linux/bug.h>
+ #include <linux/compiler.h>
+ #include <linux/export.h>
+ #include <linux/string.h>
+@@ -52,6 +53,7 @@
+ 			struct list_head *a, struct list_head *b)
+ {
+ 	struct list_head *tail = head;
++	u8 count = 0;
+ 
+ 	for (;;) {
+ 		/* if equal, take 'a' -- important for sort stability */
+@@ -77,6 +79,15 @@
+ 	/* Finish linking remainder of list b on to tail */
+ 	tail->next = b;
+ 	do {
++		/*
++		 * If the merge is highly unbalanced (e.g. the input is
++		 * already sorted), this loop may run many iterations.
++		 * Continue callbacks to the client even though no
++		 * element comparison is needed, so the client's cmp()
++		 * routine can invoke cond_resched() periodically.
++		 */
++		if (unlikely(!++count))
++			cmp(priv, b, b);
+ 		b->prev = tail;
+ 		tail = b;
+ 		b = b->next;
tools/perf/check-headers.sh +4 -1
index 55aba47e5aec9292..f1080d4096663ba1 100755
@@ -193,7 +193,6 @@ check include/uapi/linux/mman.h       '-I "^#include <\(uapi/\)*asm/mman.h>"'
 check include/linux/build_bug.h       '-I "^#\(ifndef\|endif\)\( \/\/\)* static_assert$"'
 check include/linux/ctype.h	      '-I "isdigit("'
 check lib/ctype.c		      '-I "^EXPORT_SYMBOL" -I "^#include <linux/export.h>" -B'
-check lib/list_sort.c		      '-I "^#include <linux/bug.h>"'
 
 # diff non-symmetric files
 check_2 tools/perf/arch/x86/entry/syscalls/syscall_32.tbl arch/x86/entry/syscalls/syscall_32.tbl
@@ -211,6 +210,10 @@ done
 check_2 tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h
 check_2 tools/perf/util/hashmap.c tools/lib/bpf/hashmap.c
 
+# Files with larger differences
+
+check_ignore_some_hunks lib/list_sort.c
+
 cd tools/perf || exit
 
 if [ ${#FAILURES[@]} -gt 0 ]
Signature · 1 line
2.46.0
maintainer
#3 lore raw

Re: [PATCH 2/2] perf tools: Cope with differences for lib/list_sort.c copy from the kernel

Quoted 11 lines · Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

With 6d74e1e371d43a7b ("tools/lib/list_sort: remove redundant code for cond_resched handling") we need to use the newly added hunk based exceptions when comparing the copy we carry in tools/lib/ to the original file, do it by adding the hunks that we know will be the expected diff.

If at some point the original file is updated in other parts, then we should flag and check the file for update.

Quoted 8 lines
Cc Adrian Hunter <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Ian Rogers <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Kuan-Wei Chiu <[email protected]>
Cc Namhyung Kim <[email protected]>

I'm seeing this but I think it's ok since we're adding a patch file as a content.

Applying: perf tools: Cope with differences for lib/list_sort.c copy from the kernel .git/rebase-apply/patch:21: space before tab in indent.
struct list_head *a, struct list_head *b)
.git/rebase-apply/patch:23: space before tab in indent.
struct list_head *tail = head;
.git/rebase-apply/patch:25: trailing whitespace.

.git/rebase-apply/patch:26: space before tab in indent.
for (;;) {
.git/rebase-apply/patch:27: space before tab in indent.
/* if equal, take 'a' -- important for sort stability */
warning: squelched 6 whitespace errors
warning: 11 lines add whitespace errors.

And build doesn't show the message for lib/list_sort.c anymore. :)

I think it's nice to update for later changes, just put the diff in a file with the same name under check-header_ignore_hunks directory. Good job!

Thanks,
Namhyung

Quoted 69 lines
---
 .../check-header_ignore_hunks/lib/list_sort.c | 31 +++++++++++++++++++
 tools/perf/check-headers.sh                   |  5 ++-
 2 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 tools/perf/check-header_ignore_hunks/lib/list_sort.c
tools/perf/check-header_ignore_hunks/lib/list_sort.c new file +31 -0
new file mode 100644
index 0000000000000000..32d98cb34f80a987
@@ -0,0 +1,31 @@
+@@ -1,5 +1,6 @@
+ // SPDX-License-Identifier: GPL-2.0
+ #include <linux/kernel.h>
++#include <linux/bug.h>
+ #include <linux/compiler.h>
+ #include <linux/export.h>
+ #include <linux/string.h>
+@@ -52,6 +53,7 @@
+ 			struct list_head *a, struct list_head *b)
+ {
+ 	struct list_head *tail = head;
++	u8 count = 0;
+ 
+ 	for (;;) {
+ 		/* if equal, take 'a' -- important for sort stability */
+@@ -77,6 +79,15 @@
+ 	/* Finish linking remainder of list b on to tail */
+ 	tail->next = b;
+ 	do {
++		/*
++		 * If the merge is highly unbalanced (e.g. the input is
++		 * already sorted), this loop may run many iterations.
++		 * Continue callbacks to the client even though no
++		 * element comparison is needed, so the client's cmp()
++		 * routine can invoke cond_resched() periodically.
++		 */
++		if (unlikely(!++count))
++			cmp(priv, b, b);
+ 		b->prev = tail;
+ 		tail = b;
+ 		b = b->next;
tools/perf/check-headers.sh +4 -1
index 55aba47e5aec9292..f1080d4096663ba1 100755
@@ -193,7 +193,6 @@ check include/uapi/linux/mman.h       '-I "^#include <\(uapi/\)*asm/mman.h>"'
 check include/linux/build_bug.h       '-I "^#\(ifndef\|endif\)\( \/\/\)* static_assert$"'
 check include/linux/ctype.h	      '-I "isdigit("'
 check lib/ctype.c		      '-I "^EXPORT_SYMBOL" -I "^#include <linux/export.h>" -B'
-check lib/list_sort.c		      '-I "^#include <linux/bug.h>"'
 
 # diff non-symmetric files
 check_2 tools/perf/arch/x86/entry/syscalls/syscall_32.tbl arch/x86/entry/syscalls/syscall_32.tbl
@@ -211,6 +210,10 @@ done
 check_2 tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h
 check_2 tools/perf/util/hashmap.c tools/lib/bpf/hashmap.c
 
+# Files with larger differences
+
+check_ignore_some_hunks lib/list_sort.c
+
 cd tools/perf || exit
 
 if [ ${#FAILURES[@]} -gt 0 ]
Signature · 1 line
2.46.0
Acked-by on the v1 series
#6 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 9 lines · Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

Hi,

Please take a look, as per tools/include/uapi/README we carry
copies of kernel files for various reasons and check when it drifts, in this case we need another way to accept diffs while checking, its all spelled out in the individual patches, please ack.

Quoted 6 lines

- Arnaldo

Arnaldo Carvalho de Melo (2):
tools check_headers.sh: Add check variant that excludes some hunks perf tools: Cope with differences for lib/list_sort.c copy from the kernel

LGTM. For the series:

While reviewing the patches, I noticed that there was already a difference between lib/list_sort.c and tools/lib/list_sort.c regarding an additional #include <linux/bug.h>. This prompted me to investigate the reason for this discrepancy. From what I can see, both files only seem to require only three headers:

#include <linux/compiler.h> /* for likely() macro */ #include <linux/export.h> /* for EXPORT_SYMBOL() macro */ #include <linux/list_sort.h> /* for list_sort() and linux/types.h */

I'll check the git history and run build tests to confirm. If only these headers are needed, I'll submit a cleanup patch.

Regards,
Kuan-Wei

Quoted 8 lines
 .../check-header_ignore_hunks/lib/list_sort.c | 31 +++++++++++++++++++
 tools/perf/check-headers.sh                   | 29 ++++++++++++++++-
 2 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100644 tools/perf/check-header_ignore_hunks/lib/list_sort.c
Signature · 1 line
2.46.0
author maintainer
#7 lore raw
Quoted 7 lines · Kuan-Wei Chiu
Quoted 5 lines · Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>
Please take a look, as per tools/include/uapi/README we carry
copies of kernel files for various reasons and check when it drifts, in this case we need another way to accept diffs while checking, its all spelled out in the individual patches, please ack.

Quoted 7 lines
Quoted 3 lines

Arnaldo Carvalho de Melo (2):
tools check_headers.sh: Add check variant that excludes some hunks perf tools: Cope with differences for lib/list_sort.c copy from the kernel

LGTM. For the series:

Adding it to that cset before pushing to the written in stone perf-tools/perf-tools branch.

Quoted 6 lines

While reviewing the patches, I noticed that there was already a difference between lib/list_sort.c and tools/lib/list_sort.c regarding an additional #include <linux/bug.h>. This prompted me to investigate the reason for this discrepancy. From what I can see, both files only seem to require only three headers:

Quoted 6 lines

#include <linux/compiler.h> /* for likely() macro */ #include <linux/export.h> /* for EXPORT_SYMBOL() macro */ #include <linux/list_sort.h> /* for list_sort() and linux/types.h */

I'll check the git history and run build tests to confirm. If only these headers are needed, I'll submit a cleanup patch.

tools/ is a sidecar or sorts for the kernel, that tries to add value to kernel developers while not getting in their way.

Sometimes things we discover while using more widely things that were designed for use in the kernel source may be of help to kernel developers, if this is one such case, great!

But IIRC that linux/bug.h discrepancy, without further checking, was something already somehow accepted via:

+check lib/list_sort.c '-I "^#include <linux/bug.h>"'

in the cset that introduced the copy:

92ec3cc94c2cb60d ("tools lib: Adopt list_sort() from the kernel sources")

- Arnaldo

author maintainer
#4 lore raw

Re: [PATCH 2/2] perf tools: Cope with differences for lib/list_sort.c copy from the kernel

In reply to Namhyung Kim
Quoted 38 lines · Namhyung Kim
Quoted 11 lines · Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

With 6d74e1e371d43a7b ("tools/lib/list_sort: remove redundant code for cond_resched handling") we need to use the newly added hunk based exceptions when comparing the copy we carry in tools/lib/ to the original file, do it by adding the hunks that we know will be the expected diff.

If at some point the original file is updated in other parts, then we should flag and check the file for update.

Quoted 8 lines
Cc Adrian Hunter <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Ian Rogers <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Kuan-Wei Chiu <[email protected]>
Cc Namhyung Kim <[email protected]>

I'm seeing this but I think it's ok since we're adding a patch file as a content.

Applying: perf tools: Cope with differences for lib/list_sort.c copy from the kernel .git/rebase-apply/patch:21: space before tab in indent.
struct list_head *a, struct list_head *b)
.git/rebase-apply/patch:23: space before tab in indent.
struct list_head *tail = head;
.git/rebase-apply/patch:25: trailing whitespace.

.git/rebase-apply/patch:26: space before tab in indent.
for (;;) {
.git/rebase-apply/patch:27: space before tab in indent.
/* if equal, take 'a' -- important for sort stability */
warning: squelched 6 whitespace errors
warning: 11 lines add whitespace errors.

Quoted 3 lines

And build doesn't show the message for lib/list_sort.c anymore. :)

I think it's nice to update for later changes, just put the diff in a

What kind of update you thinks its nice for later changes?

Quoted 1 line

file with the same name under check-header_ignore_hunks directory.

Isn't it like that already? Was the intention:

.../check-header_ignore_hunks/lib/list_sort.c | 31 +++++++++++++++++++

It is the same name as tools/lib/list_sort.c and lib/list_sort.c

Or did you mean something else?

Quoted 1 line

Good job!

Assuming all is right, thanks! 8-)

- Arnaldo

Quoted 72 lines

Thanks,
Namhyung

Quoted 69 lines
---
 .../check-header_ignore_hunks/lib/list_sort.c | 31 +++++++++++++++++++
 tools/perf/check-headers.sh                   |  5 ++-
 2 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 tools/perf/check-header_ignore_hunks/lib/list_sort.c
tools/perf/check-header_ignore_hunks/lib/list_sort.c new file +31 -0
new file mode 100644
index 0000000000000000..32d98cb34f80a987
@@ -0,0 +1,31 @@
+@@ -1,5 +1,6 @@
+ // SPDX-License-Identifier: GPL-2.0
+ #include <linux/kernel.h>
++#include <linux/bug.h>
+ #include <linux/compiler.h>
+ #include <linux/export.h>
+ #include <linux/string.h>
+@@ -52,6 +53,7 @@
+ 			struct list_head *a, struct list_head *b)
+ {
+ 	struct list_head *tail = head;
++	u8 count = 0;
+ 
+ 	for (;;) {
+ 		/* if equal, take 'a' -- important for sort stability */
+@@ -77,6 +79,15 @@
+ 	/* Finish linking remainder of list b on to tail */
+ 	tail->next = b;
+ 	do {
++		/*
++		 * If the merge is highly unbalanced (e.g. the input is
++		 * already sorted), this loop may run many iterations.
++		 * Continue callbacks to the client even though no
++		 * element comparison is needed, so the client's cmp()
++		 * routine can invoke cond_resched() periodically.
++		 */
++		if (unlikely(!++count))
++			cmp(priv, b, b);
+ 		b->prev = tail;
+ 		tail = b;
+ 		b = b->next;
tools/perf/check-headers.sh +4 -1
index 55aba47e5aec9292..f1080d4096663ba1 100755
@@ -193,7 +193,6 @@ check include/uapi/linux/mman.h       '-I "^#include <\(uapi/\)*asm/mman.h>"'
 check include/linux/build_bug.h       '-I "^#\(ifndef\|endif\)\( \/\/\)* static_assert$"'
 check include/linux/ctype.h	      '-I "isdigit("'
 check lib/ctype.c		      '-I "^EXPORT_SYMBOL" -I "^#include <linux/export.h>" -B'
-check lib/list_sort.c		      '-I "^#include <linux/bug.h>"'
 
 # diff non-symmetric files
 check_2 tools/perf/arch/x86/entry/syscalls/syscall_32.tbl arch/x86/entry/syscalls/syscall_32.tbl
@@ -211,6 +210,10 @@ done
 check_2 tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h
 check_2 tools/perf/util/hashmap.c tools/lib/bpf/hashmap.c
 
+# Files with larger differences
+
+check_ignore_some_hunks lib/list_sort.c
+
 cd tools/perf || exit
 
 if [ ${#FAILURES[@]} -gt 0 ]
Signature · 1 line
2.46.0
maintainer
#8 lore raw
In reply to Arnaldo Carvalho de Melo

Hi Arnaldo,

Quoted 12 lines · Arnaldo Carvalho de Melo
Quoted 10 lines · Kuan-Wei Chiu
Quoted 9 lines · Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>
Please take a look, as per tools/include/uapi/README we carry
copies of kernel files for various reasons and check when it drifts, in this case we need another way to accept diffs while checking, its all spelled out in the individual patches, please ack.

Arnaldo Carvalho de Melo (2):
tools check_headers.sh: Add check variant that excludes some hunks perf tools: Cope with differences for lib/list_sort.c copy from the kernel

Quoted 6 lines
Quoted 3 lines

LGTM. For the series:

Adding it to that cset before pushing to the written in stone perf-tools/perf-tools branch.

Oh, I thought you wanted to have it in the perf-tools-next branch. But it's ok to go through perf-tools. I'll drop this patchset from tmp.perf-tools-next.

Thanks,
Namhyung

Quoted 31 lines
Quoted 7 lines

While reviewing the patches, I noticed that there was already a difference between lib/list_sort.c and tools/lib/list_sort.c regarding an additional #include <linux/bug.h>. This prompted me to investigate the reason for this discrepancy. From what I can see, both files only seem to require only three headers:

Quoted 6 lines

#include <linux/compiler.h> /* for likely() macro */ #include <linux/export.h> /* for EXPORT_SYMBOL() macro */ #include <linux/list_sort.h> /* for list_sort() and linux/types.h */

I'll check the git history and run build tests to confirm. If only these headers are needed, I'll submit a cleanup patch.

tools/ is a sidecar or sorts for the kernel, that tries to add value to kernel developers while not getting in their way.

Sometimes things we discover while using more widely things that were designed for use in the kernel source may be of help to kernel developers, if this is one such case, great!

But IIRC that linux/bug.h discrepancy, without further checking, was something already somehow accepted via:

+check lib/list_sort.c '-I "^#include <linux/bug.h>"'

in the cset that introduced the copy:

92ec3cc94c2cb60d ("tools lib: Adopt list_sort() from the kernel sources")

- Arnaldo

maintainer
#5 lore raw

Re: [PATCH 2/2] perf tools: Cope with differences for lib/list_sort.c copy from the kernel

In reply to Arnaldo Carvalho de Melo
Quoted 39 lines · Arnaldo Carvalho de Melo
Quoted 38 lines · Namhyung Kim
Quoted 11 lines · Arnaldo Carvalho de Melo

From: Arnaldo Carvalho de Melo <[email protected]>

With 6d74e1e371d43a7b ("tools/lib/list_sort: remove redundant code for cond_resched handling") we need to use the newly added hunk based exceptions when comparing the copy we carry in tools/lib/ to the original file, do it by adding the hunks that we know will be the expected diff.

If at some point the original file is updated in other parts, then we should flag and check the file for update.

Quoted 8 lines
Cc Adrian Hunter <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Ian Rogers <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kan Liang <[email protected]>
Cc Kuan-Wei Chiu <[email protected]>
Cc Namhyung Kim <[email protected]>

I'm seeing this but I think it's ok since we're adding a patch file as a content.

Applying: perf tools: Cope with differences for lib/list_sort.c copy from the kernel .git/rebase-apply/patch:21: space before tab in indent.
struct list_head *a, struct list_head *b)
.git/rebase-apply/patch:23: space before tab in indent.
struct list_head *tail = head;
.git/rebase-apply/patch:25: trailing whitespace.

.git/rebase-apply/patch:26: space before tab in indent.
for (;;) {
.git/rebase-apply/patch:27: space before tab in indent.
/* if equal, take 'a' -- important for sort stability */
warning: squelched 6 whitespace errors
warning: 11 lines add whitespace errors.

Quoted 5 lines
Quoted 3 lines

And build doesn't show the message for lib/list_sort.c anymore. :)

I think it's nice to update for later changes, just put the diff in a

What kind of update you thinks its nice for later changes?

I meant it's good. :) It'd be convenient if we have some changes that need to be handled separately like this in the future.

Quoted 10 lines
Quoted 2 lines

file with the same name under check-header_ignore_hunks directory.

Isn't it like that already? Was the intention:

.../check-header_ignore_hunks/lib/list_sort.c | 31 +++++++++++++++++++

It is the same name as tools/lib/list_sort.c and lib/list_sort.c

Or did you mean something else?

No, I just said about possible future work and glad to have this.

Quoted 4 lines
Quoted 2 lines

Good job!

Assuming all is right, thanks! 8-)

Thanks,
Namhyung

Quoted 70 lines
Quoted 70 lines
Quoted 70 lines
---
 .../check-header_ignore_hunks/lib/list_sort.c | 31 +++++++++++++++++++
 tools/perf/check-headers.sh                   |  5 ++-
 2 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 tools/perf/check-header_ignore_hunks/lib/list_sort.c
tools/perf/check-header_ignore_hunks/lib/list_sort.c new file +31 -0
new file mode 100644
index 0000000000000000..32d98cb34f80a987
@@ -0,0 +1,31 @@
+@@ -1,5 +1,6 @@
+ // SPDX-License-Identifier: GPL-2.0
+ #include <linux/kernel.h>
++#include <linux/bug.h>
+ #include <linux/compiler.h>
+ #include <linux/export.h>
+ #include <linux/string.h>
+@@ -52,6 +53,7 @@
+ 			struct list_head *a, struct list_head *b)
+ {
+ 	struct list_head *tail = head;
++	u8 count = 0;
+ 
+ 	for (;;) {
+ 		/* if equal, take 'a' -- important for sort stability */
+@@ -77,6 +79,15 @@
+ 	/* Finish linking remainder of list b on to tail */
+ 	tail->next = b;
+ 	do {
++		/*
++		 * If the merge is highly unbalanced (e.g. the input is
++		 * already sorted), this loop may run many iterations.
++		 * Continue callbacks to the client even though no
++		 * element comparison is needed, so the client's cmp()
++		 * routine can invoke cond_resched() periodically.
++		 */
++		if (unlikely(!++count))
++			cmp(priv, b, b);
+ 		b->prev = tail;
+ 		tail = b;
+ 		b = b->next;
tools/perf/check-headers.sh +4 -1
index 55aba47e5aec9292..f1080d4096663ba1 100755
@@ -193,7 +193,6 @@ check include/uapi/linux/mman.h       '-I "^#include <\(uapi/\)*asm/mman.h>"'
 check include/linux/build_bug.h       '-I "^#\(ifndef\|endif\)\( \/\/\)* static_assert$"'
 check include/linux/ctype.h	      '-I "isdigit("'
 check lib/ctype.c		      '-I "^EXPORT_SYMBOL" -I "^#include <linux/export.h>" -B'
-check lib/list_sort.c		      '-I "^#include <linux/bug.h>"'
 
 # diff non-symmetric files
 check_2 tools/perf/arch/x86/entry/syscalls/syscall_32.tbl arch/x86/entry/syscalls/syscall_32.tbl
@@ -211,6 +210,10 @@ done
 check_2 tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h
 check_2 tools/perf/util/hashmap.c tools/lib/bpf/hashmap.c
 
+# Files with larger differences
+
+check_ignore_some_hunks lib/list_sort.c
+
 cd tools/perf || exit
 
 if [ ${#FAILURES[@]} -gt 0 ]
Signature · 1 line
2.46.0