From patchwork Tue Dec 13 09:27:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13071852 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 834FBC4167B for ; Tue, 13 Dec 2022 09:11:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 891FD8E0006; Tue, 13 Dec 2022 04:11:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6163F8E0003; Tue, 13 Dec 2022 04:11:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3A5B48E0003; Tue, 13 Dec 2022 04:11:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0BC8A8E0006 for ; Tue, 13 Dec 2022 04:11:27 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 614D11C6543 for ; Tue, 13 Dec 2022 09:11:26 +0000 (UTC) X-FDA: 80236714572.28.B3E5301 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf16.hostedemail.com (Postfix) with ESMTP id 35765180003 for ; Tue, 13 Dec 2022 09:11:22 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf16.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1670922684; 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=bcUHycRfTmcc149UJSRLAItdiMHwuy/uxCqLn6VIdfA=; b=WC3moNjG1tZZMR0twxV9ySTgy6VeVghFnetRGJ3FLKbnciKywRMbEd8TFoQR8ACq3NOZsK WrLatfOLKjfLhcK9d4wRvybZzWDnlzLQ9uPIB2CsIywlJUmrYrNWFS5ngpbVKnpiKebP2R bbBBmoP8jMeLn5Q5hc9Qi6l69Qd4sLo= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf16.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1670922684; a=rsa-sha256; cv=none; b=nmyzBoEUSFmqmbu8aaZq+GeD7iTcXBCsqT3WERQB0hVRmKYbFnfes3CFggJ9zXrNxVMrxu e5bEhZfvxrk+lo1XuCC7xmrf7p8W5Tb1zwGBGm+K6+vjsd1se9FhX55bD4PYUj2zVoLZw7 p7XXrgRw8hXNPDBJyV+SPTQmoKh6Jq8= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4NWXlL3417z15NBs; Tue, 13 Dec 2022 17:10:22 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 13 Dec 2022 17:11:18 +0800 From: Kefeng Wang To: Andrew Morton , David Hildenbrand , Oscar Salvador , SeongJae Park CC: , , , , , Kefeng Wang Subject: [PATCH -next 1/8] mm: memory_hotplug: add pfn_to_online_folio() Date: Tue, 13 Dec 2022 17:27:28 +0800 Message-ID: <20221213092735.187924-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221213092735.187924-1-wangkefeng.wang@huawei.com> References: <20221213092735.187924-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 35765180003 X-Stat-Signature: eg4utea8e7jtnsmecdosdu4h1iz9ey15 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1670922682-778950 X-HE-Meta: U2FsdGVkX19jgrwozwn9hDSFadAEUJK0Cx2qANEM2LRrgnJvjlWzOI0G/mH/3DxfiRqHvLHhZypcJzaxo3UV7eV+2DNQw32rVe2j/wFD2u0vdcZvhIgRyCEREOFBrN1HHMLLzwJzd9MJjsoPM8ksx3jXU6bzIumjQCR1X75Czi21ZeEZ/3+58OGdIKiBIP7Ky1bDRdEYP4z4O8GhKm2p7gBw3xF+wp2Me47aIAMmulTux0tobel113rhlEb9JdslMcqUu39lCu0S5PkjhY78WN4tDGvo7IzgHcHWIZV9XVJ/yKPloLhL15fWmqS/7DUR8rgel401pEENXbWF9Um5kpOWyxiN+8c2jWV55H2AAw/xXBzEFshiOM0DT9kWqIwtO5GX7rK18A4woFJsE5mjnpEzyXNmF5er2gWT67SqU4IkES/br4hbQejhTJWc0uEi7fGy5tjmR2pLqM2B/rk2YsZOyPoRO0I2hpeeaBdEKxqSlfYyifMBR8t6M90eqzSKGl8CmsZ21riw1/+QyCv6RvESoPsFPlu1mDQ6V0ZqTltTYUNZDtWXeojwJ1s7kMR20N1Gzhrt8QfwTXF3ADpCTzYCDiZnZ/RL2aaeb+YShSjpwXA5x6UtX1QihhForfmpUSynhvTAwvg7LVq5C/fzen4hW8YptZ+iDBKPBXL6CemHONkjal5Eo20yAqGdtWORO9ZF1du3gLbuQ2k1pK71B8JhR3yX/85ogPj9M+Btd0cL4I/vVTIsix1/SUtrero/HN9ayJouDg+fLOsL3GK4bdyNIca0pq0bOtatiGftTAZy4b9DXB8MlYuopHqi9UdgofPvtibrhrpi2g8V1E2tupGOFChvRbODpN6AL1XHhs6nU2DM/4oAgnHNR471ET/FGQrJtN1L14rf6AyGhhHaJAFOpPazjze2wCbUzvmBrWgPIDBfWOaDEuQLL3+fia+ME9s9sN79JBgq1W4iHui C2qSHhM/ gzLQP 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: Introduce a wrapper function pfn_to_online_folio(), which calls pfn_to_online_page() and returns the folio of the page found, or null if no page. Signed-off-by: Kefeng Wang --- include/linux/memory_hotplug.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 9fcbf5706595..e841e4fb52a7 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -265,6 +265,13 @@ static inline void pgdat_kswapd_unlock(pg_data_t *pgdat) {} static inline void pgdat_kswapd_lock_init(pg_data_t *pgdat) {} #endif /* ! CONFIG_MEMORY_HOTPLUG */ +static inline struct folio *pfn_to_online_folio(unsigned long pfn) +{ + struct page *page = pfn_to_online_page(pfn); + + return page ? page_folio(page) : NULL; +} + /* * Keep this declaration outside CONFIG_MEMORY_HOTPLUG as some * platforms might override and use arch_get_mappable_range()