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 10D33C433EF for ; Mon, 14 Feb 2022 14:50:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C7B36B0071; Mon, 14 Feb 2022 09:50:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 975876B0073; Mon, 14 Feb 2022 09:50:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 83DE26B0078; Mon, 14 Feb 2022 09:50:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0189.hostedemail.com [216.40.44.189]) by kanga.kvack.org (Postfix) with ESMTP id 7406D6B0071 for ; Mon, 14 Feb 2022 09:50:26 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 338C39D282 for ; Mon, 14 Feb 2022 14:50:26 +0000 (UTC) X-FDA: 79141671252.12.49CB434 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf23.hostedemail.com (Postfix) with ESMTP id 9DC83140011 for ; Mon, 14 Feb 2022 14:50:25 +0000 (UTC) Date: Mon, 14 Feb 2022 23:50:19 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1644850224; 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=a6uiMGBxoN7l/Xu87OWN9A7aEPeNg8ZMf78cUU3cM7s=; b=gLdV7l4kjK36aWTwPyKcNIfYbY3uFHSKKhhoZBPFv9Mklj6FF76jReocMd79rjSgRevGQV Fm0Ps34bkaWTiH3AZ1QVRU7uWrgW9SCfcZ+YeCWECa8iOZpgzXonUi1dCatL4utw2Wo7Wk QgyE9QXzJNUdVNWw1IINYGJDZZuLiy8= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Naoya Horiguchi To: Miaohe Lin Cc: akpm@linux-foundation.org, naoya.horiguchi@nec.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/8] mm/memory-failure.c: remove unneeded orig_head Message-ID: <20220214145019.GD2624914@u2004> References: <20220210141733.1908-1-linmiaohe@huawei.com> <20220210141733.1908-5-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220210141733.1908-5-linmiaohe@huawei.com> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=gLdV7l4k; spf=pass (imf23.hostedemail.com: domain of naoya.horiguchi@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=naoya.horiguchi@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Rspamd-Server: rspam07 X-Rspam-User: X-Rspamd-Queue-Id: 9DC83140011 X-Stat-Signature: 4x5k658ykugdwwmtqk1pz1cegkr83b7o X-HE-Tag: 1644850225-3712 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, Feb 10, 2022 at 10:17:29PM +0800, Miaohe Lin wrote: > orig_head is used to check whether the page have changed compound pages > during the locking. But it's always equal to hpage. So we can use hpage > directly and remove this redundant one. > > Signed-off-by: Miaohe Lin > --- > 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 2dd7f35ee65a..4370c2f407c5 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -1691,7 +1691,6 @@ int memory_failure(unsigned long pfn, int flags) > { > struct page *p; > struct page *hpage; > - struct page *orig_head; > struct dev_pagemap *pgmap; > int res = 0; > unsigned long page_flags; > @@ -1737,7 +1736,7 @@ int memory_failure(unsigned long pfn, int flags) > goto unlock_mutex; > } > > - orig_head = hpage = compound_head(p); > + hpage = compound_head(p); > num_poisoned_pages_inc(); > > /* > @@ -1821,7 +1820,7 @@ int memory_failure(unsigned long pfn, int flags) > * The page could have changed compound pages during the locking. > * If this happens just bail out. > */ > - if (PageCompound(p) && compound_head(p) != orig_head) { > + if (PageCompound(p) && compound_head(p) != hpage) { I think that this if-check was intended to detect the case that page p belongs to a thp when memory_failure() is called and belongs to a compound page in different size (like slab or some driver page) after the thp is split. But your suggestion makes me aware that the page p could be embedded on a thp again after thp split. I think this might be rare, but if it happens the current if-check (or suggested one) cannot detect it. So I feel that simply dropping compound_head() check might be better? - if (PageCompound(p) && compound_head(p) != orig_head) { + if (PageCompound(p)) { This should ensure the assumption (mentioned in 8/8 patch) more that the error page never belongs to compound page after taking page lock. Thanks, Naoya Horiguchi