From patchwork Tue Mar 9 06:35:34 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: 12124237 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 EBC0BC433E9 for ; Tue, 9 Mar 2021 06:35:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 18720652C2 for ; Tue, 9 Mar 2021 06:35:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 18720652C2 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 6B35C8D00B5; Tue, 9 Mar 2021 01:35:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 63AEA8D007F; Tue, 9 Mar 2021 01:35:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48D648D00B5; Tue, 9 Mar 2021 01:35:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0205.hostedemail.com [216.40.44.205]) by kanga.kvack.org (Postfix) with ESMTP id 29E9C8D007F for ; Tue, 9 Mar 2021 01:35:43 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D4BE13638 for ; Tue, 9 Mar 2021 06:35:42 +0000 (UTC) X-FDA: 77899374924.25.2CEE3D5 Received: from mail.kingsoft.com (mail.kingsoft.com [114.255.44.145]) by imf04.hostedemail.com (Postfix) with ESMTP id 02896130 for ; Tue, 9 Mar 2021 06:35:36 +0000 (UTC) X-AuditID: 0a580157-47bff70000021a79-0c-604710991148 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 D3.96.06777.99017406; Tue, 9 Mar 2021 14:07:21 +0800 (HKT) Received: from alex-virtual-machine (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.2176.2; Tue, 9 Mar 2021 14:35:35 +0800 Date: Tue, 9 Mar 2021 14:35:34 +0800 From: Aili Yao To: "HORIGUCHI =?utf-8?q?NAOYA?=(=?utf-8?b?5aCA5Y+j44CA55u05Lmf?=)" CC: "Luck, Tony" , Oscar Salvador , "david@redhat.com" , "akpm@linux-foundation.org" , "bp@alien8.de" , "tglx@linutronix.de" , "mingo@redhat.com" , "hpa@zytor.com" , "x86@kernel.org" , "linux-edac@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "yangfeng1@kingsoft.com" , Subject: [PATCH v2] mm,hwpoison: return -EBUSY when page already poisoned Message-ID: <20210309143534.6c1a8ec5@alex-virtual-machine> In-Reply-To: <20210309060440.GA29668@hori.linux.bs1.fc.nec.co.jp> References: <20210304144524.795872d7@alex-virtual-machine> <20210304235720.GA215567@agluck-desk2.amr.corp.intel.com> <20210305093016.40c87375@alex-virtual-machine> <20210305093656.6c262b19@alex-virtual-machine> <20210305221143.GA220893@agluck-desk2.amr.corp.intel.com> <20210308064558.GA3617@hori.linux.bs1.fc.nec.co.jp> <3690ece2101d428fb9067fcd2a423ff8@intel.com> <20210308223839.GA21886@hori.linux.bs1.fc.nec.co.jp> <20210308225504.GA233893@agluck-desk2.amr.corp.intel.com> <20210309100421.3d09b6b1@alex-virtual-machine> <20210309060440.GA29668@hori.linux.bs1.fc.nec.co.jp> Organization: kingsoft X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.30; 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+NgFprNIsWRmVeSWpSXmKPExsXCFcGooDtTwD3B4ONbI4s569ewWXze8I/N 4uv6X8wW0zaKW1w41cBkcXnXHDaLe2v+s1pcOrCAyeJi4wFGizPTiiw2b5rKbPHmwj0Wix8b HrM68Hp8b+1j8Vi85yWTx6ZVnWwemz5NYvd4d+4cu8eJGb9ZPF5c3cji8X7fVTaPzaerPT5v kvM40fKFNYA7issmJTUnsyy1SN8ugSvj2oqbLAX3hCrWvnBtYLzF18XIySEhYCLRfXkeaxcj F4eQwHQmiYaVm9khnJeMEvN7zjGDVLEIqEh8bZnOBmKzCahK7Lo3ixXEFhFIklg8+ysTSAOz wH0WiR1/9wE5HBzCAp4SB3oUQWp4BawkWvYdYwexOQUcJS5NXcMMseAKi8TeN69ZQBL8AmIS vVf+M0GcZC/RtmURI0SzoMTJmU/AapgFdCROrDrGDGHLS2x/OwfMFhJQlDi85Bc7RK+SxJHu GWwQdqzEsnmvWCcwCs9CMmoWklGzkIxawMi8ipGlODfdcBMjJP7CdzDOa/qod4iRiYPxEKME B7OSCK/fcbcEId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rwtx10ThATSE0tSs1NTC1KLYLJMHJxS DUxlQoceMrVIHfjEtNIgc0ay2Wd/lnmM/YIHnuvMbm3LvH9q87xls+3LnRbe770m2fyr//ny V7/Krk3znPZtXfl5M532yY2hfyt2VzMareQrvf7rFMfdmwclNyx8nTPrwYuSwI/91hyneTbO WWEvdVB+ocGbcyHdx5JnZx6fNPOzyqekFHnZjD+7yp+vkn368ALT1ypWWbbMkiuvrBo4i1qi AovD7vUUXg2dEp7i2p2zbsEfE1Uvt/exX+WeWX9lCZ+hNsv1fNZTFXkx7c0z1UxfbpgetuhL 6ydRodyTyz/UW036cX/F2u/hIncW/ztrtGPDVysemQNzZrzXO/9+wYwVhhzSfW1Hjn3dm6ET svb8QiWW4oxEQy3mouJEAIh1PCguAwAA X-Stat-Signature: zgm8spp7id3y3cqm9m4oauazp5dtjpme X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 02896130 Received-SPF: none (kingsoft.com>: No applicable sender policy available) receiver=imf04; identity=mailfrom; envelope-from=""; helo=mail.kingsoft.com; client-ip=114.255.44.145 X-HE-DKIM-Result: none/none X-HE-Tag: 1615271736-454892 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 the page is already poisoned, another memory_failure() call in the same page now return 0, meaning OK. For nested memory mce handling, this behavior may lead to mce looping, Example: 1.When LCME is enabled, and there are two processes A && B running on different core X && Y separately, which will access one same page, then the page corrupted when process A access it, a MCE will be rasied to core X and the error process is just underway. 2.Then B access the page and trigger another MCE to core Y, it will also do error process, it will see TestSetPageHWPoison be true, and 0 is returned. 3.The kill_me_maybe will check the return: 1244 static void kill_me_maybe(struct callback_head *cb) 1245 { 1254 if (!memory_failure(p->mce_addr >> PAGE_SHIFT, flags) && 1255 !(p->mce_kflags & MCE_IN_KERNEL_COPYIN)) { 1256 set_mce_nospec(p->mce_addr >> PAGE_SHIFT, p->mce_whole_page); 1257 sync_core(); 1258 return; 1259 } 1267 } 4. The error process for B will end, and may nothing happened if kill-early is not set, The process B will re-excute instruction and get into mce again and then loop happens. And also the set_mce_nospec() here is not proper, may refer to commit fd0e786d9d09 ("x86/mm, mm/hwpoison: Don't unconditionally unmap kernel 1:1 pages"). For other cases which care the return value of memory_failure() should check why they want to process a memory error which have already been processed. This behavior seems reasonable. Signed-off-by: Aili Yao Reviewed-by: Naoya Horiguchi --- mm/memory-failure.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 24210c9bd843..b6bc77460ee1 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1228,7 +1228,7 @@ static int memory_failure_hugetlb(unsigned long pfn, int flags) if (TestSetPageHWPoison(head)) { pr_err("Memory failure: %#lx: already hardware poisoned\n", pfn); - return 0; + return -EBUSY; } num_poisoned_pages_inc(); @@ -1430,7 +1430,7 @@ int memory_failure(unsigned long pfn, int flags) if (TestSetPageHWPoison(p)) { pr_err("Memory failure: %#lx: already hardware poisoned\n", pfn); - return 0; + return -EBUSY; } orig_head = hpage = compound_head(p);