]> www.infradead.org Git - users/willy/linux.git/commitdiff
perf tools: Cope with differences for lib/list_sort.c copy from the kernel
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 30 Sep 2024 20:13:48 +0000 (17:13 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 2 Oct 2024 18:07:32 +0000 (15:07 -0300)
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.

Acked-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Link: https://lore.kernel.org/lkml/20240930202136.16904-3-acme@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/check-header_ignore_hunks/lib/list_sort.c [new file with mode: 0644]
tools/perf/check-headers.sh

diff --git a/tools/perf/check-header_ignore_hunks/lib/list_sort.c b/tools/perf/check-header_ignore_hunks/lib/list_sort.c
new file mode 100644 (file)
index 0000000..32d98cb
--- /dev/null
@@ -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;
index 55aba47e5aec92925846cb65fb0dff97e3ee4029..f1080d4096663ba10258fd666c4f457b49add8a5 100755 (executable)
@@ -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 ]