Re: [PATCH v3 1/2] ubifs: Remove unnecessary cond_resched() from list_sort() compare
From: Richard Weinberger
Date: Wed Mar 25 2026 - 03:26:29 EST
----- Ursprüngliche Mail -----
> Von: "Kuan-Wei Chiu" <visitorckw@xxxxxxxxx>
> An: "richard" <richard@xxxxxx>, "Andrew Morton" <akpm@xxxxxxxxxxxxxxxxxxxx>
> CC: "chengzhihao1" <chengzhihao1@xxxxxxxxxx>, "Christoph Hellwig" <hch@xxxxxxxxxxxxx>, "jserv" <jserv@xxxxxxxxxxxxxxxx>,
> "eleanor15x" <eleanor15x@xxxxxxxxx>, "marscheng" <marscheng@xxxxxxxxxx>, "linux-mtd" <linux-mtd@xxxxxxxxxxxxxxxxxxx>,
> "linux-kernel" <linux-kernel@xxxxxxxxxxxxxxx>, "Kuan-Wei Chiu" <visitorckw@xxxxxxxxx>
> 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@xxxxxxxxx>
Acked-by: Richard Weinberger <richard@xxxxxx>
Thanks,
//richard