Commit be0e6f29 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds

signal: turn dequeue_signal_lock() into kernel_dequeue_signal()

1. Rename dequeue_signal_lock() to kernel_dequeue_signal(). This
   matches another "for kthreads only" kernel_sigaction() helper.

2. Remove the "tsk" and "mask" arguments, they are always current
   and current->blocked. And it is simply wrong if tsk != current.

3. We could also remove the 3rd "siginfo_t *info" arg but it looks
   potentially useful. However we can simplify the callers if we
   change kernel_dequeue_signal() to accept info => NULL.

4. Remove _irqsave, it is never called from atomic context.
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Reviewed-by: default avatarTejun Heo <tj@kernel.org>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2e01fabe
...@@ -444,9 +444,7 @@ static int nbd_thread_recv(struct nbd_device *nbd) ...@@ -444,9 +444,7 @@ static int nbd_thread_recv(struct nbd_device *nbd)
spin_unlock_irqrestore(&nbd->tasks_lock, flags); spin_unlock_irqrestore(&nbd->tasks_lock, flags);
if (signal_pending(current)) { if (signal_pending(current)) {
siginfo_t info; ret = kernel_dequeue_signal(NULL);
ret = dequeue_signal_lock(current, &current->blocked, &info);
dev_warn(nbd_to_dev(nbd), "pid %d, %s, got signal %d\n", dev_warn(nbd_to_dev(nbd), "pid %d, %s, got signal %d\n",
task_pid_nr(current), current->comm, ret); task_pid_nr(current), current->comm, ret);
mutex_lock(&nbd->tx_lock); mutex_lock(&nbd->tx_lock);
...@@ -560,11 +558,8 @@ static int nbd_thread_send(void *data) ...@@ -560,11 +558,8 @@ static int nbd_thread_send(void *data)
!list_empty(&nbd->waiting_queue)); !list_empty(&nbd->waiting_queue));
if (signal_pending(current)) { if (signal_pending(current)) {
siginfo_t info; int ret = kernel_dequeue_signal(NULL);
int ret;
ret = dequeue_signal_lock(current, &current->blocked,
&info);
dev_warn(nbd_to_dev(nbd), "pid %d, %s, got signal %d\n", dev_warn(nbd_to_dev(nbd), "pid %d, %s, got signal %d\n",
task_pid_nr(current), current->comm, ret); task_pid_nr(current), current->comm, ret);
mutex_lock(&nbd->tx_lock); mutex_lock(&nbd->tx_lock);
...@@ -592,10 +587,8 @@ static int nbd_thread_send(void *data) ...@@ -592,10 +587,8 @@ static int nbd_thread_send(void *data)
spin_unlock_irqrestore(&nbd->tasks_lock, flags); spin_unlock_irqrestore(&nbd->tasks_lock, flags);
/* Clear maybe pending signals */ /* Clear maybe pending signals */
if (signal_pending(current)) { if (signal_pending(current))
siginfo_t info; kernel_dequeue_signal(NULL);
dequeue_signal_lock(current, &current->blocked, &info);
}
return 0; return 0;
} }
......
...@@ -2345,7 +2345,6 @@ static void fsg_disable(struct usb_function *f) ...@@ -2345,7 +2345,6 @@ static void fsg_disable(struct usb_function *f)
static void handle_exception(struct fsg_common *common) static void handle_exception(struct fsg_common *common)
{ {
siginfo_t info;
int i; int i;
struct fsg_buffhd *bh; struct fsg_buffhd *bh;
enum fsg_state old_state; enum fsg_state old_state;
...@@ -2357,8 +2356,7 @@ static void handle_exception(struct fsg_common *common) ...@@ -2357,8 +2356,7 @@ static void handle_exception(struct fsg_common *common)
* into a high-priority EXIT exception. * into a high-priority EXIT exception.
*/ */
for (;;) { for (;;) {
int sig = int sig = kernel_dequeue_signal(NULL);
dequeue_signal_lock(current, &current->blocked, &info);
if (!sig) if (!sig)
break; break;
if (sig != SIGUSR1) { if (sig != SIGUSR1) {
......
...@@ -121,13 +121,12 @@ static int jffs2_garbage_collect_thread(void *_c) ...@@ -121,13 +121,12 @@ static int jffs2_garbage_collect_thread(void *_c)
/* Put_super will send a SIGKILL and then wait on the sem. /* Put_super will send a SIGKILL and then wait on the sem.
*/ */
while (signal_pending(current) || freezing(current)) { while (signal_pending(current) || freezing(current)) {
siginfo_t info;
unsigned long signr; unsigned long signr;
if (try_to_freeze()) if (try_to_freeze())
goto again; goto again;
signr = dequeue_signal_lock(current, &current->blocked, &info); signr = kernel_dequeue_signal(NULL);
switch(signr) { switch(signr) {
case SIGSTOP: case SIGSTOP:
......
...@@ -2462,14 +2462,15 @@ extern void ignore_signals(struct task_struct *); ...@@ -2462,14 +2462,15 @@ extern void ignore_signals(struct task_struct *);
extern void flush_signal_handlers(struct task_struct *, int force_default); extern void flush_signal_handlers(struct task_struct *, int force_default);
extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info); extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info);
static inline int dequeue_signal_lock(struct task_struct *tsk, sigset_t *mask, siginfo_t *info) static inline int kernel_dequeue_signal(siginfo_t *info)
{ {
unsigned long flags; struct task_struct *tsk = current;
siginfo_t __info;
int ret; int ret;
spin_lock_irqsave(&tsk->sighand->siglock, flags); spin_lock_irq(&tsk->sighand->siglock);
ret = dequeue_signal(tsk, mask, info); ret = dequeue_signal(tsk, &tsk->blocked, info ?: &__info);
spin_unlock_irqrestore(&tsk->sighand->siglock, flags); spin_unlock_irq(&tsk->sighand->siglock);
return ret; return ret;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment