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 9A99CC25B78 for ; Thu, 23 May 2024 02:32:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B6846B0096; Wed, 22 May 2024 22:32:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 167446B0098; Wed, 22 May 2024 22:32:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 02E0C6B0099; Wed, 22 May 2024 22:32:05 -0400 (EDT) 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 DBA156B0096 for ; Wed, 22 May 2024 22:32:05 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8C3F6400FE for ; Thu, 23 May 2024 02:32:05 +0000 (UTC) X-FDA: 82148085810.29.46572E3 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf01.hostedemail.com (Postfix) with ESMTP id 1F3F54001D for ; Thu, 23 May 2024 02:32:01 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716431523; a=rsa-sha256; cv=none; b=5q5eFXGBPlggaMoMEzlyiHsoEA1th4zMqJHncqBoi3VlKnh3GRvX+XOGWCVzHqt7eUBfBR eZ58p5KblM+DomFBJvLiGNmyfUMmZFGuJa9vIrY0ZVFw2ZU2mYfJbWvCTmtmne+PorG2mB aaGoAaxk8jTEz2zEEcuj0QN8Pn70YgQ= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716431523; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TsOdROg4EzhZ5yWrrkJb1xYFByIFJo+RGVMwVe5YdD0=; b=JcZruPE7sMWT0e3du9/o1FXM/Ly4cwOAE1bak5QCM6HWwLaxykvy7Qcm/esiguhEdbVyzB /0bWLwjCWym9lc2Q7sYWRC4GyZhLtJM2Wfwhkr67arOLEYHQbZxftfXrXwS6KcYNufKBMD XxzAmfS44ojH0OzbtWOPB5ji3z6hlDg= Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4VlBtv32yrz1ysLB; Thu, 23 May 2024 10:28:55 +0800 (CST) Received: from canpemm500002.china.huawei.com (unknown [7.192.104.244]) by mail.maildlp.com (Postfix) with ESMTPS id C27F21A016C; Thu, 23 May 2024 10:31:57 +0800 (CST) Received: from [10.173.135.154] (10.173.135.154) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 23 May 2024 10:31:57 +0800 Subject: Re: [PATCH v3 3/5] mm/memory-failure: improve memory failure action_result messages To: Jane Chu , , , , , References: <20240521235429.2368017-1-jane.chu@oracle.com> <20240521235429.2368017-4-jane.chu@oracle.com> From: Miaohe Lin Message-ID: Date: Thu, 23 May 2024 10:31:56 +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: <20240521235429.2368017-4-jane.chu@oracle.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.173.135.154] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500002.china.huawei.com (7.192.104.244) X-Rspamd-Queue-Id: 1F3F54001D X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: wt6o16qac41i973t5q3ni9k3inohpmfx X-HE-Tag: 1716431521-520286 X-HE-Meta: U2FsdGVkX19uP9AmFzN14rSqK2a0xKnNk3iUlf+bJgXtr/xPlCRrfJ3e6Jwb/hsGSIikfyWokYis+PsXdXyzYijsPIBjQpYeaZ5itrvvyRb/8g6ku+sojeR2ZrMDaFFnCxzTVhcf5mvuoU20AEX+c0HDoBGl+7sE/nB4u8Xp97RdcMifEWuhj2G4tjJk7v+/kFzVr9xvZeT8WSv0kSh6wWfd4fERCPAnSZJ8Sh/SPn7OjuBN8aEhnHVyKbbKVJVMFdfZpa1I4vogY9YkK0um6Js+6HYaVuGHEU0IyFc+zMCfkMM3T58LI7Tauf/S89Pgg8PVG4lEmbHOtUw/5oOwyAd85j3jhD9IRMeJMbB+OI+xljivCFlkdA5f3wCM57af+i7dgxEl3YXsUEcyGAn0qkh+Z/Thv0Posr3eayRmK14z9waDNUZhox8fQWLKRCtrdbY5WMXSbE5O7sX/asQ7eWZhB82N6AbEgKtw10Mxpd9Kx8P5huEMv1eNTRzLWXEboRErJr7DYSdoQYz9WZKz7UhvcNzgHu2pf94fhHX7Hqs+dlRK9AUd70vc2Yb3ogghIZA4YVYKhCqvMOvfEsOc5skXp3X2QDwXaM1gZGRsaH9l8+TDTdfHTobHVT+5DWGufaxAiAIXEzbx+MoKkT3jYo0xG+l8yYR58M5nOyi+Ae6Vhf4M1Gia+fp4smTgrKr+1h2azg2MMNDlmLBwfrC0QomOOtnx0NItj92F7/fJxepLHzs/YXr8DhooqfGGklxzzfqJY9fooedoVpYH8HThgKy3KwIqQH1HTXyMGVzN9a0LFKKS/8JrVAR7cYiJ3cp3vRK59ON5sAPhFgR/vyxec1gjkNEm4oAfTzD+ashDD5zY7bvKkHYkToMObr4UvGNgtEw6WfkHxNkW1njAMfZYVjR+2vS5y4tNDj0jCnxp/WvKhW8uVMb3SgH9KMQC0+FuI/cIP8sGGLxMRaDZgEV Th+/SC+/ HbB6LhonGvrTWe/M4cd1gAJmxXutArrszIjQTolzPseH30QgLrKbYhSWlEmmm2IsgTd6pS/u7g7B3OKmx2EFl5DggC0Gu9wSinbbM+wZWJkN0MJlWh4euH+gibAikyoFDCefm+W0r2IXfsWZVbie5/WjaWDUtwrf9WA72toFMBBOc14zu7obDiA+auw7iOa0Ri4hJhQFSM78o/b/i7q4rW5qSDGVw+OLl0AqgnyEAqgbGVtzpuRT/lm5gGZwkzURRD38u8bgEtXpQYte085AhHx3BS2rI2aiu/15C8lSm+QWRY6A= 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: List-Subscribe: List-Unsubscribe: On 2024/5/22 7:54, Jane Chu wrote: > Added two explicit MF_MSG messages describing failure in get_hwpoison_page. > Attemped to document the definition of various action names, and made a few > adjustment to the action_result() calls. > > Signed-off-by: Jane Chu Thanks for your patch. This really improves the code. > --- > include/linux/mm.h | 2 ++ > include/ras/ras_event.h | 2 ++ > mm/memory-failure.c | 38 +++++++++++++++++++++++++++++++++----- > 3 files changed, 37 insertions(+), 5 deletions(-) > > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 9849dfda44d4..b4598c6a393a 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -4111,6 +4111,7 @@ enum mf_action_page_type { > MF_MSG_DIFFERENT_COMPOUND, > MF_MSG_HUGE, > MF_MSG_FREE_HUGE, > + MF_MSG_GET_HWPOISON, > MF_MSG_UNMAP_FAILED, > MF_MSG_DIRTY_SWAPCACHE, > MF_MSG_CLEAN_SWAPCACHE, > @@ -4124,6 +4125,7 @@ enum mf_action_page_type { > MF_MSG_BUDDY, > MF_MSG_DAX, > MF_MSG_UNSPLIT_THP, > + MF_MSG_ALREADY_POISONED, > MF_MSG_UNKNOWN, > }; > > diff --git a/include/ras/ras_event.h b/include/ras/ras_event.h > index c011ea236e9b..b3f6832a94fe 100644 > --- a/include/ras/ras_event.h > +++ b/include/ras/ras_event.h > @@ -360,6 +360,7 @@ TRACE_EVENT(aer_event, > EM ( MF_MSG_DIFFERENT_COMPOUND, "different compound page after locking" ) \ > EM ( MF_MSG_HUGE, "huge page" ) \ > EM ( MF_MSG_FREE_HUGE, "free huge page" ) \ > + EM ( MF_MSG_GET_HWPOISON, "get hwpoison page" ) \ > EM ( MF_MSG_UNMAP_FAILED, "unmapping failed page" ) \ > EM ( MF_MSG_DIRTY_SWAPCACHE, "dirty swapcache page" ) \ > EM ( MF_MSG_CLEAN_SWAPCACHE, "clean swapcache page" ) \ > @@ -373,6 +374,7 @@ TRACE_EVENT(aer_event, > EM ( MF_MSG_BUDDY, "free buddy page" ) \ > EM ( MF_MSG_DAX, "dax page" ) \ > EM ( MF_MSG_UNSPLIT_THP, "unsplit thp" ) \ > + EM ( MF_MSG_ALREADY_POISONED, "already poisoned" ) \ > EMe ( MF_MSG_UNKNOWN, "unknown page" ) > > /* > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 739311e121af..1e22d73c9329 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -879,6 +879,28 @@ static int kill_accessing_process(struct task_struct *p, unsigned long pfn, > return ret > 0 ? -EHWPOISON : -EFAULT; > } > > +/* > + * MF_IGNORED - The m-f() handler marks the page as PG_hwpoisoned'ed. > + * But it could not do more to isolate the page from being accessed again, > + * nor does it kill the process. This is extremely rare and one of the > + * potential causes is that the page state has been changed due to > + * underlying race condition. This is the most severe outcomes. > + * > + * MF_FAILED - The m-f() handler marks the page as PG_hwpoisoned'ed. It > + * should have killed the process, but it can't isolate the page, due to > + * conditions such as extra pin, unmap failure, etc. Accessing the page > + * again will trigger another MCE and the process will be killed by the > + * m-f() handler immediately. > + * > + * MF_DELAYED - The m-f() handler marks the page as PG_hwpoisoned'ed. The > + * page is unmapped, but perhaps remains in LRU or file mapping. An attempt Would the page remain in LRU or file mapping? IIUC, MF_DELAYED is returned from two functions: 1. me_swapcache_dirty. Page lives in swap cache and removed from LRU. 2. kvm_gmem_error_folio. Page range is unmapped. It seems page won't be in the LRU or page cache. Or am I miss something? > + * to access the page again will trigger page fault and the PF handler > + * will kill the process. > + * > + * MF_RECOVERED - The m-f() handler marks the page as PG_hwpoisoned'ed. > + * The page has been completely isolated, that is, unmapped, taken out of > + * the buddy system, or hole-punnched out of the file mapping. > + */ > static const char *action_name[] = { > [MF_IGNORED] = "Ignored", > [MF_FAILED] = "Failed", > @@ -893,6 +915,7 @@ static const char * const action_page_types[] = { > [MF_MSG_DIFFERENT_COMPOUND] = "different compound page after locking", > [MF_MSG_HUGE] = "huge page", > [MF_MSG_FREE_HUGE] = "free huge page", > + [MF_MSG_GET_HWPOISON] = "get hwpoison page", > [MF_MSG_UNMAP_FAILED] = "unmapping failed page", > [MF_MSG_DIRTY_SWAPCACHE] = "dirty swapcache page", > [MF_MSG_CLEAN_SWAPCACHE] = "clean swapcache page", > @@ -906,6 +929,7 @@ static const char * const action_page_types[] = { > [MF_MSG_BUDDY] = "free buddy page", > [MF_MSG_DAX] = "dax page", > [MF_MSG_UNSPLIT_THP] = "unsplit thp", > + [MF_MSG_ALREADY_POISONED] = "already poisoned", > [MF_MSG_UNKNOWN] = "unknown page", > }; > > @@ -1013,12 +1037,13 @@ static int me_kernel(struct page_state *ps, struct page *p) > > /* > * Page in unknown state. Do nothing. > + * This is a catch-all in case we fail to make sense of the page state. > */ > static int me_unknown(struct page_state *ps, struct page *p) > { > pr_err("%#lx: Unknown page state\n", page_to_pfn(p)); > unlock_page(p); > - return MF_FAILED; > + return MF_IGNORED; > } > > /* > @@ -2055,6 +2080,8 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb > if (flags & MF_ACTION_REQUIRED) { > folio = page_folio(p); > res = kill_accessing_process(current, folio_pfn(folio), flags); > + action_result(pfn, MF_MSG_ALREADY_POISONED, MF_FAILED); > + return res; We might reuse the below "return res;"? > } > return res; Besides from the above possible nits, this patch looks good to me. Acked-by: Miaohe Lin Thanks. .