]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
signal: turn dequeue_signal_lock() into kernel_dequeue_signal()
authorOleg Nesterov <oleg@redhat.com>
Wed, 21 Oct 2015 22:03:58 +0000 (09:03 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 21 Oct 2015 22:03:58 +0000 (09:03 +1100)
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: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Tejun 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: Andrew Morton <akpm@linux-foundation.org>
drivers/block/nbd.c
drivers/usb/gadget/function/f_mass_storage.c
fs/jffs2/background.c
include/linux/sched.h

index 293495a75d3d8ce1e0f61e3571ddcc0c1fa14312..214de17d0659f54f21e2b3034a46d690f821a063 100644 (file)
@@ -432,9 +432,7 @@ static int nbd_thread_recv(struct nbd_device *nbd)
        nbd->task_recv = NULL;
 
        if (signal_pending(current)) {
-               siginfo_t info;
-
-               ret = dequeue_signal_lock(current, &current->blocked, &info);
+               ret = kernel_dequeue_signal(NULL);
                dev_warn(nbd_to_dev(nbd), "pid %d, %s, got signal %d\n",
                         task_pid_nr(current), current->comm, ret);
                mutex_lock(&nbd->tx_lock);
@@ -545,11 +543,8 @@ static int nbd_thread_send(void *data)
                                         !list_empty(&nbd->waiting_queue));
 
                if (signal_pending(current)) {
-                       siginfo_t info;
-                       int ret;
+                       int 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",
                                 task_pid_nr(current), current->comm, ret);
                        mutex_lock(&nbd->tx_lock);
index a6eb537d77689f53e7b0e31cff14c2f523c52fe4..9d1e3b3d39ca977381cdddd0c2502a08d44ba1d5 100644 (file)
@@ -2347,7 +2347,6 @@ static void fsg_disable(struct usb_function *f)
 
 static void handle_exception(struct fsg_common *common)
 {
-       siginfo_t               info;
        int                     i;
        struct fsg_buffhd       *bh;
        enum fsg_state          old_state;
@@ -2359,8 +2358,7 @@ static void handle_exception(struct fsg_common *common)
         * into a high-priority EXIT exception.
         */
        for (;;) {
-               int sig =
-                       dequeue_signal_lock(current, &current->blocked, &info);
+               int sig = kernel_dequeue_signal(NULL);
                if (!sig)
                        break;
                if (sig != SIGUSR1) {
index bb9cebc9ca8acb7e5e321e7b6fc8484174fd5fce..f3145fd86d86eab7ebe8944de8a5c44d7de58dd3 100644 (file)
@@ -121,13 +121,12 @@ static int jffs2_garbage_collect_thread(void *_c)
                /* Put_super will send a SIGKILL and then wait on the sem.
                 */
                while (signal_pending(current) || freezing(current)) {
-                       siginfo_t info;
                        unsigned long signr;
 
                        if (try_to_freeze())
                                goto again;
 
-                       signr = dequeue_signal_lock(current, &current->blocked, &info);
+                       signr = kernel_dequeue_signal(NULL);
 
                        switch(signr) {
                        case SIGSTOP:
index a21197572391ac1f7990472d9a43516375bfe12c..ecd9409640c62e5d2273a70b0697c50da83d6ce5 100644 (file)
@@ -2465,14 +2465,15 @@ extern void ignore_signals(struct task_struct *);
 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);
 
-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;
 
-       spin_lock_irqsave(&tsk->sighand->siglock, flags);
-       ret = dequeue_signal(tsk, mask, info);
-       spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
+       spin_lock_irq(&tsk->sighand->siglock);
+       ret = dequeue_signal(tsk, &tsk->blocked, info ?: &__info);
+       spin_unlock_irq(&tsk->sighand->siglock);
 
        return ret;
 }