public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] lib/list_sort: Clean up list_sort() scheduling workarounds
@ 2026-03-20 18:09 Kuan-Wei Chiu
  2026-03-20 18:09 ` [PATCH v3 1/2] ubifs: Remove unnecessary cond_resched() from list_sort() compare Kuan-Wei Chiu
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Kuan-Wei Chiu @ 2026-03-20 18:09 UTC (permalink / raw)
  To: richard, akpm
  Cc: chengzhihao1, hch, jserv, eleanor15x, marscheng, linux-mtd,
	linux-kernel, Kuan-Wei Chiu

Historically, list_sort() included a hack in merge_final() that
periodically invoked dummy cmp(priv, b, b) calls when merging highly
unbalanced lists. This allowed the caller to invoke cond_resched()
within their comparison callbacks to avoid soft lockups. 

However, an audit of the kernel tree shows that fs/ubifs/ has been the
sole user of this mechanism. For all other generic list_sort() users,
this results in wasted function calls and unnecessary overhead in a
tight loop.

Recent discussions and code inspection confirmed that the lists being
sorted in UBIFS are bounded in size (a few thousand elements at most),
and the comparison functions are extremely lightweight. Therefore,
UBIFS does not actually need to rely on this mechanism.
---
Changes in v3:
- Abandoned the idea of introducing a new list_sort_nonatomic() API.
- Removed the dummy cmp() hack.
- Dropped the cond_resched() calls from UBIFS.
- Split the changes into a 2-patch series.
- Dropped Zhihao Cheng's Reviewed-by tag due to the fundamental change.

Changes in v2:
- Dropped the u8 count rate-limiter in merge() and merge_final().
- Removed cond_resched() calls from UBIFS comparison callbacks.

v2: https://lore.kernel.org/lkml/20260317165905.1482256-1-visitorckw@gmail.com/
v1: https://lore.kernel.org/lkml/20260315193900.218737-1-visitorckw@gmail.com/

Kuan-Wei Chiu (2):
  ubifs: Remove unnecessary cond_resched() from list_sort() compare
  lib/list_sort: Remove dummy cmp() calls to speed up merge_final()

 fs/ubifs/gc.c     | 2 --
 fs/ubifs/replay.c | 1 -
 lib/list_sort.c   | 9 ---------
 3 files changed, 12 deletions(-)

-- 
2.53.0.959.g497ff81fa9-goog


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-03-25  7:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 18:09 [PATCH v3 0/2] lib/list_sort: Clean up list_sort() scheduling workarounds Kuan-Wei Chiu
2026-03-20 18:09 ` [PATCH v3 1/2] ubifs: Remove unnecessary cond_resched() from list_sort() compare Kuan-Wei Chiu
2026-03-21  2:06   ` Zhihao Cheng
2026-03-25  7:18   ` Richard Weinberger
2026-03-20 18:09 ` [PATCH v3 2/2] lib/list_sort: Remove dummy cmp() calls to speed up merge_final() Kuan-Wei Chiu
2026-03-25  5:44   ` Christoph Hellwig
2026-03-21  1:21 ` [PATCH v3 0/2] lib/list_sort: Clean up list_sort() scheduling workarounds Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox