From patchwork Wed Jan 20 06:15:09 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: 12031475 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 A9496C433DB for ; Wed, 20 Jan 2021 06:15:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 41D962313A for ; Wed, 20 Jan 2021 06:15:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 41D962313A 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 BBD6A6B0005; Wed, 20 Jan 2021 01:15:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B6D336B0006; Wed, 20 Jan 2021 01:15:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA9856B0007; Wed, 20 Jan 2021 01:15:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0021.hostedemail.com [216.40.44.21]) by kanga.kvack.org (Postfix) with ESMTP id 935F16B0005 for ; Wed, 20 Jan 2021 01:15:29 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 587A01EE6 for ; Wed, 20 Jan 2021 06:15:29 +0000 (UTC) X-FDA: 77725141578.11.fly48_271496927558 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 3B876180F8B82 for ; Wed, 20 Jan 2021 06:15:29 +0000 (UTC) X-HE-Tag: fly48_271496927558 X-Filterd-Recvd-Size: 4788 Received: from mail.kingsoft.com (unknown [114.255.44.146]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Wed, 20 Jan 2021 06:15:25 +0000 (UTC) X-AuditID: 0a580155-6fbff700000550c6-09-6007c47ba84e 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 9B.7E.20678.B74C7006; Wed, 20 Jan 2021 13:49:47 +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 14:15:09 +0800 Date: Wed, 20 Jan 2021 14:15:09 +0800 From: Aili Yao To: , , , Subject: [PATCH v3] mm,hwpoison: Differentiate Action Required error in current and non current processes Message-ID: <20210120141509.47969d56.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+NgFprHLMWRmVeSWpSXmKPExsXCFcGooFt9hD3B4PY1TYt7a/6zWlxsPMBo cWZakQOzx6ZPk9g9XlzdyOKx+XR1AHMUl01Kak5mWWqRvl0CV8asK6dYC54LVdxpe8fWwDiZ v4uRk0NCwETi/qFLzF2MXBxCAtOZJN5v284K4bxglNjZO40ZpIpFQFVi/6JTjCA2G5C9694s VhBbRCBFYtaMT2A1wgI5EpP+zQGL8wpYSdw80cHUxcjBwS8gJvGqwRhimb3E879nmSFKBCVO znzCAmIzC+hInFh1jBnClpfY/nYOmC0koChxeMkvdoheJYkj3TPYIOxYiWXzXrFOYBSYhWTU LCSjZiEZtYCReRUjS3FuutEmRkgQhu5gnNH0Ue8QIxMH4yFGCQ5mJRHepr9sCUK8KYmVValF +fFFpTmpxYcYpTlYlMR5W5yAUgLpiSWp2ampBalFMFkmDk6pBqZgk95D/0MCzmsaNIX3HubJ vlqsNf8m/93ZL049fKjzIcyt1TRI/MOPV+u95n+oKq2cyTHz5+QfGqJyUux5HNsPTRe89HTq oSc6DZKqfze/+9fwdvrnGXZuLPnL/I8uYDkZo3X+X4TzrhcTLaf7dvKsW/2s0vjBmRQ5ccNt J/OkJVi8wp5NvLyYK0vCl1uhV+rlSq/gCRr/DB7vFuov2r6XXS/9+Zm4N3Pef7YLNfI9bNA1 ccekxgjfs5ysLC+uz0/VP5S5YGeSxvWmxKyucJawzktnzsRXB/PEGD9rLyp/Y7Xhv/nhOa8W 3H7zsvPOzWtJazqlOg7uf+Z5yXHTe4Y7O0yd+W+xH/LUelVQ9YxLiaU4I9FQi7moOBEAi35B w7ECAAA= 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. Reviewed-by: Naoya Horiguchi Reviewed-by: Oscar Salvador Signed-off-by: Aili Yao --- mm/memory-failure.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 5a38e9eade94..2d6047780466 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 @@ -454,11 +457,12 @@ static struct task_struct *task_early_kill(struct task_struct *tsk, /* * Comparing ->mm here because current task might represent * a subthread, while tsk always points to the main thread. + * If tsk is not current, we need to fallback to + * find_early_kill_thread checking whether other processes with + * PF_MCE_EARLY set still care the error. */ if (tsk->mm == current->mm) return current; - else - return NULL; } return find_early_kill_thread(tsk); }