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 2A253C433F5 for ; Thu, 28 Apr 2022 03:20:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62A426B0071; Wed, 27 Apr 2022 23:20:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B2A26B0072; Wed, 27 Apr 2022 23:20:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A1356B0073; Wed, 27 Apr 2022 23:20:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 385616B0071 for ; Wed, 27 Apr 2022 23:20:22 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1178421831 for ; Thu, 28 Apr 2022 03:20:22 +0000 (UTC) X-FDA: 79404834684.08.FD9D82D Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf17.hostedemail.com (Postfix) with ESMTP id 1DF0340051 for ; Thu, 28 Apr 2022 03:20:12 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Kpgp31BNxz1JBj2; Thu, 28 Apr 2022 11:19:23 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 28 Apr 2022 11:20:17 +0800 Subject: Re: [RFC PATCH v1 4/4] mm, memory_hotplug: fix inconsistent num_poisoned_pages on memory hotremove To: Naoya Horiguchi CC: Andrew Morton , David Hildenbrand , Mike Kravetz , Yang Shi , Oscar Salvador , Muchun Song , Naoya Horiguchi , , Linux-MM References: <20220427042841.678351-1-naoya.horiguchi@linux.dev> <20220427042841.678351-5-naoya.horiguchi@linux.dev> From: Miaohe Lin Message-ID: <828cc111-40e8-88ed-bb50-fb185e5f0304@huawei.com> Date: Thu, 28 Apr 2022 11:20:16 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20220427042841.678351-5-naoya.horiguchi@linux.dev> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Stat-Signature: ez7wt89ne9k6sz179wbum64e49wqeqrs X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1DF0340051 X-Rspam-User: Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-HE-Tag: 1651116012-113090 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 2022/4/27 12:28, Naoya Horiguchi wrote: > From: Naoya Horiguchi > > When offlining memory section with hwpoisoned pages, the hwpoisons are > canceled. But num_poisoned_pages is not updated for that event, so the > counter becomes inconsistent. IIUC, this work is already done via clear_hwpoisoned_pages when __remove_pages. Or am I miss something? Thanks! > > Add num_poisoned_pages_dec() in __offline_isolated_pages(). PageHWPoison > can be set on a tail page of some high order buddy page, so we need check > PageHWPoison on each subpage. > > Signed-off-by: Naoya Horiguchi > --- > mm/page_alloc.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 6e5b4488a0c5..dcd962855617 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -9487,12 +9487,15 @@ void __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn) > zone = page_zone(pfn_to_page(pfn)); > spin_lock_irqsave(&zone->lock, flags); > while (pfn < end_pfn) { > + int i; > + > page = pfn_to_page(pfn); > /* > * The HWPoisoned page may be not in buddy system, and > * page_count() is not 0. > */ > if (unlikely(!PageBuddy(page) && PageHWPoison(page))) { > + num_poisoned_pages_dec(); > pfn++; > continue; > } > @@ -9510,6 +9513,9 @@ void __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn) > BUG_ON(page_count(page)); > BUG_ON(!PageBuddy(page)); > order = buddy_order(page); > + for (i = 0; i < 1 << order; i++) > + if (PageHWPoison(page + i)) > + num_poisoned_pages_dec(); > del_page_from_free_list(page, zone, order); > pfn += (1 << order); > } >