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 1A1FDECAAA1 for ; Tue, 6 Sep 2022 03:00:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 68D8380248; Mon, 5 Sep 2022 23:00:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 63C9380224; Mon, 5 Sep 2022 23:00:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5054F80248; Mon, 5 Sep 2022 23:00:05 -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 3FD2D80224 for ; Mon, 5 Sep 2022 23:00:05 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0E043140784 for ; Tue, 6 Sep 2022 03:00:05 +0000 (UTC) X-FDA: 79880156370.16.334CD6C Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf27.hostedemail.com (Postfix) with ESMTP id CBA36400B0 for ; Tue, 6 Sep 2022 03:00:03 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MM9722x9szrS60; Tue, 6 Sep 2022 10:58:06 +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; Tue, 6 Sep 2022 10:59:59 +0800 Subject: Re: [PATCH v2 1/4] mm,hwpoison,hugetlb,memory_hotplug: hotremove memory section with hwpoisoned hugepage To: Naoya Horiguchi CC: Andrew Morton , David Hildenbrand , Mike Kravetz , Yang Shi , Oscar Salvador , Muchun Song , Jane Chu , Naoya Horiguchi , , Linux-MM References: <20220905062137.1455537-1-naoya.horiguchi@linux.dev> <20220905062137.1455537-2-naoya.horiguchi@linux.dev> From: Miaohe Lin Message-ID: <3e302aa5-d63d-097e-2cb7-831b7c99e736@huawei.com> Date: Tue, 6 Sep 2022 10:59:58 +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: <20220905062137.1455537-2-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: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662433204; a=rsa-sha256; cv=none; b=U8Th/YdEUZiK9KelBBo4Gympc25IW7qaYOvs/9UpWk9tLnemAGuteM4PzbxJinx7stGexf QAXL9WsKpAQ6GEopIY1FcZhQqAjVzlQ1UKHOmtKrq6OLbZmhAl9w8wa3tvOjRVmVuFvzZy xzdCZsEisjrm/2drPOeFnnnaoEgDWM4= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662433204; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Fr02B4pqby/D/2JGYNP4XFBA1Ux1WEqsWBwz1i+b6Cg=; b=oeU3jwVCJHxrfshKOJpzs+67N+E9jir+8tKuDQDGuE3u9N/+PPz9Crqb1DXtPu3VVTuLXU 8++tNfBNY6pk1Fz8cd812aSarijGrFtZZzSLg+hkY+vNHjwrtWTt6IPPTm7BwsaWYesy/4 upsVsTHLN+dycvIeGknS1UkcbLY3WaE= X-Rspam-User: Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam06 X-Stat-Signature: bpe3asawqkrb64n7388h15xzx47sxbyj X-Rspamd-Queue-Id: CBA36400B0 X-HE-Tag: 1662433203-67011 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/9/5 14:21, Naoya Horiguchi wrote: > 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. Yes, thanks for your work, Naoya. ;) > > 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; > + } This change has a side-effect. If hugetlb pages are in-use, dissolve_free_huge_pages() will always return -EBUSY even if those pages can be migrated. So we fail to hotremove the memory even if they could be offlined. Or am I miss something? Thanks, Miaohe Lin > + > 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); >