From patchwork Mon Sep 5 06:21:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naoya Horiguchi X-Patchwork-Id: 12965475 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 446A9ECAAA1 for ; Mon, 5 Sep 2022 06:22:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF828801AB; Mon, 5 Sep 2022 02:22:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA81B8D0050; Mon, 5 Sep 2022 02:22:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B7058801AB; Mon, 5 Sep 2022 02:22:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A815E8D0050 for ; Mon, 5 Sep 2022 02:22:13 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id CE78412186B for ; Mon, 5 Sep 2022 06:22:12 +0000 (UTC) X-FDA: 79877036904.06.AAEE11F Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf14.hostedemail.com (Postfix) with ESMTP id 6D346100055 for ; Mon, 5 Sep 2022 06:22:12 +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=1662358931; 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=ucAIXNnH5R2gOfgMvHbR1y7ug9n/ezUmfveCIJw4IxY=; b=ASM6HcWZzDLxIDXs3ez6SRtQhvGY3pPYeVjp5UhQSb4qv3mL+xT5hh7Qb0N6USjo4XDIWS JIO6ZYdRQqpOMgdLzA+JiCmflMW8UrAFrA3yqYD3NyoawZpIBB1E6LRtznziKUchM2IOm4 6GyjKk9KlgbmHYdoU+2LrbRLBKQ9gpY= From: Naoya Horiguchi To: linux-mm@kvack.org Cc: Andrew Morton , Miaohe Lin , David Hildenbrand , Mike Kravetz , Yang Shi , Oscar Salvador , Muchun Song , Jane Chu , Naoya Horiguchi , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/4] mm,hwpoison,hugetlb,memory_hotplug: hotremove memory section with hwpoisoned hugepage Date: Mon, 5 Sep 2022 15:21:34 +0900 Message-Id: <20220905062137.1455537-2-naoya.horiguchi@linux.dev> In-Reply-To: <20220905062137.1455537-1-naoya.horiguchi@linux.dev> References: <20220905062137.1455537-1-naoya.horiguchi@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662358932; a=rsa-sha256; cv=none; b=Mo1PhKA1ux8s3FNyftiQeEDJXfbZUl0yG6wQiHUwjHKoi88DOSuXLEXjP1sYDQ+jS8zjGJ DFdlmk5zmGcc6s8zLOZ+XcSZm3lI0a2lq9hxOUC8v2flm8+3JQ57i85GtcAu70P//kxJYu 4gQ7kvG9cPX7GhlounHvFabklQPqPpM= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=ASM6HcWZ; spf=pass (imf14.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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662358932; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ucAIXNnH5R2gOfgMvHbR1y7ug9n/ezUmfveCIJw4IxY=; b=UrYzDMteNe5jzwMl5RM1Wg4hYgbOpG3lneVvF6EmGdaAY9icvNNg6Ov7uw2fzWCvAgjsJH FLNf2rFIv72UbyNaUsnZOIIOH0BwMZvQ3cNqcro4IhWV2FuwKyGT0TlEKtdcDL1hOmkuj9 L8aReERg+hNwWrtIGrkMt7EX8lK/0I4= Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=ASM6HcWZ; spf=pass (imf14.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: rspam12 X-Stat-Signature: h54qn5zijmspwb95cpjikgcsrtfwihtu X-Rspamd-Queue-Id: 6D346100055 X-HE-Tag: 1662358932-879555 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 HWPoisoned page is not supposed to be accessed once marked, but currently such accesses can happen during memory hotremove because do_migrate_range() can be called before dissolve_free_huge_pages() is called. Move dissolve_free_huge_pages() before scan_movable_pages(). Recently delayed dissolve has been implemented, so the dissolving can turn a hwpoisoned hugepage into 4kB hwpoison page, which memory hotplug can handle safely. Reported-by: Miaohe Lin Signed-off-by: Naoya Horiguchi --- mm/memory_hotplug.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index fad6d1f2262a..c24735d63b25 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1880,6 +1880,17 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages, cond_resched(); + /* + * Dissolve free hugepages in the memory block before doing + * offlining actually in order to make hugetlbfs's object + * counting consistent. + */ + ret = dissolve_free_huge_pages(start_pfn, end_pfn); + if (ret) { + reason = "failure to dissolve huge pages"; + goto failed_removal_isolated; + } + ret = scan_movable_pages(pfn, end_pfn, &pfn); if (!ret) { /* @@ -1895,17 +1906,6 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages, goto failed_removal_isolated; } - /* - * Dissolve free hugepages in the memory block before doing - * offlining actually in order to make hugetlbfs's object - * counting consistent. - */ - ret = dissolve_free_huge_pages(start_pfn, end_pfn); - if (ret) { - reason = "failure to dissolve huge pages"; - goto failed_removal_isolated; - } - ret = test_pages_isolated(start_pfn, end_pfn, MEMORY_OFFLINE); } while (ret);