Re: [PATCH] pid: remove unnecessary idr_preload()

From: Oleg Nesterov
Date: Tue Dec 16 2025 - 04:41:14 EST


On 12/15, Tycho Andersen wrote:
>
> From: "Tycho Andersen (AMD)" <tycho@xxxxxxxxxx>
>
> As near as I can tell, nothing in the second pidmap_lock critical section
> actually allocates an id, so there is no need to do idr_preload().
> idr_replace() does not, nor does pidfs_add_pid().

Yes. The extra idr_preload() was needed for pidfs_add_pid() after the commit
9698d5a483654 ("pidfs: rework inode number allocation").

But please see
[PATCH v3 2/2] pid: only take pidmap_lock once on alloc
https://lore.kernel.org/all/20251206131955.780557-3-mjguzik@xxxxxxxxx/

This patch removes the unnecessary idr_preload() too.

Oleg.