From patchwork Wed Apr 27 04:28:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12828280 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 E44BAC433EF for ; Wed, 27 Apr 2022 04:29:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7EDF16B007D; Wed, 27 Apr 2022 00:29:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 79D776B007E; Wed, 27 Apr 2022 00:29:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 666336B0080; Wed, 27 Apr 2022 00:29:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 56B006B007D for ; Wed, 27 Apr 2022 00:29:11 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 32E6761A05 for ; Wed, 27 Apr 2022 04:29:11 +0000 (UTC) X-FDA: 79401379302.14.9AE907A Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf03.hostedemail.com (Postfix) with ESMTP id 2131C20032 for ; Wed, 27 Apr 2022 04:29:06 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1651033749; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eItuMRrHX4Os0FsD9ZvtHrWEjjS1bDgCgiQWK4LzGH8=; b=Q/L/bZLR2KByUYsk0eKAUGr4PH3NUZja3XUO0pphORYpe2Rj7I0j0E8fs/cZgyDX/WahYp 09fcfU+W8FupvA87f9W0dG+wtisEPzXqeStjOqyflUdvzWcdv0AuLrYisdZAoSasUl0Jor l4AoypbWmeThkIg4PlM2aCefocljWNw= From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Miaohe Lin , David Hildenbrand , Mike Kravetz , Yang Shi , Oscar Salvador , Muchun Song , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [RFC PATCH v1 4/4] mm, memory_hotplug: fix inconsistent num_poisoned_pages on memory hotremove Date: Wed, 27 Apr 2022 13:28:41 +0900 Message-Id: <20220427042841.678351-5-naoya.horiguchi@linux.dev> In-Reply-To: <20220427042841.678351-1-naoya.horiguchi@linux.dev> References: <20220427042841.678351-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Stat-Signature: h5dw8mgc537c9qzhyssiegkoty6omgxt Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="Q/L/bZLR"; spf=pass (imf03.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-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 2131C20032 X-HE-Tag: 1651033746-534842 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: 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. 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); }