Whamcloud - gitweb
LU-9859 libcfs: remove unnecessary cfs_block_allsigs() calls 50/35350/15
authorNeilBrown <neilb@suse.com>
Mon, 10 Feb 2020 14:06:31 +0000 (09:06 -0500)
committerOleg Drokin <green@whamcloud.com>
Thu, 20 Feb 2020 07:14:11 +0000 (07:14 +0000)
Threads started by kthread_run() ignore all signals,
as kthreadd() calls ignore_signals(), and this is
inherited by all children.
So there is no need to call cfs_block_allsigs() in functions
that are only run from kthread_run().

For the case of lnet_ping_md_unlink() it is not from a kernel
thread but nothing in that function should be affected by
signals so it is safe to remove.

For lnet_ping() we need to manually block signals since
LNetEQPool() can unconditionally abort when a signal is
recieved.

Linux-commit: 1b2dad1459e480028a2714439048d8a634132857

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Change-Id: I124dccf78a3187d5f4a31c7b76db5369aaafc369
Reviewed-on: https://review.whamcloud.com/35350
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
13 files changed:
libcfs/include/libcfs/libcfs.h
libcfs/libcfs/linux/linux-prim.c
libcfs/libcfs/workitem.c
lnet/klnds/gnilnd/gnilnd_cb.c
lnet/klnds/gnilnd/gnilnd_conn.c
lnet/klnds/gnilnd/gnilnd_stack.c
lnet/klnds/o2iblnd/o2iblnd_cb.c
lnet/klnds/socklnd/socklnd_cb.c
lnet/lnet/acceptor.c
lnet/lnet/api-ni.c
lnet/lnet/lib-move.c
lnet/lnet/peer.c
lnet/selftest/timer.c

index 3d54dda..bf71718 100644 (file)
@@ -108,7 +108,6 @@ static inline int notifier_from_ioctl_errno(int err)
  * Defined by platform
  */
 int unshare_fs_struct(void);
-sigset_t cfs_block_allsigs(void);
 sigset_t cfs_block_sigs(unsigned long sigs);
 sigset_t cfs_block_sigsinv(unsigned long sigs);
 void cfs_restore_sigs(sigset_t);
index d0797a3..f54a5f9 100644 (file)
@@ -171,21 +171,6 @@ int kstrtobool_from_user(const char __user *s, size_t count, bool *res)
 EXPORT_SYMBOL(kstrtobool_from_user);
 #endif /* !HAVE_KSTRTOBOOL_FROM_USER */
 
-sigset_t
-cfs_block_allsigs(void)
-{
-       unsigned long   flags;
-       sigset_t        old;
-
-       spin_lock_irqsave(&current->sighand->siglock, flags);
-       old = current->blocked;
-       sigfillset(&current->blocked);
-       recalc_sigpending();
-       spin_unlock_irqrestore(&current->sighand->siglock, flags);
-       return old;
-}
-EXPORT_SYMBOL(cfs_block_allsigs);
-
 sigset_t cfs_block_sigs(unsigned long sigs)
 {
        unsigned long  flags;
index be11e32..885fc10 100644 (file)
@@ -204,8 +204,6 @@ cfs_wi_scheduler(void *arg)
 {
        struct cfs_wi_sched *sched = (struct cfs_wi_sched *)arg;
 
-       cfs_block_allsigs();
-
        /* CPT affinity scheduler? */
        if (sched->ws_cptab != NULL)
                if (cfs_cpt_bind(sched->ws_cptab, sched->ws_cpt) != 0)
index 4cff9ed..970f62c 100644 (file)
@@ -3036,8 +3036,6 @@ kgnilnd_reaper(void *arg)
        struct timer_list  timer;
        DEFINE_WAIT(wait);
 
-       cfs_block_allsigs();
-
        /* all gnilnd threads need to run fairly urgently */
        set_user_nice(current, *kgnilnd_tunables.kgn_nice);
        spin_lock(&kgnilnd_data.kgn_reaper_lock);
@@ -5013,8 +5011,6 @@ kgnilnd_scheduler(void *arg)
 
        dev = &kgnilnd_data.kgn_devices[(threadno + 1) % kgnilnd_data.kgn_ndevs];
 
-       cfs_block_allsigs();
-
        /* all gnilnd threads need to run fairly urgently */
        set_user_nice(current, *kgnilnd_tunables.kgn_sched_nice);
        deadline = jiffies + cfs_time_seconds(*kgnilnd_tunables.kgn_sched_timeout);
index 541c7ef..efb6d3d 100644 (file)
@@ -2272,7 +2272,6 @@ kgnilnd_dgram_waitq(void *arg)
        DEFINE_WAIT(mover_done);
 
        snprintf(name, sizeof(name), "kgnilnd_dgn_%02d", dev->gnd_id);
-       cfs_block_allsigs();
 
        /* all gnilnd threads need to run fairly urgently */
        set_user_nice(current, *kgnilnd_tunables.kgn_nice);
@@ -2452,7 +2451,7 @@ kgnilnd_dgram_mover(void *arg)
        DEFINE_WAIT(wait);
 
        snprintf(name, sizeof(name), "kgnilnd_dg_%02d", dev->gnd_id);
-       cfs_block_allsigs();
+
        /* all gnilnd threads need to run fairly urgently */
        set_user_nice(current, *kgnilnd_tunables.kgn_nice);
 
index 456d181..411dbff 100644 (file)
@@ -370,7 +370,6 @@ kgnilnd_ruhroh_thread(void *arg)
        int                i = 1;
        DEFINE_WAIT(wait);
 
-       cfs_block_allsigs();
        set_user_nice(current, *kgnilnd_tunables.kgn_nice);
        kgnilnd_data.kgn_ruhroh_running = 1;
 
@@ -595,8 +594,6 @@ kgnilnd_rca(void *arg)
        rs_event_t event;
        lnet_nid_t nid;
 
-       cfs_block_allsigs();
-
        /* all gnilnd threads need to run fairly urgently */
        set_user_nice(current, *kgnilnd_tunables.kgn_nice);
 
index 674f66c..b7b1cc7 100644 (file)
@@ -3502,8 +3502,6 @@ kiblnd_connd (void *arg)
        int                peer_index = 0;
        unsigned long      deadline = jiffies;
 
-       cfs_block_allsigs();
-
        init_waitqueue_entry(&wait, current);
        kiblnd_data.kib_connd = current;
 
@@ -3763,8 +3761,6 @@ kiblnd_scheduler(void *arg)
        int                     busy_loops = 0;
        int                     rc;
 
-       cfs_block_allsigs();
-
        init_waitqueue_entry(&wait, current);
 
        sched = kiblnd_data.kib_scheds[KIB_THREAD_CPT(id)];
@@ -3905,8 +3901,6 @@ kiblnd_failover_thread(void *arg)
 
        LASSERT(*kiblnd_tunables.kib_dev_failover != 0);
 
-       cfs_block_allsigs();
-
        init_waitqueue_entry(&wait, current);
        write_lock_irqsave(glock, flags);
 
index 8675858..8839f31 100644 (file)
@@ -1482,8 +1482,6 @@ int ksocknal_scheduler(void *arg)
                return -ENOMEM;
        }
 
-       cfs_block_allsigs();
-
        rc = cfs_cpt_bind(lnet_cpt_table(), sched->kss_cpt);
        if (rc != 0) {
                CWARN("Can't set CPU partition affinity to %d: %d\n",
@@ -2216,8 +2214,6 @@ ksocknal_connd(void *arg)
        int nloops = 0;
        int cons_retry = 0;
 
-       cfs_block_allsigs();
-
        init_waitqueue_entry(&wait, current);
 
        spin_lock_bh(connd_lock);
@@ -2608,8 +2604,6 @@ int ksocknal_reaper(void *arg)
        int peer_index = 0;
        time64_t deadline = ktime_get_seconds();
 
-        cfs_block_allsigs ();
-
        init_waitqueue_entry(&wait, current);
 
        spin_lock_bh(&ksocknal_data.ksnd_reaper_lock);
index beb499b..5de4d44 100644 (file)
@@ -369,8 +369,6 @@ lnet_acceptor(void *arg)
 
        LASSERT(lnet_acceptor_state.pta_sock == NULL);
 
-       cfs_block_allsigs();
-
        rc = lnet_sock_listen(&lnet_acceptor_state.pta_sock,
                              0, accept_port, accept_backlog,
                              lnet_acceptor_state.pta_ns);
index fbf3711..702ddbf 100644 (file)
@@ -37,6 +37,9 @@
 #include <linux/ktime.h>
 #include <linux/moduleparam.h>
 #include <linux/uaccess.h>
+#ifdef HAVE_SCHED_HEADERS
+#include <linux/sched/signal.h>
+#endif
 
 #include <lnet/lib-lnet.h>
 
@@ -1741,8 +1744,6 @@ static void
 lnet_ping_md_unlink(struct lnet_ping_buffer *pbuf,
                    struct lnet_handle_md *ping_mdh)
 {
-       sigset_t        blocked = cfs_block_allsigs();
-
        LNetMDUnlink(*ping_mdh);
        LNetInvalidateMDHandle(ping_mdh);
 
@@ -1751,8 +1752,6 @@ lnet_ping_md_unlink(struct lnet_ping_buffer *pbuf,
                CDEBUG(D_NET, "Still waiting for ping data MD to unlink\n");
                schedule_timeout_uninterruptible(cfs_time_seconds(1));
        }
-
-       cfs_restore_sigs(blocked);
 }
 
 static void
@@ -4155,8 +4154,12 @@ static int lnet_ping(struct lnet_process_id id, signed long timeout,
 
        do {
                /* MUST block for unlink to complete */
-               if (unlinked)
-                       blocked = cfs_block_allsigs();
+               if (unlinked) {
+                       sigset_t set;
+
+                       sigfillset(&set);
+                       sigprocmask(SIG_SETMASK, &set, &blocked);
+               }
 
                rc2 = LNetEQPoll(&eqh, 1, timeout, &event, &which);
 
index 07dc2d3..2a39b3c 100644 (file)
@@ -3494,8 +3494,6 @@ lnet_monitor_thread(void *arg)
         *  4. Checks if there are any NIs on the remote recovery queue
         *     and pings them.
         */
-       cfs_block_allsigs();
-
        while (the_lnet.ln_mt_state == LNET_MT_STATE_RUNNING) {
                now = ktime_get_real_seconds();
 
index 8570b5d..d5adfc3 100644 (file)
@@ -3280,7 +3280,6 @@ static int lnet_peer_discovery(void *arg)
        wait_for_completion(&the_lnet.ln_started);
 
        CDEBUG(D_NET, "started\n");
-       cfs_block_allsigs();
 
        for (;;) {
                if (lnet_peer_discovery_wait_for_work())
index 3ceec81..5b482db 100644 (file)
@@ -170,8 +170,6 @@ stt_timer_main (void *arg)
 {
         int rc = 0;
 
-        cfs_block_allsigs();
-
        while (!stt_data.stt_shuttingdown) {
                stt_check_timers(&stt_data.stt_prev_slot);