From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9A52C021A0 for ; Mon, 17 Feb 2025 06:33:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 93D65280036; Mon, 17 Feb 2025 01:33:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8ECDA280032; Mon, 17 Feb 2025 01:33:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 718EC280036; Mon, 17 Feb 2025 01:33:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4E6AD280032 for ; Mon, 17 Feb 2025 01:33:51 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 09A3C4C2DD for ; Mon, 17 Feb 2025 06:33:51 +0000 (UTC) X-FDA: 83128471062.26.014192E Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) by imf02.hostedemail.com (Postfix) with ESMTP id B594A80005 for ; Mon, 17 Feb 2025 06:33:48 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=CUttw4BX; spf=pass (imf02.hostedemail.com: domain of xueshuai@linux.alibaba.com designates 115.124.30.110 as permitted sender) smtp.mailfrom=xueshuai@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1739774029; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vvMi8bcBgppidelzMl/TigrL5YZhFRFfYcEROd+lYRc=; b=TGHp++DM/9JU4Qs0VaxJUGc9I0UurCUFcIsn/OtFvcaVsJTB+aQKYSe64VuA3y17xzHKuN O6sYagGTpuQcgyvVBBxIWqONsvdMNLi0q4ulAV1Mb11LKvsdsRRXcbndiTjwXt2biSbur3 Wp3Rhhn9kaC6q//u03huUSYjzCcu8WQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=linux.alibaba.com header.s=default header.b=CUttw4BX; spf=pass (imf02.hostedemail.com: domain of xueshuai@linux.alibaba.com designates 115.124.30.110 as permitted sender) smtp.mailfrom=xueshuai@linux.alibaba.com; dmarc=pass (policy=none) header.from=linux.alibaba.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1739774029; a=rsa-sha256; cv=none; b=bRUeoc/rSY1hSZ+eYpLMs3l5vQg0XVy4/3zLNMkXAnGT9RE2yEFk0epBvAZoa0yXP2Cb01 jLEOu3GpUySnuKUxGF/f5bPCVACoiEx6jBqjRnAIv1+jFUqhc+4ySV5r2cg/q6oh946rL0 uy2FYmHYncdsUwzZx0zr/NjzmBo58Hw= DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1739774023; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=vvMi8bcBgppidelzMl/TigrL5YZhFRFfYcEROd+lYRc=; b=CUttw4BX2Tfeg8MVmM77B3AvtOGqbsysc202/jGw7+0lMGAs/ut0QlyEP+jfnWrmeztmtBTNvagnKqNgGnBzTxKM7/NIUykck9+jpTI8dzoxLVa61qXmKOV+Znyronry3e/R5qs2SxKm3uDc1UGQbABKeSOCumXvsy1iiuqTyPQ= Received: from localhost.localdomain(mailfrom:xueshuai@linux.alibaba.com fp:SMTPD_---0WPb1mQP_1739774021 cluster:ay36) by smtp.aliyun-inc.com; Mon, 17 Feb 2025 14:33:41 +0800 From: Shuai Xue To: tony.luck@intel.com, bp@alien8.de, nao.horiguchi@gmail.com Cc: tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, linmiaohe@huawei.com, akpm@linux-foundation.org, peterz@infradead.org, jpoimboe@kernel.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, baolin.wang@linux.alibaba.com, tianruidong@linux.alibaba.com Subject: [PATCH v2 4/5] mm/hwpoison: Fix incorrect "not recovered" report for recovered clean pages Date: Mon, 17 Feb 2025 14:33:34 +0800 Message-ID: <20250217063335.22257-5-xueshuai@linux.alibaba.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20250217063335.22257-1-xueshuai@linux.alibaba.com> References: <20250217063335.22257-1-xueshuai@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: B594A80005 X-Stat-Signature: fk5mqswz7teog37xahuade8nzbffgf16 X-HE-Tag: 1739774028-188827 X-HE-Meta: U2FsdGVkX18XoqYLmnAeO7c8FE1Io6VT4UydTx+3LcJlSgwt5GS1PonXV5kd7LUO4po+Y8SYPvy9dEG2pckLVCPQtbh4XsIit25hxrOvLRMJZ9n+cQQK9dY//Slgs37nEqjjjwCv3wpfo60RF7ugUMLtxyuA6UaaC9/mEoxP1ZcefeZhR9UFDOAMEg6L16oRRkMxk6fp75lbSSl9ox0K1w1zUj2UTP61FO6ToBBouoFBwGvrMau3o15EdlxPuqESVyjhNrLndoR4K402B809EhrSB+hKPUxb8+ed7QktIjxvTiv9s7iGTTv21QqrAwrsZTb0rCJJq1rDlPU2wjduTd6lvWDbK/oLCBjQi2j88ax65smyXG3P7ELYEEgh466BSs8XYz3+BgRfbtmzgYt8yHKkGOGEdC9q6LscUnQZ6xRGuqXMT8GnrYqXLSuNfQhf/7E7mwTFyt9QGMuKBVMG3G74BHAACFoRBT0TgsE1SdD/Lqah+6fEm+soetRC2/9f+9zxYC/bd4cr213rNNlQQI/bU8XTtU9F4HTlmAMiqIzvM5ZH9xy2UutF8m5Oh8lIdk3guwT34UOlfRJ1oxbF8U6FQp5jAS56j5GVCNyzZb5vi1cvEbaucNxMWb2W9mb7NL90wsHdokt/oC6Of0ELy7zT11lD2McrWi7X+7D3XOICZQwJ4KtNbR6t0D1tacGUOlTspmaPXNlE1XCF671Uu7/A8P9smRifQangoAqkD+0KMCPmhvnqrtevXg89936PKMgP/su3T8+mN6xdTWxylyrohVPdsDVFz1zE8UQ152aIqkkhBo6G3+dD6sjpxVhlL8yWE6XKyqZxmeD77dhU+FhXV3EwC2bHReH+CuJKSfw9XGQVFGDhvNu+GcwaB0a1sgBu5zxvAFlOCdg2nQFxxuS/c2B4FVM+GZfKBG4ngM17MF8UYRoLKNPqyGES69fDFznh/w6Ed4cSDpaUKqE fpa1InmM zavsZZDci/uVikFPIGrTRX5dvbiTEX8Hh/FvAkCZ9yCKpLNuKVRicMne77EeTTNjMXpMvhJVPaiKaA01dmrfaiBjAIcf2DPPjlRpDJGzYdFbzQRsCkavGphKyuiu3eZOgves4YtXC1KU8a3T1ApwUI9XDmyZGe/4ZKplziw+kbyFBA8Iyk0C6RP6rEFWoe8+QjBZb5UFoy4OjhPVtOReUG/wkcRwn9gs1ZF43gWcy+Gkx00gCvd7yshg3Xvv0aOVggzOqUjrVzA3yZgHbkskqG4a6EBWwJQmi+TVYA2i31g5WWhlGZ1F34CEgmd/pU+z8+LmNRRzSSUHixdq4+QomXgoCsboOCAO8BV79ypijsg7JdzAY/zSZZXNwboFyd4PkKFEH X-Bogosity: Ham, tests=bogofilter, spamicity=0.052083, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When an uncorrected memory error is consumed there is a race between the CMCI from the memory controller reporting an uncorrected error with a UCNA signature, and the core reporting and SRAR signature machine check when the data is about to be consumed. If the CMCI wins that race, the page is marked poisoned when uc_decode_notifier() calls memory_failure(). For dirty pages, memory_failure() invokes try_to_unmap() with the TTU_HWPOISON flag, converting the PTE to a hwpoison entry. As a result, kill_accessing_process(): - call walk_page_range() and return 1 regardless of whether try_to_unmap() succeeds or fails, - call kill_proc() to make sure a SIGBUS is sent - return -EHWPOISON to indicate that SIGBUS is already sent to the process and kill_me_maybe() doesn't have to send it again. However, for clean pages, the TTU_HWPOISON flag is cleared, leaving the PTE unchanged and not converted to a hwpoison entry. Conversely, for clean pages where PTE entries are not marked as hwpoison, kill_accessing_process() returns -EFAULT, causing kill_me_maybe() to send a SIGBUS. Console log looks like this: Memory failure: 0x827ca68: corrupted page was clean: dropped without side effects Memory failure: 0x827ca68: recovery action for clean LRU page: Recovered Memory failure: 0x827ca68: already hardware poisoned mce: Memory error not recovered To fix it, return 0 for "corrupted page was clean", preventing an unnecessary SIGBUS. Fixes: 046545a661af ("mm/hwpoison: fix error page recovered but reported "not recovered"") Signed-off-by: Shuai Xue Cc: stable@vger.kernel.org --- mm/memory-failure.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 995a15eb67e2..b037952565be 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -881,12 +881,17 @@ static int kill_accessing_process(struct task_struct *p, unsigned long pfn, mmap_read_lock(p->mm); ret = walk_page_range(p->mm, 0, TASK_SIZE, &hwpoison_walk_ops, (void *)&priv); + /* + * ret = 1 when CMCI wins, regardless of whether try_to_unmap() + * succeeds or fails, then kill the process with SIGBUS. + * ret = 0 when poison page is a clean page and it's dropped, no + * SIGBUS is needed. + */ if (ret == 1 && priv.tk.addr) kill_proc(&priv.tk, pfn, flags); - else - ret = 0; mmap_read_unlock(p->mm); - return ret > 0 ? -EHWPOISON : -EFAULT; + + return ret > 0 ? -EHWPOISON : 0; } /* -- 2.39.3