From patchwork Thu Aug 29 15:05:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13783361 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 D3D5EC83F2D for ; Thu, 29 Aug 2024 15:05:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5388B6B0083; Thu, 29 Aug 2024 11:05:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C1026B0089; Thu, 29 Aug 2024 11:05:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 361FE6B008A; Thu, 29 Aug 2024 11:05:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0773D6B0083 for ; Thu, 29 Aug 2024 11:05:27 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A00B4A1032 for ; Thu, 29 Aug 2024 15:05:26 +0000 (UTC) X-FDA: 82505606652.10.47A85FB Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf07.hostedemail.com (Postfix) with ESMTP id 33BF440062 for ; Thu, 29 Aug 2024 15:05:07 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724943888; a=rsa-sha256; cv=none; b=P2nPMkHrR7jzmkeeZWkfOTY10a9RZPSs5g8YW+IM5++TpN6jNNG4/ZoXm6zmF8YcxrEvkx CK1HfyrNCo4rBtSPKfN+2plW/Q3WOjfjNEk7FIt1TDe5FLn1tjWb+mTutqAvXm179SMU6O ZDKVEL5gVJkHByvxNKPgG1xyVJOxkdA= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724943888; 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=hMMD+SCZmgEnkSUBFbiAduzvMmXuWz+EToFDFaqvorY=; b=cmZqGZB79N0ayC9XSA8oophdC0TsfEYvFYCKL+QCG7iCGVonequ8iCXlWxUXyvxin5Kw3V FQj5yhccLIROqS0UgX3BTzMVD6IoCtcepoCVVRheTzujLwUf0eU6iF9a7RTEgW7FC+pMic Cfrj36qNtefQrlXe+YIhwqrvanaE8bo= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Wvl1t4nKwz1j7kR; Thu, 29 Aug 2024 23:04:50 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 55C641A0188; Thu, 29 Aug 2024 23:05:03 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 29 Aug 2024 23:05:02 +0800 From: Kefeng Wang To: Andrew Morton CC: David Hildenbrand , Oscar Salvador , Miaohe Lin , Naoya Horiguchi , , Kefeng Wang Subject: [PATCH v3 5-fix/5] mm: memory_hotplug: unify Huge/LRU/non-LRU movable folio isolation fix Date: Thu, 29 Aug 2024 23:05:00 +0800 Message-ID: <20240829150500.2599549-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240827114728.3212578-6-wangkefeng.wang@huawei.com> References: <20240827114728.3212578-6-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemf100008.china.huawei.com (7.185.36.138) X-Rspam-User: X-Rspamd-Queue-Id: 33BF440062 X-Rspamd-Server: rspam01 X-Stat-Signature: 6smwqzfpu5s14h4p1dp6cksocsez5dze X-HE-Tag: 1724943907-608804 X-HE-Meta: U2FsdGVkX1/BQqUXGLeVosGlwznp/8n4cOt4+J9V77abfjbbx5Irg2fdthoe6mP5zMd+Zfl9d+yO3WqwRwlNzRxedFnk3F32nbS8wIcOLzIZYEkoMz1wRL2SEVxVWHNF3Tw75s0OIDIZHIM1u+eZhXagFFrknOg29oh/5oONKCdh0e1ESvY8kO/M7ujHuMygzuKx2Aomzvyz3rREjiVyt+cSefmU5W1SqU7dBDlA6bjThH+S+DILwhJScKBOVmfto6tRuB65krEzfNkq5D5WQ1IPX6w3sQAV0lhtEnHpJMgo0OwzyMU77AGcdSm4f2ONm3eg/s1e1IGweK82c65djnRt39HNixTcujneXLTd1zBXae4NYti7wf+oLNCAip2KJT1lm/5lsMDFvFVzwEDhbP64cWfiOo4WAQDVMxdRC2qSyqwDe+Za87aAgWFpDeipR1bSPGWgBBlp0njJac4QHAwafeempC7bRNoxEnq6LT+Knw0coOAWMw3PhCqjzCV+iqbboVUk8Q08/qMDog+jhnPuHwO2j0+lJgswA0YWSH1NK2WTGFYhbNgJMbBhCklr7xmgn/pmlrTFAf2XsbrXm10axw8KJpHoLCho08XHmzFHc5FWFnvejZmzBG4ExhKaKuvYH4YODKSrGN9AjBp1TM8rKb153Dc5+VrHiLp/oYqBVr8MWB0xA0PTuol74+HY0TrV23Khy7WDTGrzs0twG/CbOnGNoTCdxBRcK0YTLvNBwvnRKWnVVnTwWxZSXQROAfwxETBmTA4+sIdl24hpdm8ZJWczsphRj+gqJa2lTaFF4pgk/YvOi/Ea2x7avVxFgkEu+u6a+RoKA8nvic/qt4Vw9tDAKYGri5RAAWOetOdBaVBwHkzG2JzCPIBvJpgedlrpzC1rs4m+jgncOAtphHL1DhvUuFqubRt7jT9aVXMA8NsW0wpFVXqmSWi5zICEVCTUafztGgca4gEsMga ePHsdXcK zB6u+QfEXskYrK2vNeVYH1M74Z/czMGhWjEhw5GXsL+C+CewPhcsN7mcBwtetcl3iV2RnzGKfZN3tJctA+orfHPAMxsgGDqODvutrKmcKDNNY1XnQSzTDYvrJDO7pfo7UHx+k5xN1gzVWSkElGyVu4bVTzZm9xUNaT0IQb6HO6TJA+ElnfJ1wGc4DiNvrpAL9O6+9QXZEpOE1JgQq+Sa8jritNLpaY83rxIJKrlGI2ZZFCb2JkQgqCD7ZJPzffyJAtP1P 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: List-Subscribe: List-Unsubscribe: - Use folio_try_get()/folio_put() unconditionally, per David - print current pfn when isolate_folio_to_list fails. - memory hotremove test passed for free/used hugetlb folio Signed-off-by: Kefeng Wang --- mm/memory_hotplug.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 5f09866d17cf..621ae1015106 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1780,7 +1780,6 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) for (pfn = start_pfn; pfn < end_pfn; pfn++) { struct page *page; - bool hugetlb; if (!pfn_valid(pfn)) continue; @@ -1811,22 +1810,21 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) continue; } - hugetlb = folio_test_hugetlb(folio); - if (!hugetlb) { - folio = folio_get_nontail_page(page); - if (!folio) - continue; - } + if (!folio_try_get(folio)) + continue; + + if (unlikely(page_folio(page) != folio)) + goto put_folio; if (!isolate_folio_to_list(folio, &source)) { if (__ratelimit(&migrate_rs)) { - pr_warn("failed to isolate pfn %lx\n", pfn); + pr_warn("failed to isolate pfn %lx\n", + page_to_pfn(page)); dump_page(page, "isolation failed"); } } - - if (!hugetlb) - folio_put(folio); +put_folio: + folio_put(folio); } if (!list_empty(&source)) { nodemask_t nmask = node_states[N_MEMORY];