mm/memory-failure.c: rework the signaling logic in kill_proc
authorMiaohe Lin <linmiaohe@huawei.com>
Tue, 22 Mar 2022 21:44:18 +0000 (14:44 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 22 Mar 2022 22:57:07 +0000 (15:57 -0700)
BUS_MCEERR_AR code is only sent when MF_ACTION_REQUIRED is set and the
target is current.  Rework the code to make this clear.

Link: https://lkml.kernel.org/r/20220218090118.1105-4-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/memory-failure.c

index b5291c8..716aebc 100644 (file)
@@ -258,16 +258,13 @@ static int kill_proc(struct to_kill *tk, unsigned long pfn, int flags)
        pr_err("Memory failure: %#lx: Sending SIGBUS to %s:%d due to hardware memory corruption\n",
                        pfn, t->comm, t->pid);
 
-       if (flags & MF_ACTION_REQUIRED) {
-               if (t == current)
-                       ret = force_sig_mceerr(BUS_MCEERR_AR,
-                                        (void __user *)tk->addr, addr_lsb);
-               else
-                       /* Signal other processes sharing the page if they have PF_MCE_EARLY set. */
-                       ret = send_sig_mceerr(BUS_MCEERR_AO, (void __user *)tk->addr,
-                               addr_lsb, t);
-       } else {
+       if ((flags & MF_ACTION_REQUIRED) && (t == current))
+               ret = force_sig_mceerr(BUS_MCEERR_AR,
+                                (void __user *)tk->addr, addr_lsb);
+       else
                /*
+                * Signal other processes sharing the page if they have
+                * PF_MCE_EARLY set.
                 * Don't use force here, it's convenient if the signal
                 * can be temporarily blocked.
                 * This could cause a loop when the user sets SIGBUS
@@ -275,7 +272,6 @@ static int kill_proc(struct to_kill *tk, unsigned long pfn, int flags)
                 */
                ret = send_sig_mceerr(BUS_MCEERR_AO, (void __user *)tk->addr,
                                      addr_lsb, t);  /* synchronous? */
-       }
        if (ret < 0)
                pr_info("Memory failure: Error sending signal to %s:%d: %d\n",
                        t->comm, t->pid, ret);