reduce tasklist_lock hold time on exit and do some pid cleanup
Subsystems (2)
v4 cover reduce tasklist_lock hold time on exit and do some pid cleanup
The clone side contends against exit side in a way which avoidably exacerbates the problem by the latter waiting on locks held by the former while holding the tasklist_lock.
Whacking this for both add_device_randomness and pids allocation gives me a 15% speed up for thread creation/destruction in a 24-core vm.
The random patch is worth about 4%.
nothing blew up with lockdep, lightly tested so far
Bench (plop into will-it-scale):
$ cat tests/threadspawn1.c
char *testcase_description = "Thread creation and teardown";
static void *worker(void *arg)
{
return (NULL);
}void testcase(unsigned long long *iterations, unsigned long nr)
{
pthread_t thread;
int error;
while (1) {
error = pthread_create(&thread, NULL, worker, NULL);
assert(error == 0);
error = pthread_join(thread, NULL);
assert(error == 0);
(*iterations)++;
}
}v4:
- justify moving get_pid in the commit message with a one-liner
- drop the tty unref patch -- it is completely optional and Oleg has his own variant
- add the ACK by Oleg
v3:
- keep procfs flush where it was, instead hoist get_pid outside of the lock
- make detach_pid et al accept an array argument of pids to populate
- sprinkle asserts
- drop irq trips around pidmap_lock
- move tty unref outside of tasklist_lock
Mateusz Guzik (5):
exit: perform add_device_randomness() without tasklist_lock
exit: hoist get_pid() in release_task() outside of tasklist_lock
pid: sprinkle tasklist_lock asserts
pid: perform free_pid() calls outside of tasklist_lock
pid: drop irq disablement around pidmap_lock
include/linux/pid.h | 7 ++- kernel/exit.c | 36 +++++++---- kernel/pid.c | 82 ++++++++++++++------------ kernel/sys.c | 14 +++-- scripts/selinux/genheaders/genheaders | Bin 90112 -> 0 bytes 5 files changed, 82 insertions(+), 57 deletions(-) delete mode 100755 scripts/selinux/genheaders/genheaders
Signature · 1 line
2.43.0
PATCH v4 1/5 exit: perform add_device_randomness() without tasklist_lock
Parallel calls to add_device_randomness() contend on their own.
The clone side aleady runs outside of tasklist_lock, which in turn means any caller on the exit side extends the tasklist_lock hold time while contending on the random-private lock.
--- kernel/exit.c | 6 +++--- scripts/selinux/genheaders/genheaders | Bin 90112 -> 0 bytes 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100755 scripts/selinux/genheaders/genheaders
kernel/exit.c +3 -3
@@ -174,9 +174,6 @@ static void __exit_signal(struct task_struct *tsk) sig->curr_target =next_thread (tsk); } -add_device_randomness ((const void *) &tsk->se.sum_exec_runtime, -sizeof (unsigned long long )); -/* * Accumulate here the counters for all threads as they die. We could * skip the group leader because it is the last user of signal_struct,
@@ -278,6 +275,9 @@ void release_task(struct task_struct *p)write_unlock_irq (&tasklist_lock);proc_flush_pid (thread_pid);put_pid (thread_pid); +add_device_randomness (&p->se.sum_exec_runtime, +sizeof (p->se.sum_exec_runtime)); +free_pids (post.pids);release_thread (p);put_task_struct_rcu_user (p);
scripts/selinux/genheaders/genheaders deleted binary +0 -0
Signature · 1 line
2.43.0
Re: [PATCH v4 1/5] exit: perform add_device_randomness() without tasklist_lock
scripts/selinux/genheaders/genheaders
Quoted 10 lines · Mateusz Guzik
scripts/selinux/genheaders/genheaders deleted binary +0
-0
...
Hmm? ;)
Other than that looks great.
And since you removed the tty unref patch, this series no longer conflicts with "exit: change the release_task() paths to call flush_sigqueue() lockless"
https://lore.kernel.org/all/[email protected]/ I've sent for review.
Hopefully we will add your "unref" patch later.
Oleg.
Re: [PATCH v4 1/5] exit: perform add_device_randomness() without tasklist_lock
Quoted 10 lines · Oleg Nesterov
Quoted 8 lines · Mateusz Guzik
scripts/selinux/genheaders/genheaders deleted binary +0
-0
Quoted 6 lines
Quoted 2 lines
literal 90112 zcmeI54VYWidFQXqM}!HsAV3BA;1X~VGz
MnRD8IRv5n=#7zLYDVcSUZjK)$tBMCk...
Hmm? ;)
argh.
there was a temporary window where this file was creeping in, i forgot about it. i'll resend. :/
Signature · 1 line
Mateusz Guzik <mjguzik gmail.com>
PATCH v4 2/5 exit: hoist get_pid() in release_task() outside of tasklist_lock
In reply to Mateusz Guzikreduces hold time as get_pid() contains an atomic
--- kernel/exit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/exit.c +2 -1
@@ -248,9 +248,10 @@ void release_task(struct task_struct *p)cgroup_release (p); + thread_pid =get_pid (p->thread_pid); +write_lock_irq (&tasklist_lock);ptrace_release_task (p); - thread_pid =get_pid (p->thread_pid);__exit_signal (p);/*
Signature · 1 line
2.43.0
PATCH v4 3/5 pid: sprinkle tasklist_lock asserts
In reply to Mateusz Guzik--- kernel/pid.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
kernel/pid.c +12 -3
@@ -339,17 +339,23 @@ static struct pid **task_pid_ptr(struct task_struct *task, enum pid_type type)*/ void attach_pid (struct task_struct *task,enum pid_type type) { -struct pid *pid = *task_pid_ptr (task, type); +struct pid *pid; + +lockdep_assert_held_write (&tasklist_lock); + + pid = *task_pid_ptr (task, type);hlist_add_head_rcu (&task->pid_links[type], &pid->tasks[type]); }static void __change_pid (struct task_struct *task,enum pid_type type,struct pid *new) { -struct pid **pid_ptr =task_pid_ptr (task, type); -struct pid *pid; +struct pid **pid_ptr, *pid;int tmp; +lockdep_assert_held_write (&tasklist_lock); + + pid_ptr =task_pid_ptr (task, type); pid = *pid_ptr;hlist_del_rcu (&task->pid_links[type]);
@@ -386,6 +392,8 @@ void exchange_tids(struct task_struct *left, struct task_struct *right)struct hlist_head *head1 = &pid1->tasks[PIDTYPE_PID ];struct hlist_head *head2 = &pid2->tasks[PIDTYPE_PID ]; +lockdep_assert_held_write (&tasklist_lock); +/* Swap the single entry tid lists */ hlists_swap_heads_rcu (head1, head2);
@@ -403,6 +411,7 @@ void transfer_pid(struct task_struct *old, struct task_struct *new, enum pid_type type) {WARN_ON_ONCE (type ==PIDTYPE_PID ); +lockdep_assert_held_write (&tasklist_lock);hlist_replace_rcu (&old->pid_links[type], &new->pid_links[type]); }
Signature · 1 line
2.43.0
Re: [PATCH v4 3/5] pid: sprinkle tasklist_lock asserts
* Mateusz Guzik <[email protected]> [250205 14:33]:
If a patch is worth doing, it's worth explaining. I'm surprised you didn't add a comment after the last revision missed a comment on patch 2/6. This is literally in the submitting patches document [1].
I don't mean to delay this series, but I do want to know why things are done when I'm hunting through git logs. Having a change log isn't optional, and now you know that Andrews script won't fix this problem [2].
I see you are upset by this considering the terse and lack of punctuation in patch 2, but please try to understand these comments serve a purpose in maintaining the code years later.
[1]. https://www.kernel.org/doc/html/v6.12/process/submitting-patches.html#describe-your-changes
[2]. https://lore.kernel.org/all/[email protected]/
Quoted 58 lines
Reviewed-by Oleg Nesterov <[email protected]>Signed-off-by Mateusz Guzik <[email protected]>--- kernel/pid.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)kernel/pid.c +12
-3@@ -339,17 +339,23 @@ static struct pid **task_pid_ptr(struct task_struct *task, enum pid_type type)*/ void attach_pid (struct task_struct *task,enum pid_type type) { -struct pid *pid = *task_pid_ptr (task, type); +struct pid *pid; + +lockdep_assert_held_write (&tasklist_lock); + + pid = *task_pid_ptr (task, type);hlist_add_head_rcu (&task->pid_links[type], &pid->tasks[type]); }static void __change_pid (struct task_struct *task,enum pid_type type,struct pid *new) { -struct pid **pid_ptr =task_pid_ptr (task, type); -struct pid *pid; +struct pid **pid_ptr, *pid;int tmp; +lockdep_assert_held_write (&tasklist_lock); + + pid_ptr =task_pid_ptr (task, type); pid = *pid_ptr;hlist_del_rcu (&task->pid_links[type]);@@ -386,6 +392,8 @@ void exchange_tids(struct task_struct *left, struct task_struct *right)struct hlist_head *head1 = &pid1->tasks[PIDTYPE_PID ];struct hlist_head *head2 = &pid2->tasks[PIDTYPE_PID ]; +lockdep_assert_held_write (&tasklist_lock); +/* Swap the single entry tid lists */ hlists_swap_heads_rcu (head1, head2);@@ -403,6 +411,7 @@ void transfer_pid(struct task_struct *old, struct task_struct *new, enum pid_type type) {WARN_ON_ONCE (type ==PIDTYPE_PID ); +lockdep_assert_held_write (&tasklist_lock);hlist_replace_rcu (&old->pid_links[type], &new->pid_links[type]); }Signature · 1 line
2.43.0
Re: [PATCH v4 3/5] pid: sprinkle tasklist_lock asserts
Quoted 7 lines · Liam R. Howlett
* Mateusz Guzik <[email protected]> [250205 14:33]:
If a patch is worth doing, it's worth explaining. I'm surprised you didn't add a comment after the last revision missed a comment on patch 2/6. This is literally in the submitting patches document [1].
Quoted 9 lines
I don't mean to delay this series, but I do want to know why things are done when I'm hunting through git logs. Having a change log isn't optional, and now you know that Andrews script won't fix this problem [2].
I see you are upset by this considering the terse and lack of punctuation in patch 2, but please try to understand these comments serve a purpose in maintaining the code years later.
I'm not upset.
For this specific case I don't know what can be written in the body given the really self-explanatory nature of the change, other than to spell it out(?).
Does this work for you:
The routines need to be called with the tasklist_lock, the asserts validate at runtime that this holds.
I also git log a lot and like to know what's up, to that end I appreciate *short* commit messages so that I know there is nothing more to the patch than meets the eye. In particular if there is nothing of value to add in the body, I appreciate if there is none.
But that's me, I'm not going to insist one way or the other.
Quoted 61 lines
[1]. https://www.kernel.org/doc/html/v6.12/process/submitting-patches.html#describe-your-changes
[2]. https://lore.kernel.org/all/[email protected]/Quoted 58 lines
Reviewed-by Oleg Nesterov <[email protected]>Signed-off-by Mateusz Guzik <[email protected]>--- kernel/pid.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)kernel/pid.c +12
-4@@ -339,17 +339,23 @@ static struct pid **task_pid_ptr(struct task_struct *task, enum pid_type type)*/ void attach_pid (struct task_struct *task,enum pid_type type) { -struct pid *pid = *task_pid_ptr (task, type); +struct pid *pid; + +lockdep_assert_held_write (&tasklist_lock); + + pid = *task_pid_ptr (task, type);hlist_add_head_rcu (&task->pid_links[type], &pid->tasks[type]); }static void __change_pid (struct task_struct *task,enum pid_type type,struct pid *new) { -struct pid **pid_ptr =task_pid_ptr (task, type); -struct pid *pid; +struct pid **pid_ptr, *pid;int tmp; +lockdep_assert_held_write (&tasklist_lock); + + pid_ptr =task_pid_ptr (task, type); pid = *pid_ptr;hlist_del_rcu (&task->pid_links[type]);@@ -386,6 +392,8 @@ void exchange_tids(struct task_struct *left, struct task_struct *right)struct hlist_head *head1 = &pid1->tasks[PIDTYPE_PID ];struct hlist_head *head2 = &pid2->tasks[PIDTYPE_PID ]; +lockdep_assert_held_write (&tasklist_lock); +/* Swap the single entry tid lists */ hlists_swap_heads_rcu (head1, head2);@@ -403,6 +411,7 @@ void transfer_pid(struct task_struct *old, struct task_struct *new, enum pid_type type) {WARN_ON_ONCE (type ==PIDTYPE_PID ); +lockdep_assert_held_write (&tasklist_lock);hlist_replace_rcu (&old->pid_links[type], &new->pid_links[type]); } --2.43.0
Signature · 1 line
Mateusz Guzik <mjguzik gmail.com>
Re: [PATCH v4 3/5] pid: sprinkle tasklist_lock asserts
Quoted 13 lines · Mateusz Guzik
Quoted 12 lines · Liam R. Howlett
* Mateusz Guzik <[email protected]> [250205 14:33]:
If a patch is worth doing, it's worth explaining. I'm surprised you didn't add a comment after the last revision missed a comment on patch 2/6. This is literally in the submitting patches document [1].
I don't mean to delay this series, but I do want to know why things are done when I'm hunting through git logs. Having a change log isn't optional, and now you know that Andrews script won't fix this problem [2].
Quoted 6 lines
Quoted 4 lines
I see you are upset by this considering the terse and lack of punctuation in patch 2, but please try to understand these comments serve a purpose in maintaining the code years later.
I'm not upset.
Good, thanks - that wasn't my intention.
Quoted 4 lines
For this specific case I don't know what can be written in the body given the really self-explanatory nature of the change, other than to spell it out(?).
You could say why you added it? Is this something that was seen happening?
Quoted 4 lines
Does this work for you:
The routines need to be called with thetasklist_lock, the asserts validate at runtime that this holds.
Well, you are checking this lock because it is protecting something that's being changed. You could say "the tasklist_lock protects X, make sure that it's held"?
Quoted 74 lines
I also git log a lot and like to know what's up, to that end I appreciate *short* commit messages so that I know there is nothing more to the patch than meets the eye. In particular if there is nothing of value to add in the body, I appreciate if there is none.
But that's me, I'm not going to insist one way or the other.
Quoted 61 lines
[1]. https://www.kernel.org/doc/html/v6.12/process/submitting-patches.html#describe-your-changes
[2]. https://lore.kernel.org/all/[email protected]/Quoted 58 lines
Reviewed-by Oleg Nesterov <[email protected]>Signed-off-by Mateusz Guzik <[email protected]>--- kernel/pid.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)kernel/pid.c +12
-4@@ -339,17 +339,23 @@ static struct pid **task_pid_ptr(struct task_struct *task, enum pid_type type)*/ void attach_pid (struct task_struct *task,enum pid_type type) { -struct pid *pid = *task_pid_ptr (task, type); +struct pid *pid; + +lockdep_assert_held_write (&tasklist_lock); + + pid = *task_pid_ptr (task, type);hlist_add_head_rcu (&task->pid_links[type], &pid->tasks[type]); }static void __change_pid (struct task_struct *task,enum pid_type type,struct pid *new) { -struct pid **pid_ptr =task_pid_ptr (task, type); -struct pid *pid; +struct pid **pid_ptr, *pid;int tmp; +lockdep_assert_held_write (&tasklist_lock); + + pid_ptr =task_pid_ptr (task, type); pid = *pid_ptr;hlist_del_rcu (&task->pid_links[type]);@@ -386,6 +392,8 @@ void exchange_tids(struct task_struct *left, struct task_struct *right)struct hlist_head *head1 = &pid1->tasks[PIDTYPE_PID ];struct hlist_head *head2 = &pid2->tasks[PIDTYPE_PID ]; +lockdep_assert_held_write (&tasklist_lock); +/* Swap the single entry tid lists */ hlists_swap_heads_rcu (head1, head2);@@ -403,6 +411,7 @@ void transfer_pid(struct task_struct *old, struct task_struct *new, enum pid_type type) {WARN_ON_ONCE (type ==PIDTYPE_PID ); +lockdep_assert_held_write (&tasklist_lock);hlist_replace_rcu (&old->pid_links[type], &new->pid_links[type]); } --2.43.0
Signature · 1 line
Mateusz Guzik <mjguzik gmail.com>
Re: [PATCH v4 3/5] pid: sprinkle tasklist_lock asserts
Quoted 9 lines · Liam R. Howlett
Quoted 3 lines · Mateusz Guzik
For this specific case I don't know what can be written in the body given the really self-explanatory nature of the change, other than to spell it out(?).
You could say why you added it? Is this something that was seen happening?
I guess this is a cultural discrepancy, if you will.
I spent most of my time in a codebase which is very assert-heavy and if anything you would need to justify *not* adding some, let alone for locking.
Plugging a gap of the sort would not require any explanation.
The kernel has numerous examples of mere comments stating that a given lock is required or no information whatsoever, which one can only infer from context. I'm assuming this predates lockdep. Given that lockdep asserts are nops on production kernels there is no legitimate reason to continue like that (or *avoid* asserting on lock state) that I can see.
I'm going to sleep on it, type up a sentence or two, maybe reword other commit messages and resend.
Signature · 1 line
Mateusz Guzik <mjguzik gmail.com>
PATCH v4 4/5 pid: perform free_pid() calls outside of tasklist_lock
In reply to Mateusz GuzikAs the clone side already executes pid allocation with only pidmap_lock held, issuing free_pid() while still holding tasklist_lock exacerbates total hold time of the latter.
The pid array is smuggled through newly added release_task_post struct so that any extra things want to get moved out have means to do it.
--- include/linux/pid.h | 7 ++++--- kernel/exit.c | 27 +++++++++++++++++++-------- kernel/pid.c | 44 ++++++++++++++++++++++---------------------- kernel/sys.c | 14 +++++++++----- 4 files changed, 54 insertions(+), 38 deletions(-)
include/linux/pid.h +4 -3
@@ -101,9 +101,9 @@ extern struct pid *get_task_pid(struct task_struct *task, enum pid_type type);* these helpers must be called with the tasklist_lock write-held. */ extern void attach_pid (struct task_struct *task,enum pid_type ); -extern void detach_pid (struct task_struct *task,enum pid_type ); -extern void change_pid (struct task_struct *task,enum pid_type , -struct pid *pid); +void detach_pid (struct pid **pids,struct task_struct *task,enum pid_type ); +void change_pid (struct pid **pids,struct task_struct *task,enum pid_type , +struct pid *pid);extern void exchange_tids (struct task_struct *task,struct task_struct *old);extern void transfer_pid (struct task_struct *old,struct task_struct *new,enum pid_type );
@@ -129,6 +129,7 @@ extern struct pid *find_ge_pid(int nr, struct pid_namespace *);extern struct pid *alloc_pid (struct pid_namespace *ns,pid_t *set_tid,size_t set_tid_size);extern void free_pid (struct pid *pid); +void free_pids (struct pid **pids);extern void disable_pid_allocation (struct pid_namespace *ns);/*
kernel/exit.c +19 -8
@@ -122,14 +122,22 @@ static __init int kernel_exit_sysfs_init(void)late_initcall (kernel_exit_sysfs_init);#endif -static void __unhash_process (struct task_struct *p,bool group_dead) +/* +* For things release_task() would like to do *after* tasklist_lock is released. +*/ +struct release_task_post { +struct pid *pids[PIDTYPE_MAX ]; +}; + +static void __unhash_process (struct release_task_post *post,struct task_struct *p, +bool group_dead) { nr_threads--; -detach_pid (p,PIDTYPE_PID ); +detach_pid (post->pids, p,PIDTYPE_PID );if (group_dead) { -detach_pid (p,PIDTYPE_TGID ); -detach_pid (p,PIDTYPE_PGID ); -detach_pid (p,PIDTYPE_SID ); +detach_pid (post->pids, p,PIDTYPE_TGID ); +detach_pid (post->pids, p,PIDTYPE_PGID ); +detach_pid (post->pids, p,PIDTYPE_SID );list_del_rcu (&p->tasks);list_del_init (&p->sibling);
@@ -141,7 +149,7 @@ static void __unhash_process(struct task_struct *p, bool group_dead)/* * This function expects the tasklist_lock write-locked. */ -static void __exit_signal (struct task_struct *tsk) +static void __exit_signal (struct release_task_post *post,struct task_struct *tsk) {struct signal_struct *sig = tsk->signal;bool group_dead =thread_group_leader (tsk);
@@ -194,7 +202,7 @@ static void __exit_signal(struct task_struct *tsk)task_io_accounting_add (&sig->ioac, &tsk->ioac); sig->sum_sched_runtime += tsk->se.sum_exec_runtime; sig->nr_threads--; -__unhash_process (tsk, group_dead); +__unhash_process (post, tsk, group_dead);write_sequnlock (&sig->stats_lock);/*
@@ -236,10 +244,13 @@ void __weak release_thread(struct task_struct *dead_task)void release_task (struct task_struct *p) { +struct release_task_post post;struct task_struct *leader;struct pid *thread_pid;int zap_leader; repeat: +memset (&post,0 ,sizeof (post)); +/* don't need to get the RCU readlock here - the process is dead and * can't be modifying its own credentials. But shut RCU-lockdep up */ rcu_read_lock ();
@@ -252,7 +263,7 @@ void release_task(struct task_struct *p)write_lock_irq (&tasklist_lock);ptrace_release_task (p); -__exit_signal (p); +__exit_signal (&post, p);/* * If we are the last non-leader member of the thread
kernel/pid.c +22 -22
84 lines not on this page · raw message
kernel/sys.c +9 -5
@@ -1085,6 +1085,7 @@ SYSCALL_DEFINE2(setpgid, pid_t, pid, pid_t, pgid) {struct task_struct *p;struct task_struct *group_leader = current->group_leader; +struct pid *pids[PIDTYPE_MAX ] = {0 };struct pid *pgrp;int err;
@@ -1142,13 +1143,14 @@ SYSCALL_DEFINE2(setpgid, pid_t, pid, pid_t, pgid) goto out;if (task_pgrp (p) != pgrp) -change_pid (p,PIDTYPE_PGID , pgrp); +change_pid (pids, p,PIDTYPE_PGID , pgrp); err =0 ; out:/* All paths lead to here, thus we are safe. -DaveM */ write_unlock_irq (&tasklist_lock);rcu_read_unlock (); +free_pids (pids);return err; }
@@ -1222,21 +1224,22 @@ SYSCALL_DEFINE1(getsid, pid_t, pid)return retval; } -static void set_special_pids (struct pid *pid) +static void set_special_pids (struct pid **pids,struct pid *pid) {struct task_struct *curr = current->group_leader;if (task_session (curr) != pid) -change_pid (curr,PIDTYPE_SID , pid); +change_pid (pids, curr,PIDTYPE_SID , pid);if (task_pgrp (curr) != pid) -change_pid (curr,PIDTYPE_PGID , pid); +change_pid (pids, curr,PIDTYPE_PGID , pid); }int ksys_setsid (void ) {struct task_struct *group_leader = current->group_leader;struct pid *sid =task_pid (group_leader); +struct pid *pids[PIDTYPE_MAX ] = {0 };pid_t session =pid_vnr (sid);int err = -EPERM ;
@@ -1252,13 +1255,14 @@ int ksys_setsid(void) goto out; group_leader->signal->leader =1 ; -set_special_pids (sid); +set_special_pids (pids, sid);proc_clear_tty (group_leader); err = session; out:write_unlock_irq (&tasklist_lock); +free_pids (pids);if (err >0 ) {proc_sid_connector (group_leader);sched_autogroup_create_attach (group_leader);
Signature · 1 line
2.43.0
PATCH v4 5/5 pid: drop irq disablement around pidmap_lock
In reply to Mateusz GuzikIt no longer serves any purpose now that the tasklist_lock -> pidmap_lock ordering got eliminated.
--- kernel/pid.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
kernel/pid.c +11 -12
@@ -115,11 +115,10 @@ static void delayed_put_pid(struct rcu_head *rhp)void free_pid (struct pid *pid) {int i; -unsigned long flags;lockdep_assert_not_held (&tasklist_lock); -spin_lock_irqsave (&pidmap_lock, flags); +spin_lock (&pidmap_lock);for (i =0 ; i <= pid->level; i++) {struct upid *upid = pid->numbers + i;struct pid_namespace *ns = upid->ns;
@@ -142,7 +141,7 @@ void free_pid(struct pid *pid)idr_remove (&ns->idr, upid->nr); }pidfs_remove_pid (pid); -spin_unlock_irqrestore (&pidmap_lock, flags); +spin_unlock (&pidmap_lock);call_rcu (&pid->rcu, delayed_put_pid); }
@@ -210,7 +209,7 @@ struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid, }idr_preload (GFP_KERNEL ); -spin_lock_irq (&pidmap_lock); +spin_lock (&pidmap_lock);if (tid) { nr = idr_alloc(&tmp->idr, NULL, tid,
@@ -237,7 +236,7 @@ struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid, nr =idr_alloc_cyclic (&tmp->idr,NULL , pid_min, pid_max,GFP_ATOMIC ); } -spin_unlock_irq (&pidmap_lock); +spin_unlock (&pidmap_lock);idr_preload_end ();if (nr <0 ) {
@@ -271,7 +270,7 @@ struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid, upid = pid->numbers + ns->level;idr_preload (GFP_KERNEL ); -spin_lock_irq (&pidmap_lock); +spin_lock (&pidmap_lock);if (!(ns->pid_allocated &PIDNS_ADDING )) goto out_unlock;pidfs_add_pid (pid);
@@ -280,18 +279,18 @@ struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid,idr_replace (&upid->ns->idr, pid, upid->nr); upid->ns->pid_allocated++; } -spin_unlock_irq (&pidmap_lock); +spin_unlock (&pidmap_lock);idr_preload_end ();return pid; out_unlock: -spin_unlock_irq (&pidmap_lock); +spin_unlock (&pidmap_lock);idr_preload_end ();put_pid_ns (ns); out_free: -spin_lock_irq (&pidmap_lock); +spin_lock (&pidmap_lock);while (++i <= ns->level) { upid = pid->numbers + i;idr_remove (&upid->ns->idr, upid->nr);
@@ -301,7 +300,7 @@ struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid,if (ns->pid_allocated ==PIDNS_ADDING )idr_set_cursor (&ns->idr,0 ); -spin_unlock_irq (&pidmap_lock); +spin_unlock (&pidmap_lock);kmem_cache_free (ns->pid_cachep, pid);return ERR_PTR (retval);
@@ -309,9 +308,9 @@ struct pid *alloc_pid(struct pid_namespace *ns, pid_t *set_tid,void disable_pid_allocation (struct pid_namespace *ns) { -spin_lock_irq (&pidmap_lock); +spin_lock (&pidmap_lock); ns->pid_allocated &= ~PIDNS_ADDING ; -spin_unlock_irq (&pidmap_lock); +spin_unlock (&pidmap_lock); }struct pid *find_pid_ns (int nr,struct pid_namespace *ns)
Signature · 1 line
2.43.0