From patchwork Wed Jan 20 07:03:02 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: 12031493 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,URIBL_BLOCKED, 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 AB5FFC433E0 for ; Wed, 20 Jan 2021 07:03:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A994523158 for ; Wed, 20 Jan 2021 07:03:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A994523158 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 A880F6B0005; Wed, 20 Jan 2021 02:03:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A3A7C6B0006; Wed, 20 Jan 2021 02:03:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 94FFB6B0007; Wed, 20 Jan 2021 02:03:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0192.hostedemail.com [216.40.44.192]) by kanga.kvack.org (Postfix) with ESMTP id 800AC6B0005 for ; Wed, 20 Jan 2021 02:03:17 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 42B1D1EE6 for ; Wed, 20 Jan 2021 07:03:17 +0000 (UTC) X-FDA: 77725262034.24.act43_4d0530b27558 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin24.hostedemail.com (Postfix) with ESMTP id 19BC61A4A0 for ; Wed, 20 Jan 2021 07:03:17 +0000 (UTC) X-HE-Tag: act43_4d0530b27558 X-Filterd-Recvd-Size: 5525 Received: from mail.kingsoft.com (mail.kingsoft.com [114.255.44.145]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Wed, 20 Jan 2021 07:03:10 +0000 (UTC) X-AuditID: 0a580155-713ff700000550c6-33-6007cfb70059 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-2-NODE-85) with SMTP id 00.AE.20678.7BFC7006; Wed, 20 Jan 2021 14:37:43 +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; Wed, 20 Jan 2021 15:03:05 +0800 Date: Wed, 20 Jan 2021 15:03:02 +0800 From: Aili Yao To: , , , Subject: [PATCH v4] mm,hwpoison: Differentiate Action Required error in current and non current processes Message-ID: <20210120150302.2bd277e3.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+NgFprLLMWRmVeSWpSXmKPExsXCFcGooLv9PHuCwdMpChb31vxntbjYeIDR 4sy0Igdmj02fJrF7vLi6kcVj8+nqAOYoLpuU1JzMstQifbsEroypR78zFpyUqLg4aTNjA+MD 4S5GTg4JAROJn1u/s4LYQgLTmSTmv3LtYuQCsl8wSpxd0w2WYBFQlXj7ejkziM0GZO+6Nwss LiKQIjFrxiewuLBAjsTCSx1gNq+AlcSKFVeAbA4OfgExiVcNxhC77CWe/z0LVSIocXLmExYQ m1lAR+LEqmPMELa8xPa3c5gh7lGUOLzkFztEr5LEke4ZbBB2rMSyea9YJzAKzEIyahaSUbOQ jFrAyLyKkaU4N91oEyMkBEN3MM5o+qh3iJGJg/EQowQHs5IIb9NftgQh3pTEyqrUovz4otKc 1OJDjNIcLErivC1OQCmB9MSS1OzU1ILUIpgsEwenVANTx4oNt3T28Nx+p9IVflPCUd073fPG q718n+xiMpq2tO/xffvxzFbDhfdXnPuaKPfU11p328rF01ZmHZfID6k1v7yI+wYPows/89xl YeoPusp3NWzao6QYLvzszleJ6bKL3dj4VP5z6xoU/HbXXDPJJcg33CozlTn/esNO9id37j06 uV5yNdvUhMcxOfO3BNl+WvopWf2asIzvhL9+gtHRPybuYZbNfXwhLbXYtf7uj7rv7z6qfgld tUCj7g6Hwicmg0Knwu2FrtdmXntdssM+Izdi6eTn7/xeef/z7rv/tlOQV/l0aaSgyMunChG/ N/x/d+725dLFV3+znPl14KWh+jTPH1OMzQ03bee28nbwVWIpzkg01GIuKk4EAM8feXCwAgAA X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 5a38e9eade94..4586d501aeb9 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 @@ -440,10 +443,13 @@ static struct task_struct *find_early_kill_thread(struct task_struct *tsk) * Determine whether a given process is "early kill" process which expects * to be signaled when some page under the process is hwpoisoned. * Return task_struct of the dedicated thread (main thread unless explicitly - * specified) if the process is "early kill," and otherwise returns NULL. + * specified) if the process is "early kill" and otherwise returns NULL. * - * Note that the above is true for Action Optional case, but not for Action - * Required case where SIGBUS should sent only to the current thread. + * Note that the above is true for Action Optional case. For Action Required + * case, it's only meaningful to the current thread which need to be signaled + * with SIGBUS, this error is Action Optional for other non current + * processes sharing the same error page,if the process is "early kill",the + * task_struct of the dedicated thread will also be returned. */ static struct task_struct *task_early_kill(struct task_struct *tsk, int force_early) @@ -457,8 +463,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); }