提交 eca1a089 编写于 作者: P Paul E. McKenney

signal: Exit RCU read-side critical section on each pass through loop

The kill_pid_info() can potentially loop indefinitely if tasks are created
and deleted sufficiently quickly, and if this happens, this function
will remain in a single RCU read-side critical section indefinitely.
This commit therefore exits the RCU read-side critical section on each
pass through the loop.  Because a race must happen to retry the loop,
this should have no performance impact in the common case.
Reported-by: NDave Jones <davej@redhat.com>
Signed-off-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
Acked-by: NOleg Nesterov <oleg@redhat.com>
Reviewed-by: NPranith Kumar <bobby.prani@gmail.com>
上级 d7e29933
...@@ -1331,23 +1331,21 @@ int kill_pid_info(int sig, struct siginfo *info, struct pid *pid) ...@@ -1331,23 +1331,21 @@ int kill_pid_info(int sig, struct siginfo *info, struct pid *pid)
int error = -ESRCH; int error = -ESRCH;
struct task_struct *p; struct task_struct *p;
rcu_read_lock(); for (;;) {
retry: rcu_read_lock();
p = pid_task(pid, PIDTYPE_PID); p = pid_task(pid, PIDTYPE_PID);
if (p) { if (p)
error = group_send_sig_info(sig, info, p); error = group_send_sig_info(sig, info, p);
if (unlikely(error == -ESRCH)) rcu_read_unlock();
/* if (likely(!p || error != -ESRCH))
* The task was unhashed in between, try again. return error;
* If it is dead, pid_task() will return NULL,
* if we race with de_thread() it will find the
* new leader.
*/
goto retry;
}
rcu_read_unlock();
return error; /*
* The task was unhashed in between, try again. If it
* is dead, pid_task() will return NULL, if we race with
* de_thread() it will find the new leader.
*/
}
} }
int kill_proc_info(int sig, struct siginfo *info, pid_t pid) int kill_proc_info(int sig, struct siginfo *info, pid_t pid)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册