[PATCH v3 1/2] ubifs: Remove unnecessary cond_resched() from list_sort() compare
Richard Weinberger
richard at nod.at
Wed Mar 25 00:18:17 PDT 2026
----- Ursprüngliche Mail -----
> Von: "Kuan-Wei Chiu" <visitorckw at gmail.com>
> An: "richard" <richard at nod.at>, "Andrew Morton" <akpm at linux-foundation.org>
> CC: "chengzhihao1" <chengzhihao1 at huawei.com>, "Christoph Hellwig" <hch at infradead.org>, "jserv" <jserv at ccns.ncku.edu.tw>,
> "eleanor15x" <eleanor15x at gmail.com>, "marscheng" <marscheng at google.com>, "linux-mtd" <linux-mtd at lists.infradead.org>,
> "linux-kernel" <linux-kernel at vger.kernel.org>, "Kuan-Wei Chiu" <visitorckw at gmail.com>
> Gesendet: Freitag, 20. März 2026 19:09:37
> Betreff: [PATCH v3 1/2] ubifs: Remove unnecessary cond_resched() from list_sort() compare
> Historically, UBIFS embedded cond_resched() calls inside its
> list_sort() comparison callbacks (data_nodes_cmp, nondata_nodes_cmp,
> and replay_entries_cmp) to prevent soft lockups when sorting long
> lists.
>
> However, further inspection by Richard Weinberger reveals that these
> compare functions are extremely lightweight and do not perform any
> blocking MTD I/O. Furthermore, the lists being sorted are strictly
> bounded in size:
> - In the GC case, the list contains at most the number of nodes that
> fit into a single LEB.
> - In the replay case, the list spans across a few LEBs from the UBIFS
> journal, amounting to at most a few thousand elements.
>
> Since the compare functions are called a few thousand times at most,
> the overhead of frequent scheduling points is unjustified. Removing the
> cond_resched() calls simplifies the comparison logic and reduces
> unnecessary context switch checks during the sort.
>
> Signed-off-by: Kuan-Wei Chiu <visitorckw at gmail.com>
Acked-by: Richard Weinberger <richard at nod.at>
Thanks,
//richard
More information about the linux-mtd
mailing list