From: Tycho Andersen <tycho@kernel.org>
To: Christian Brauner <brauner@kernel.org>, Oleg Nesterov <oleg@redhat.com>
Cc: linux-kernel@vger.kernel.org, "Tycho Andersen (AMD)" <tycho@kernel.org>
Subject: [PATCH] pid: remove unnecessary idr_preload()
Date: Mon, 15 Dec 2025 13:15:14 -0700 [thread overview]
Message-ID: <20251215201514.1343231-1-tycho@kernel.org> (raw)
From: "Tycho Andersen (AMD)" <tycho@kernel.org>
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().
I boot tested this and built a kernel on a $large core system, so hopefully
that would have caught any errors.
Signed-off-by: Tycho Andersen (AMD) <tycho@kernel.org>
---
kernel/pid.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/kernel/pid.c b/kernel/pid.c
index a31771bc89c1..b0fefeb0a1ec 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -270,7 +270,6 @@ struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid,
INIT_HLIST_HEAD(&pid->inodes);
upid = pid->numbers + ns->level;
- idr_preload(GFP_KERNEL);
spin_lock(&pidmap_lock);
if (!(ns->pid_allocated & PIDNS_ADDING))
goto out_unlock;
@@ -281,14 +280,12 @@ struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid,
upid->ns->pid_allocated++;
}
spin_unlock(&pidmap_lock);
- idr_preload_end();
ns_ref_active_get(ns);
return pid;
out_unlock:
spin_unlock(&pidmap_lock);
- idr_preload_end();
put_pid_ns(ns);
out_free:
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
--
2.52.0
next reply other threads:[~2025-12-15 20:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-15 20:15 Tycho Andersen [this message]
2025-12-16 9:39 ` [PATCH] pid: remove unnecessary idr_preload() Oleg Nesterov
2025-12-16 15:35 ` Tycho Andersen
2025-12-16 9:44 ` Oleg Nesterov
2025-12-16 10:02 ` Mateusz Guzik
2025-12-16 15:36 ` Tycho Andersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251215201514.1343231-1-tycho@kernel.org \
--to=tycho@kernel.org \
--cc=brauner@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.