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 D4556C19F2A for ; Thu, 4 Aug 2022 13:29:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9B4C6B0071; Thu, 4 Aug 2022 09:29:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E4B136B0072; Thu, 4 Aug 2022 09:29:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D12B98E0001; Thu, 4 Aug 2022 09:29:02 -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 C2E846B0071 for ; Thu, 4 Aug 2022 09:29:02 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9A383C117B for ; Thu, 4 Aug 2022 13:29:02 +0000 (UTC) X-FDA: 79761990924.01.93BB281 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf07.hostedemail.com (Postfix) with ESMTP id 180174011D for ; Thu, 4 Aug 2022 13:29:01 +0000 (UTC) Date: Thu, 4 Aug 2022 22:28:53 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1659619739; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xjwOLlJa1sx9Z5qqE71h/yHwNx7CZZOcwExLPX1L2fw=; b=XatL7kTfZcJaQM0vZ/NPE4IJSBkw0hZAAfLgphyqowgRySLJ5FUpD+MLs4WPRu5VNNUJve Pxqb+zyAHMkbV7aNI/qiZdB7OTQMcKwyljv4P2fV+j5yL6uS4Ks7/9f/vD4V12QQvsvrZu +UFSrTMOkLtoWjFcXEM8nQQ97NO7BOQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Naoya Horiguchi To: luofei Cc: akpm@linux-foundation.org, linmiaohe@huawei.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Naoya Horiguchi Subject: Re: [PATCH v1] mm, hwpoison, hugetlb: Check hugetlb head page hwpoison flag when unpoison page Message-ID: <20220804131639.GA39205@hori.linux.bs1.fc.nec.co.jp> References: <20220804122819.2917249-1-luofei@unicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220804122819.2917249-1-luofei@unicloud.com> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659619742; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xjwOLlJa1sx9Z5qqE71h/yHwNx7CZZOcwExLPX1L2fw=; b=5s6JH5QOSFQKiG2A3LUqFMbkFNvnzXc3hdOTiQbVng3wTA8xzklNyU54O9MSLKoSeJptHw qlxagdGO4suEYqHf72EpLf+s4b7NFv/wBqmcyqwWx96mi9lSqe4Z3L0LoafoWUCKwZUr32 3mzf6jDLmaDQxFNIDyPF8noQCKih5uc= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=XatL7kTf; spf=pass (imf07.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659619742; a=rsa-sha256; cv=none; b=joTFvx9ORNzKl1mg4HWATA7jQQeoBnW0eSuBX9P1IUqFMBv01n8yMiqFEdgZb4BFt38wsc fso3gBxqQXt85zgAxa5go7hHgcLBXQ+7q3jVUvZ3YbBUOJ01ypcd0STqyYsAw0IBabGKzU oGAhwGc+KJkva+3fMWNl1kf2af2Cc3k= X-Stat-Signature: kcyhikwkaak483hgsbhmqyh4qgrhc6e9 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 180174011D Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=XatL7kTf; spf=pass (imf07.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-HE-Tag: 1659619741-570846 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: On Thu, Aug 04, 2022 at 08:28:19AM -0400, luofei wrote: > When software-poison a huge page, if dissolve_free_huge_page() failed, > the huge page will be added to hugepage_freelists. In this case, the > head page will hold the hwpoison flag, but the real poisoned tail page > hwpoison flag is not set, this will cause unpoison_memory() fail to > unpoison the previously poisoned page. Hi luofei, When you try to unpoison a hwpoisoned hugepage, you just have to pass the pfn of the head page, not the pfn of raw poisoned subpage. Note that the position of raw error page is not exposed to userspace (dmesg shows it, but saving and parsing it for unpoison is not that useful) and the related utilities like page-types only checks PageHWpoison flag to find error pages, so it seems to me that you're introducing an inconsistent assumption. Thanks, Naoya Horiguchi > > So add a check on hugetlb head page, and also need to ensure the > previously poisoned tail page in huge page raw_hwp_list. > > Signed-off-by: luofei > --- > mm/memory-failure.c | 24 +++++++++++++++++++++++- > 1 file changed, 23 insertions(+), 1 deletion(-) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 14439806b5ef..92dbeaa24afb 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -2293,6 +2293,28 @@ core_initcall(memory_failure_init); > pr_info(fmt, pfn); \ > }) > > +static bool hugetlb_page_head_poison(struct page *hpage, struct page *page) > +{ > + struct llist_head *head; > + struct llist_node *t, *tnode; > + struct raw_hwp_page *p; > + > + if (!PageHuge(page) || !PageHWPoison(hpage) || !HPageFreed(hpage)) > + return false; > + > + if (HPageRawHwpUnreliable(hpage)) > + return false; > + > + head = raw_hwp_list_head(hpage); > + llist_for_each_safe(tnode, t, head->first) { > + p = container_of(tnode, struct raw_hwp_page, node); > + if (p->page == page) > + return true; > + } > + > + return false; > +} > + > /** > * unpoison_memory - Unpoison a previously poisoned page > * @pfn: Page number of the to be unpoisoned page > @@ -2330,7 +2352,7 @@ int unpoison_memory(unsigned long pfn) > goto unlock_mutex; > } > > - if (!PageHWPoison(p)) { > + if (!PageHWPoison(p) && !hugetlb_page_head_poison(page, p)) { > unpoison_pr_info("Unpoison: Page was already unpoisoned %#lx\n", > pfn, &unpoison_rs); > goto unlock_mutex; > -- > 2.27.0