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 4DFB2C02198 for ; Wed, 12 Feb 2025 08:09:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A8E3828000E; Wed, 12 Feb 2025 03:09:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A3E60280001; Wed, 12 Feb 2025 03:09:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9068F28000E; Wed, 12 Feb 2025 03:09:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 72FFD280001 for ; Wed, 12 Feb 2025 03:09:22 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0D076C12D7 for ; Wed, 12 Feb 2025 08:09:22 +0000 (UTC) X-FDA: 83110567764.24.79C20D3 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf29.hostedemail.com (Postfix) with ESMTP id 6CEE912000A for ; Wed, 12 Feb 2025 08:09:19 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1739347760; a=rsa-sha256; cv=none; b=IwlguFnI1DNCpM8NWREWRX3oVlKz+Z6qstOW8HD2dhA9Er0/jkBtBhsSrVM/+F2fBw5XSd BFFA8t6uB+Up96ZFs548zKvkg2VXRgI13DtugyFmMRKx5VmVVEtooP9gzVjkWHNdb+iqCJ H9wHLljrGtjjyM3L2G9FInXxh+GKioY= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1739347760; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dkjefo0q9fQHOqZdesyEB8OcmXBB2X6ObjgTri2mhTU=; b=bnfr3T/IQhj/wTBrpRu7V4uPpPq2fQ4Cu6qiRYpC5od75jF3YUZ6YuRlx/HipEOdq8PEN5 gEJSFh3ueEVKfrcExZKHd65iQvw2aaUT/DjLRfPex9rfmUOsldniJDWN8vzlXKDnmFqrrl rf7Pj204siY1E/633w7ACKvPdo3Baps= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Yt9q95D9MzkXN3; Wed, 12 Feb 2025 16:05:41 +0800 (CST) Received: from kwepemd200019.china.huawei.com (unknown [7.221.188.193]) by mail.maildlp.com (Postfix) with ESMTPS id 3251B1802D0; Wed, 12 Feb 2025 16:09:14 +0800 (CST) Received: from [10.173.127.72] (10.173.127.72) by kwepemd200019.china.huawei.com (7.221.188.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 12 Feb 2025 16:09:13 +0800 Subject: Re: [PATCH v1 4/4] mm/hwpoison: Fix incorrect "not recovered" report for recovered clean pages To: Shuai Xue CC: , , , , , , , , , , , , , References: <20250211060200.33845-1-xueshuai@linux.alibaba.com> <20250211060200.33845-5-xueshuai@linux.alibaba.com> From: Miaohe Lin Message-ID: <5f116840-60df-c6d9-d7ff-dcf1dce7773f@huawei.com> Date: Wed, 12 Feb 2025 16:09:12 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20250211060200.33845-5-xueshuai@linux.alibaba.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.173.127.72] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemd200019.china.huawei.com (7.221.188.193) X-Rspam-User: X-Rspamd-Queue-Id: 6CEE912000A X-Rspamd-Server: rspam12 X-Stat-Signature: pjmf191tf4p4a5iuaqwh9rdzdu1bugec X-HE-Tag: 1739347759-349968 X-HE-Meta: U2FsdGVkX18390ndTRJg7mT2+7NXg9Mxn6ydTYzwhaga6OrScCyAdPW+L5TQ3PCbv7xzdxMbPLJ+SGWAEJbwjzG/rnP1p03C43DXeXB7Dmv+GzgVBLjGzdIM5sXFTz7IzS6lOlzbWHU3K4XvZmXnT+1bIme77IK6Up813o0Z2Ya3twonxDYUZ+1WvAdP5f8AA9atiL8FvmhrLqq64otLNcok8ygfU8ZSIJ3foYEXppqhnGOC+q5T8JMD6q5p6u0+cU6wrywgUCNmKgVLYmO2hgv+la1i8kceH3qA+bfHLhF2++V6EwXJw7k3QpLjZ1AGTC6YnzSdkPFa3vTe1nNpumYD7DSR9dMJex4cg9OArwNtiDutMmro+lkHwyY8GygduR5nBoZEXqgneZsE0zDDWYPlzryBZswnQE8m01/+wh6B1Weh/HLZ8Ncep6OmmGREKuLtP4TzBLh5hM0KaMxmMI9rzMkJ+DFYqc/AhF9cZ0EBZE2voXjtGPt0qihz40rDzOhIya/5e27lW0j3EpIvgmbfAdFgMgJOd8WV4pGz88rCvJRL77LhHom5eOpcmPojo++I/gd4SFTs7sfwFkZBuC16Waqg7pdEED91a4See7dQ43AKcFILijaQCTkrH6GPefYY/2N6Dw8acrEUapqWGrFafAbc5fkMAd5kvOZi905gJMwPKFGjiDsW230NnAG8lYsu9QMK/nUvbVP1MmxNEg+uhVW2Eu/Zwpb/1ua+yw8QUOXfIyqfiNuFkis51XavC8nHCd7sVkCDfESYzIDAmnkugHsp1kjZbWRZb4athL0xwyclqGOH5aHDPqIoeqsfsEwE6SLIDy1JGoW66vaE1qANn81H0HsGlzUho/zecPKlPiu7XToP4arz+mBJq985nHKHWlpj9nE26TuhlIth9J+Cp4BZ2iFS7pcWsOC2ijVA9n9MrJc50tmRFH7bOqrFdIKBuvY8ot5RQbJh4iH 5HQQGiO/ kmYklrnlnhjzoAo0pNdvbHNxu2qlp80uWrFxg0DCkeDPFnpQ8Q2CAhKp8m3ZVvYUXZhOlvRtMZ5XsLiR94thrQta8ZHev50fCl8POcj6F3Zx4daxY3cvLPIOrOW8NHFLTbzQZo0QrahhXZQd1ZTovL+L4A45wAaohueTZQdHWWgxCAsGdpONBmgzaq82lf3oPRmTyX1+fz4uZkfTxkiMh+YUeFKFumCBMQmLuPHCpIligD1qNi4+xYEz+nUyYEZqBa63IKWV2+mpSj2VcGyxcrZsbTep7g8zlrQ+O X-Bogosity: Ham, tests=bogofilter, spamicity=0.001281, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2025/2/11 14:02, Shuai Xue wrote: > 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. However, for clean pages, the > TTU_HWPOISON flag is cleared, leaving the PTE unchanged and not converted > to a hwpoison entry. Consequently, for an unmapped dirty page, the PTE is > marked as a hwpoison entry allowing kill_accessing_process() to: > > - call walk_page_range() and return 1 > - 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. > > 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 -EHWPOISON if no hwpoison PTE entry is found, preventing > an unnecessary SIGBUS. Thanks for your patch. > > Fixes: 046545a661af ("mm/hwpoison: fix error page recovered but reported "not recovered"") > Signed-off-by: Shuai Xue > --- > mm/memory-failure.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 995a15eb67e2..f9a6b136a6f0 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -883,10 +883,9 @@ static int kill_accessing_process(struct task_struct *p, unsigned long pfn, > (void *)&priv); > 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 : -EFAULT; IIUC, kill_accessing_process() is supposed to return -EHWPOISON to notify that SIGBUS is already sent to the process and kill_me_maybe() doesn't have to send it again. But with your change, kill_accessing_process() will return -EHWPOISON even if SIGBUS is not sent. Does this break the semantics of -EHWPOISON? BTW I scanned the code of walk_page_range(). It seems with implementation of hwpoison_walk_ops walk_page_range() will only return 0 or 1, i.e. always >= 0. So kill_accessing_process() will always return -EHWPOISON if this patch is applied. Correct me if I miss something. Thanks. .