From patchwork Tue Jan 19 04:15:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?eWFvYWlsaSBb5LmI54ix5YipXQ==?= X-Patchwork-Id: 12028563 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43B9DC433E0 for ; Tue, 19 Jan 2021 04:15:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 31CBF20707 for ; Tue, 19 Jan 2021 04:15:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31CBF20707 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kingsoft.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6FCC18D002D; Mon, 18 Jan 2021 23:15:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6AD328D002C; Mon, 18 Jan 2021 23:15:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C3808D002D; Mon, 18 Jan 2021 23:15:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id 480148D002C for ; Mon, 18 Jan 2021 23:15:47 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0FA07180ACEEE for ; Tue, 19 Jan 2021 04:15:47 +0000 (UTC) X-FDA: 77721211134.09.bag36_0c12a372754e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id EC5EB180ACF76 for ; Tue, 19 Jan 2021 04:15:46 +0000 (UTC) X-HE-Tag: bag36_0c12a372754e X-Filterd-Recvd-Size: 5547 Received: from mail.kingsoft.com (unknown [114.255.44.146]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Tue, 19 Jan 2021 04:15:43 +0000 (UTC) X-AuditID: 0a580157-f21ff7000005df43-5a-600657a44baf Received: from mail.kingsoft.com (localhost [10.88.1.32]) (using TLS with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.kingsoft.com (SMG-1-NODE-87) with SMTP id 7E.33.57155.4A756006; Tue, 19 Jan 2021 11:53:08 +0800 (HKT) Received: from aili-OptiPlex-7020 (172.16.253.254) by KSBJMAIL2.kingsoft.cn (10.88.1.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 19 Jan 2021 12:15:31 +0800 Date: Tue, 19 Jan 2021 12:15:30 +0800 From: Aili Yao To: , , , Subject: [PATCH v2] mm,hwpoison:Differentiate Action Required error in current and non current process Message-ID: <20210119120956.7f901b76.yaoaili@kingsoft.com> Organization: Kingsoft X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Originating-IP: [172.16.253.254] X-ClientProxiedBy: KSBJMAIL1.kingsoft.cn (10.88.1.31) To KSBJMAIL2.kingsoft.cn (10.88.1.32) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLLMWRmVeSWpSXmKPExsXCFcGooLsknC3BYMdZZot7a/6zWlxsPMBo cWZakQOzx6ZPk9g9XlzdyOKx+XR1AHMUl01Kak5mWWqRvl0CV8bplceYC55JVFx8u5atgfGx cBcjJ4eEgInEr/N/2UFsIYHpTBLPD7N0MXIB2S8YJeasXs0MkmARUJU48vUPWBEbkL3r3ixW EFtEIEVi1oxPYDXCAhkS72etYAKxeQWsJHaeARnEwcEvICbxqsEYYpe9xPO/Z5khSgQlTs58 wgJiMwvoSJxYdYwZwpaX2P52DjPEPYoSh5f8YofoVZI40j2DDcKOlVg27xXrBEaBWUhGzUIy ahaSUQsYmVcxshTnphtuYoSEYPgOxnlNH/UOMTJxMB5ilOBgVhLhLV3HlCDEm5JYWZValB9f VJqTWnyIUZqDRUmcV9+ZLUFIID2xJDU7NbUgtQgmy8TBKdXAxCDO9je4JSRJr499seLd+D+x F05NZbE/Y9jIuODYvt+8PjeKnp3oT9l+8tTtVYx2WZNTfKplb5yx0V5YIVLlevKfZ62rVN2N V8+ey5iE9pzKDeSxZPNoCNq8dd0J04RdRwo7LtyaeVzbX0gysPG8T/Seue28pdM4N0WEpXjc /7L93NQFEhsvLj3pc0gjKduo9My1Zy2s34TkZBuexW2LDdSq/Xbo+HvhWOfonRL7W9LqVgVL rWZ//WQVl5j9fP3uj3oH3x87aJBp6rT4S8SizpunJz5MPGxzwW+x2raqc4adSg6h63zeK2Vv qzqTtNCFm/PybxO94woXJh2fL980uzTHj0VQ1/OSjNizul5/JZbijERDLeai4kQA/WmsQbAC AAA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hello,From 6f7f0582509e1b2aaa23e06868fee96f024e9551 Mon Sep 17 00:00:00 2001 From: Aili Yao Date: Tue, 19 Jan 2021 11:46:50 +0800 Subject: [PATCH] mm,hwpoison:Differentiate Action Required error in current and non current process When a memory uncorrected error is triggered by process A who accessed the address with error; It's Action Required Case for only current process which triggered this.this Action Required case means Action optional to other process who share the same page. Usually, kill current process will be sufficient, other process sharing the same page will get be signaled when they really touch the poisoned page. But there is another scenario that other processes sharing the same page want to be signaled early with PF_MCE_EARLY set, In this case, we should get them into kill list and signal BUS_MCEERR_AO to them. So in this patch, task_early_kill will check current process if force_early is set, and if not current,check find_early_kill_thread to see if there is PF_MCE_EARLY process which cares the error. In kill_proc, BUS_MCEERR_AR is only send to current, other process in kill list will be signaled BUS_MCEERR_AO. Signed-off-by: Aili Yao --- mm/memory-failure.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 5a38e9eade94..808ff7c24f38 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -243,9 +243,12 @@ static int kill_proc(struct to_kill *tk, unsigned long pfn, int flags) pfn, t->comm, t->pid); if (flags & MF_ACTION_REQUIRED) { - WARN_ON_ONCE(t != current); - ret = force_sig_mceerr(BUS_MCEERR_AR, + if (tk->tsk == current) + ret = force_sig_mceerr(BUS_MCEERR_AR, (void __user *)tk->addr, addr_lsb); + else + ret = send_sig_mceerr(BUS_MCEERR_AO, (void __user *)tk->addr, + addr_lsb, t); } else { /* * Don't use force here, it's convenient if the signal @@ -391,10 +394,14 @@ static void kill_procs(struct list_head *to_kill, int forcekill, bool fail, * signal and then access the memory. Just kill it. */ if (fail || tk->addr == -EFAULT) { - pr_err("Memory failure: %#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n", - pfn, tk->tsk->comm, tk->tsk->pid); - do_send_sig_info(SIGKILL, SEND_SIG_PRIV, + if (tk->tsk == current) { + pr_err("Memory failure: %#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n", + pfn, tk->tsk->comm, tk->tsk->pid); + do_send_sig_info(SIGKILL, SEND_SIG_PRIV, tk->tsk, PIDTYPE_PID); + } else if (kill_proc(tk, pfn, flags) < 0) + pr_err("Memory failure: %#lx: Cannot send advisory machine check signal to %s:%d\n", + pfn, tk->tsk->comm, tk->tsk->pid); } /* @@ -457,8 +464,6 @@ static struct task_struct *task_early_kill(struct task_struct *tsk, */ if (tsk->mm == current->mm) return current; - else - return NULL; } return find_early_kill_thread(tsk); }