Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1979603ybc; Wed, 20 Nov 2019 07:07:24 -0800 (PST) X-Google-Smtp-Source: APXvYqw1HC+SF4AwZlb19KucU4+QGVzo15DwtD9bYZeZVQZ5wrZ2/4TZsXrdac+fJ5FNTeCVb3uK X-Received: by 2002:a17:906:4e53:: with SMTP id g19mr5981914ejw.286.1574262444062; Wed, 20 Nov 2019 07:07:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574262444; cv=none; d=google.com; s=arc-20160816; b=vFxtO+p7ny7dx68z+HQ2qBrVaRnW7CSYdXFCC9bVBX1Cp9/ip6+w4wiRww9gCWaG7c gM1amweGliz2RmpQWdJ2Jy00RXVSEImaRbgvoCXUWzEgZppxucG/kAHMPc7IAG8ipgWY 2dqrTXrgdK9x3q3zlqx8A6NjoQH6+73WYX7JuG/fMMdb3RDtTIO75QQ8aP0fxFSodxoA 1NUeSi82urmGTtsG1L4ufPlQSUbC7m8n7BcI7Au6ubdRMGu2eoTGBFWa3kOtkf4/B1Hm DwlH+IHOkvCC3CiBJy0EJvlAwTgifUavQfxWs5keM3ejUjlQUN5P2zGbQwtx+iumiECO nCjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature; bh=IBz9KyuYNKXB4FibFKzT3JjYfAQ+VtzUD0zVZBCTZ40=; b=LeH89pOzBJVm4v8qtUHw117HdWTy12gglvmq9nhz6t/6sF7VE/GNGcmM/v8AyTu3Cs 95x2GjOpGds3itDohc1PTA1tA2ROcNfAL3C0eJfuia2FGaV9msPUSoXZ+S4JKbdRhinW gPmXIH3adB/NMqsOu5aBXvYft/GKhgx5QZKlEWhbUj0aVmcI9OGnyV+YMUu7esc3I5V9 CVguBL3FODkR05dgS3cUandT/NUYI7b584SS1SARTpZj2yJD2eqmc4SmcAGddxO6nM7+ O/2ceDsDpyFkK9z/G9vNA80QFrOXpnNVesfWwjynuwyYfIuq8DQ7luRpNRUO9mFWKy9i BcxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JsT18B4k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o19si15824733ejj.307.2019.11.20.07.07.00; Wed, 20 Nov 2019 07:07:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JsT18B4k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729138AbfKTPEw (ORCPT + 99 others); Wed, 20 Nov 2019 10:04:52 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:22755 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728864AbfKTPEw (ORCPT ); Wed, 20 Nov 2019 10:04:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574262291; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IBz9KyuYNKXB4FibFKzT3JjYfAQ+VtzUD0zVZBCTZ40=; b=JsT18B4kMlTqN4rnBbFt2iHtjsVXJMA5gk08ZZ30Y+BWQFcmg7x0JSISaSEYnC6fEBukTc udIpa7du8NwEe/2HT6aAFQeFBMCX8W7h5RXG5CAg7oJzA88995+C+eT9kbvZY0PrMCCZ+P TBkMnMshJdd7Q5XPL7Gm5NN147TH78c= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-383-lytrAqQxMHW7Fx7hfEbx3g-1; Wed, 20 Nov 2019 10:04:48 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8DB586EE19; Wed, 20 Nov 2019 15:04:46 +0000 (UTC) Received: from [10.36.118.126] (unknown [10.36.118.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 224E85ED2D; Wed, 20 Nov 2019 15:04:44 +0000 (UTC) Subject: Re: [PATCH 1/2] mm/memory-failure.c: PageHuge is handled at the beginning of memory_failure To: Wei Yang Cc: n-horiguchi@ah.jp.nec.com, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, James Morse , Naoya Horiguchi References: <20191118082003.26240-1-richardw.yang@linux.intel.com> <1e61c115-5787-9ef4-a449-2e490c53fca7@redhat.com> <20191120004620.GB11061@richard> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: Date: Wed, 20 Nov 2019 16:04:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <20191120004620.GB11061@richard> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: lytrAqQxMHW7Fx7hfEbx3g-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20.11.19 01:46, Wei Yang wrote: > On Tue, Nov 19, 2019 at 01:23:54PM +0100, David Hildenbrand wrote: >> On 18.11.19 09:20, Wei Yang wrote: >>> PageHuge is handled by memory_failure_hugetlb(), so this case could be >>> removed. >>> >>> Signed-off-by: Wei Yang >>> --- >>> mm/memory-failure.c | 5 +---- >>> 1 file changed, 1 insertion(+), 4 deletions(-) >>> >>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c >>> index 3151c87dff73..392ac277b17d 100644 >>> --- a/mm/memory-failure.c >>> +++ b/mm/memory-failure.c >>> @@ -1359,10 +1359,7 @@ int memory_failure(unsigned long pfn, int flags) >>> =09 * page_remove_rmap() in try_to_unmap_one(). So to determine page= status >>> =09 * correctly, we save a copy of the page flags at this time. >>> =09 */ >>> -=09if (PageHuge(p)) >>> -=09=09page_flags =3D hpage->flags; >>> -=09else >>> -=09=09page_flags =3D p->flags; >>> +=09page_flags =3D p->flags; >>> =09/* >>> =09 * unpoison always clear PG_hwpoison inside page lock >>> >> >> I somewhat miss a proper explanation why this is safe to do. We access p= age >> flags here, so why is it safe to refer to the ones of the sub-page? >> >=20 > Hi, David >=20 > I think your comment is on this line: >=20 > =09page_flags =3D p->flags; >=20 > Maybe we need to use this: >=20 > =09page_flags =3D hpage->flags; >=20 > And use hpage in the following or even the whole function? >=20 > While one thing interesting is not all "compound page" is PageCompound. F= or > some sub-page, we can't get the correct head. This means we may just chec= k on > the sub-page. Oh wait, I think I missed the check right at the beginning of this=20 function, sorry :/ Sooo, memory_failure_hugetlb() was introduced by commit 761ad8d7c7b5485bb66fd5bccb58a891fe784544 Author: Naoya Horiguchi Date: Mon Jul 10 15:47:47 2017 -0700 mm: hwpoison: introduce memory_failure_hugetlb() and essentially ripped out all PageHuge() checks *except* this check.=20 This check was introduced in commit 7258ae5c5a2ce2f5969e8b18b881be40ab55433d Author: James Morse Date: Fri Jun 16 14:02:29 2017 -0700 mm/memory-failure.c: use compound_head() flags for huge pages Maybe that was just a merge oddity as both commits are only ~1month=20 apart. IOW, I think Naoya's patch forgot to rip it out. Can we make this clear in the patch description like "This is dead code=20 that cannot be reached after commit 761ad8d7c7b5 ("mm: hwpoison:=20 introduce memory_failure_hugetlb()")" I assume Andrew can fix up when applying Reviewed-by: David Hildenbrand --=20 Thanks, David / dhildenb