]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tools/lib/list_sort: remove redundant code for cond_resched handling
authorKuan-Wei Chiu <visitorckw@gmail.com>
Sat, 25 May 2024 23:02:06 +0000 (07:02 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 25 Jun 2024 05:25:04 +0000 (22:25 -0700)
Since cond_resched() is not called in userspace, remove the redundant code
in userspace's list_sort() implementation.  This change eliminates the
unused 'count' variable and the associated logic for invoking cmp()
periodically, which was intended to trigger cond_resched() in kernel
space.

The removed code includes:
- Declaration and increment of the 'count' variable.
- Conditional invocation of cmp() based on 'count'.

This cleanup simplifies merge_final(), avoids unnecessary overhead, and
has no impact on the functionality of list_sort() in userspace.

Link: https://lkml.kernel.org/r/20240525230206.1077536-1-visitorckw@gmail.com
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ching-Chun (Jim) Huang <jserv@ccns.ncku.edu.tw>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/lib/list_sort.c

index 10c067e3a8d2ea8c0b3fb187e84350dc2ca5bde1..69affa251fa78d44bf53bd89640cb05f7f15d962 100644 (file)
@@ -52,7 +52,6 @@ static void merge_final(void *priv, list_cmp_func_t cmp, struct list_head *head,
                        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 */
@@ -78,15 +77,6 @@ static void merge_final(void *priv, list_cmp_func_t cmp, struct list_head *head,
        /* 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;