Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp621651pxb; Tue, 1 Feb 2022 07:09:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJxAM0WTSpfRnGHsKK03wXSTMdBx0V7lEADX6sZbn0i+mmwFiow0h2kAqmmjsUytbWM+FW2Q X-Received: by 2002:a17:907:7b9c:: with SMTP id ne28mr21576361ejc.536.1643728198383; Tue, 01 Feb 2022 07:09:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643728198; cv=none; d=google.com; s=arc-20160816; b=oRVOlFVU0RjyzsTIkrVD5xum6uQLm/fW/IRSNdYv+xkjojuYk1zPlsxGgXa2Lk3XDH PwT6rJ1/vBo8Uqw46fQWdXmtb2PMRVIJFKcdVOW24xbC9z2OW3hU9vZJIqa+/3DD3HQt idndjXLDVU7bZCCtK6ksh9ks33vBmgLtequKpmyJJkTcicniFj0AniI9NIrsgS5cN/I2 Dukufo04Ww2whF46S8eqL5Qg5pSGww18rV5668g8O0vtohG1rBc0JqjPf3zxaqJ+d4Ou sO4o0LntQaRTYes924eAiaWEs0Zd24agYYcyzMKBSNKv6z4KmB33GsqC+UnRy7E9IXjF J1VQ== 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:date:dkim-signature; bh=Y6C64rp3OckgZemaQ6wbEiWdl97OAVw+WvBx+s5/qQU=; b=hEADdI7VnMLoxITHrZItY0MmeYON2sdZ8QkXKV9ADU40qBwx+7Rf8s5g+gQAY4IYvz jTUGVo9SMP3k3GHUMazDhG2y63tUNM68DoU1cB4HwI5/CXGkaWRiAm/bQl0Zoksma382 WiMjJ39v+S26UKRZ7+L7+IzD3NZCtfDrt2pn7eoE3QE7KHPKBJ90+jiH8C9gOvymtWIw SUD/LlCitNT5FVwJyTqPabWuzaSuGm0gYeRUqGJC/C97qvLkzsOQIjq/88kLmDp3jUhc nrMjJP6mIdr/J0nB6DxteU58AZwnSEZe8GVZL6geRkekT2qLRqCbhdXSo+cr80kexa12 6Kew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Oa490mYU; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y11si10465403eda.480.2022.02.01.07.09.32; Tue, 01 Feb 2022 07:09:58 -0800 (PST) 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=@infradead.org header.s=casper.20170209 header.b=Oa490mYU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356421AbiA3VOb (ORCPT + 99 others); Sun, 30 Jan 2022 16:14:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232933AbiA3VO2 (ORCPT ); Sun, 30 Jan 2022 16:14:28 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E937C061714 for ; Sun, 30 Jan 2022 13:14:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Y6C64rp3OckgZemaQ6wbEiWdl97OAVw+WvBx+s5/qQU=; b=Oa490mYU6J3F82zaqC7vMK1vrL c4uVvh0LgiZWlQ5mahycnGEzdTUilgtm0Zw9UYzrGiinrmqeOu5JGRr7eopzZiEixCt++LEDO+geZ EIOlVaPFaEq8InEDBJQMwKbLJINaRB7M3/2MKZsZacijgO6r6SgREtYP4fFj8SOuwCI6CsljdpT9V UtnnUQ/aHKwVk7tqUl+VJpPmk4JPPkGLfWFjypNghBfo4+KYUGIiomGkuFx5uvNKhfYGHPl5GUtAc u64IN0IEOb6WdIeZ4Uu3Nelh5zMnXa0KecGDlLXve9csBHKaNIs6V13s9WFTlnBBATbN1nTZ6LBsI wsbPkgQA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nEHWf-008nwA-Lc; Sun, 30 Jan 2022 21:14:21 +0000 Date: Sun, 30 Jan 2022 21:14:21 +0000 From: Matthew Wilcox To: David Rientjes Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Naoya Horiguchi Subject: Re: [PATCH] mm/hwpoison: Check the subpage, not the head page Message-ID: References: <20220130013042.1906881-1-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 30, 2022 at 12:58:17PM -0800, David Rientjes wrote: > On Sun, 30 Jan 2022, Matthew Wilcox (Oracle) wrote: > > > Hardware poison is tracked on a per-page basis, not on the head page. > > > > Signed-off-by: Matthew Wilcox (Oracle) > > --- > > mm/rmap.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/mm/rmap.c b/mm/rmap.c > > index 6a1e8c7f6213..09b08888120e 100644 > > --- a/mm/rmap.c > > +++ b/mm/rmap.c > > @@ -1553,7 +1553,7 @@ static bool try_to_unmap_one(struct page *page, struct vm_area_struct *vma, > > /* Update high watermark before we lower rss */ > > update_hiwater_rss(mm); > > > > - if (PageHWPoison(page) && !(flags & TTU_IGNORE_HWPOISON)) { > > + if (PageHWPoison(subpage) && !(flags & TTU_IGNORE_HWPOISON)) { > > pteval = swp_entry_to_pte(make_hwpoison_entry(subpage)); > > if (PageHuge(page)) { > > hugetlb_count_sub(compound_nr(page), mm); > > @@ -1873,7 +1873,7 @@ static bool try_to_migrate_one(struct page *page, struct vm_area_struct *vma, > > * memory are supported. > > */ > > subpage = page; > > - } else if (PageHWPoison(page)) { > > + } else if (PageHWPoison(subpage)) { > > pteval = swp_entry_to_pte(make_hwpoison_entry(subpage)); > > if (PageHuge(page)) { > > hugetlb_count_sub(compound_nr(page), mm); > > This looks correct. Correct me if I'm wrong that this is for consistency > and cleanup and that there is no bug being fixed by this, however. Oh, no, I think there's a real bug here. It's just that we're looking at an uncommon & hence rarely-tested scenario -- a memory fault in the middle of a THP (in mainline; obviously it'll be a little more common with arbitrary sized folios). I don't do HWPoison testing myself, so this was by inspection and not from testing. A scenario where things would go wrong is a memory error on a non-head-page would go unnoticed when migrating or unmapping. Contrariwise, if there's a hardware error on a head page, all the subpages get treated as poisoned, even though they shouldn't be.