The patch titled Subject: tools/lib/list_sort: remove redundant code for cond_resched handling has been added to the -mm mm-nonmm-unstable branch. Its filename is tools-lib-list_sort-remove-redundant-code-for-cond_resched-handling.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/tools-lib-list_sort-remove-redundant-code-for-cond_resched-handling.patch This patch will later appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Kuan-Wei Chiu <visitorckw@xxxxxxxxx> Subject: tools/lib/list_sort: remove redundant code for cond_resched handling Date: Sun, 26 May 2024 07:02:06 +0800 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@xxxxxxxxx Signed-off-by: Kuan-Wei Chiu <visitorckw@xxxxxxxxx> Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx> Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx> Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> Cc: Ching-Chun (Jim) Huang <jserv@xxxxxxxxxxxxxxxx> Cc: Ian Rogers <irogers@xxxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxxxxx> Cc: Jiri Olsa <jolsa@xxxxxxxxxx> Cc: Kan Liang <kan.liang@xxxxxxxxxxxxxxx> Cc: Mark Rutland <mark.rutland@xxxxxxx> Cc: Namhyung Kim <namhyung@xxxxxxxxxx> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- tools/lib/list_sort.c | 10 ---------- 1 file changed, 10 deletions(-) --- a/tools/lib/list_sort.c~tools-lib-list_sort-remove-redundant-code-for-cond_resched-handling +++ a/tools/lib/list_sort.c @@ -52,7 +52,6 @@ static void merge_final(void *priv, list 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 /* 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; _ Patches currently in -mm which might be from visitorckw@xxxxxxxxx are perf-core-fix-several-typos.patch bcache-fix-typo.patch bcachefs-fix-typo.patch lib-min_heap-add-type-safe-interface.patch lib-min_heap-add-min_heap_init.patch lib-min_heap-add-min_heap_peek.patch lib-min_heap-add-min_heap_full.patch lib-min_heap-add-args-for-min_heap_callbacks.patch lib-min_heap-add-min_heap_sift_up.patch lib-min_heap-add-min_heap_del.patch lib-min_heap-update-min_heap_push-and-min_heap_pop-to-return-bool-values.patch lib-min_heap-rename-min_heapify-to-min_heap_sift_down.patch lib-min_heap-update-min_heap_push-to-use-min_heap_sift_up.patch lib-test_min_heap-add-test-for-heap_del.patch bcache-remove-heap-related-macros-and-switch-to-generic-min_heap.patch bcachefs-remove-heap-related-macros-and-switch-to-generic-min_heap.patch lib-sort-remove-unused-pr_fmt-macro.patch lib-sort-fix-outdated-comment-regarding-glibc-qsort.patch lib-sort-optimize-heapsort-for-handling-final-2-or-3-elements.patch lib-test_sort-add-a-testcase-to-ensure-code-coverage.patch tools-lib-list_sort-remove-redundant-code-for-cond_resched-handling.patch