Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2570549pxb; Tue, 21 Sep 2021 02:52:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCf6/T/5dykRHVXyxLFr8rI5QKV6odkjnDP8bs2mGAYG4v9xzBSfbn6AqSmsBVTMQZtRo1 X-Received: by 2002:a02:19c8:: with SMTP id b191mr736771jab.10.1632217929796; Tue, 21 Sep 2021 02:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632217929; cv=none; d=google.com; s=arc-20160816; b=HG0A0jdtr1BzokLjjj2ncfdJ2ejNr8RyW4J0vV+nwV4yA5sh5De1BQLUz9BcUl79AY IpR5rjsZFhfeI4H9qvJUntk9H8veutTNURHgznZJTWNUOD5+qdcnhvo3Er4eNi2gkDX8 MUCZUTVTMF/X92DY7SiqGj5NGdhy/7/LAi9m2JZgZl5lhKXaxziIvcjM8s2LsoY8yi5m i/Sj83B5Km9Gsf9RCvIk2djR+Wg0oqaP5es29OcjVC7fTsk4zApaXs1tW5hB7iMXr+5/ NGZ64LlT1d4oeQ8ld6rF8Tr9f5mDxnGY0uLO9+otdysX/pwd80B4FRIKT4LuU899ms/y a++A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=gPRQDB+cf55TSto6+2IaK/1yaAZ8EqxZw27am8rgyfE=; b=WfPrqjBpcfv3JQUtpyE/9r4i4u7K/Q1rbvLwOxBrgM35Qs4vCbd50EqL9AhNX5zQuf nl4qxcf3F+iegrz2Uaf+dkJv99ku8HnM9pvOBopCqL7URedPYi337nRxk2NNj5ie84X0 tugKBaYeOeiPTLPTD1OWxaseGVh/eii3sjtwm5xakdvkayP2EaxaOKnZVGUSEwS7d9rY LYcJ02XcoE6ETLva5PeZ33MvHHvttjlC6RlNn6byEPofKC1yeTeNT2zbpq8dpJOizFjL P/p4g5vcvrn31/ohlPm0SBWd1nRpvoe66XE9oBIFRSdWwNjGcf9ep4XtXtGq9lJ2Hk7f XGNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=QwK2TqI8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a1si11096115jaa.131.2021.09.21.02.51.58; Tue, 21 Sep 2021 02:52:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=QwK2TqI8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231484AbhIUJwO (ORCPT + 99 others); Tue, 21 Sep 2021 05:52:14 -0400 Received: from out0.migadu.com ([94.23.1.103]:57839 "EHLO out0.migadu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231446AbhIUJwM (ORCPT ); Tue, 21 Sep 2021 05:52:12 -0400 Date: Tue, 21 Sep 2021 18:50:34 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1632217840; 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=gPRQDB+cf55TSto6+2IaK/1yaAZ8EqxZw27am8rgyfE=; b=QwK2TqI8SGnkU2Q64iH5TYfsIO7EcLgz41GXymySEHouHrYP7FGITUs7008YIDBYf/qcvO WtlmUoN9aZYv5mYRQQ/bDmxF5ttB6BPISY5HJAU8S8eo3ou83lqcGgCg4/jqNnxuUcqGRK bt+lEGsp2xhybzhWNyNvvRtRwnnzbpE= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Naoya Horiguchi To: Yang Shi Cc: naoya.horiguchi@nec.com, hughd@google.com, kirill.shutemov@linux.intel.com, willy@infradead.org, osalvador@suse.de, akpm@linux-foundation.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/4] mm: hwpoison: handle non-anonymous THP correctly Message-ID: <20210921095034.GB817765@u2004> References: <20210914183718.4236-1-shy828301@gmail.com> <20210914183718.4236-5-shy828301@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210914183718.4236-5-shy828301@gmail.com> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: naoya.horiguchi@linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 14, 2021 at 11:37:18AM -0700, Yang Shi wrote: > Currently hwpoison doesn't handle non-anonymous THP, but since v4.8 THP > support for tmpfs and read-only file cache has been added. They could > be offlined by split THP, just like anonymous THP. > > Signed-off-by: Yang Shi > --- > mm/memory-failure.c | 21 ++++++++++++--------- > 1 file changed, 12 insertions(+), 9 deletions(-) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 3e06cb9d5121..6f72aab8ec4a 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -1150,13 +1150,16 @@ static int __get_hwpoison_page(struct page *page) > > if (PageTransHuge(head)) { > /* > - * Non anonymous thp exists only in allocation/free time. We > - * can't handle such a case correctly, so let's give it up. > - * This should be better than triggering BUG_ON when kernel > - * tries to touch the "partially handled" page. > + * We can't handle allocating or freeing THPs, so let's give > + * it up. This should be better than triggering BUG_ON when > + * kernel tries to touch the "partially handled" page. > + * > + * page->mapping won't be initialized until the page is added > + * to rmap or page cache. Use this as an indicator for if > + * this is an instantiated page. > */ > - if (!PageAnon(head)) { > - pr_err("Memory failure: %#lx: non anonymous thp\n", > + if (!head->mapping) { > + pr_err("Memory failure: %#lx: non instantiated thp\n", > page_to_pfn(page)); > return 0; > } How about cleaning up this whole "PageTransHuge()" block? As explained in commit 415c64c1453a (mm/memory-failure: split thp earlier in memory error handling), this check was introduced to avoid that non-anonymous thp is considered as hugetlb and code for hugetlb is executed (resulting in crash). With recent improvement in __get_hwpoison_page(), this confusion never happens (because hugetlb check is done before this check), so this check seems to finish its role. Thanks, Naoya Horiguchi > @@ -1415,12 +1418,12 @@ static int identify_page_state(unsigned long pfn, struct page *p, > static int try_to_split_thp_page(struct page *page, const char *msg) > { > lock_page(page); > - if (!PageAnon(page) || unlikely(split_huge_page(page))) { > + if (!page->mapping || unlikely(split_huge_page(page))) { > unsigned long pfn = page_to_pfn(page); > > unlock_page(page); > - if (!PageAnon(page)) > - pr_info("%s: %#lx: non anonymous thp\n", msg, pfn); > + if (!page->mapping) > + pr_info("%s: %#lx: not instantiated thp\n", msg, pfn); > else > pr_info("%s: %#lx: thp split failed\n", msg, pfn); > put_page(page); > -- > 2.26.2 >