From patchwork Mon Jul 5 08:55:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6raM7Jik7ZuI?= X-Patchwork-Id: 12358539 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F7BFC07E9B for ; Mon, 5 Jul 2021 08:59:26 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BE4CD613DD for ; Mon, 5 Jul 2021 08:59:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BE4CD613DD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 146576B0036; Mon, 5 Jul 2021 04:59:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 105D66B006C; Mon, 5 Jul 2021 04:59:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E8AE16B005D; Mon, 5 Jul 2021 04:59:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0253.hostedemail.com [216.40.44.253]) by kanga.kvack.org (Postfix) with ESMTP id C5FD46B0011 for ; Mon, 5 Jul 2021 04:59:24 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 3854D8248047 for ; Mon, 5 Jul 2021 08:59:24 +0000 (UTC) X-FDA: 78327935448.13.AF5D02C Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by imf07.hostedemail.com (Postfix) with ESMTP id 8147C100251E for ; Mon, 5 Jul 2021 08:59:23 +0000 (UTC) Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20210705085921epoutp035a9965ab0180c34e67ba8ca663ed11db~O2WkhEYDM1930019300epoutp039 for ; Mon, 5 Jul 2021 08:59:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20210705085921epoutp035a9965ab0180c34e67ba8ca663ed11db~O2WkhEYDM1930019300epoutp039 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1625475561; bh=2y/NVkLne+0y/XisEygWczbRR0MKGa628Bu0+nxLkNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V2FYXUfUE1W6xlEwJDXqcIAgdH9suW+UnRT9xXELpVaQKEC/gNkKqmA5daVO7jsSD bMaee7b+lkWGnDrnOcgfm2G5bY0w0ENAHceeTZIe6AVuWqWbkA6CKO84k1bZ/G7Jpv r4QzFp05vKSz4Jvmebe3dRrjbVUuUxrWtk2h8/Ho= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20210705085920epcas1p12afb92abfbcef9927da7da9c48f520c5~O2WkIgz8s2231422314epcas1p1C; Mon, 5 Jul 2021 08:59:20 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.40.160]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4GJKPM373pz4x9Q2; Mon, 5 Jul 2021 08:59:19 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id B9.DA.09952.6E9C2E06; Mon, 5 Jul 2021 17:59:18 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20210705085918epcas1p17e0ac84d91c591897d00fbc3d3caa771~O2Wh52fKY2231422314epcas1p15; Mon, 5 Jul 2021 08:59:18 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210705085918epsmtrp2caefd19958129f7f5750f8fb94f29cfc~O2Wh5As2B1532215322epsmtrp2U; Mon, 5 Jul 2021 08:59:18 +0000 (GMT) X-AuditID: b6c32a35-447ff700000026e0-12-60e2c9e68cfb Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id CC.C4.08394.6E9C2E06; Mon, 5 Jul 2021 17:59:18 +0900 (KST) Received: from localhost.localdomain (unknown [10.253.98.78]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210705085918epsmtip209624057555c41d1b2a653d34eae2c9b~O2Wht-FyX2867228672epsmtip2X; Mon, 5 Jul 2021 08:59:18 +0000 (GMT) From: Ohhoon Kwon To: david@redhat.com, ohoono.kwon@samsung.com, akpm@linux-foundation.org, mhocko@suse.com Cc: bhe@redhat.com, rppt@linux.ibm.com, ohkwon1043@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] mm: sparse: pass section_nr to section_mark_present Date: Mon, 5 Jul 2021 17:55:36 +0900 Message-Id: <20210705085538.14557-2-ohoono.kwon@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210705085538.14557-1-ohoono.kwon@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMKsWRmVeSWpSXmKPExsW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UD33Q+W2XhocRSnJFoqMVcVJwIAHpO NxO+AgAA X-CMS-MailID: 20210705085918epcas1p17e0ac84d91c591897d00fbc3d3caa771 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210705085918epcas1p17e0ac84d91c591897d00fbc3d3caa771 References: <20210705085538.14557-1-ohoono.kwon@samsung.com> Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=V2FYXUfU; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf07.hostedemail.com: domain of ohoono.kwon@samsung.com designates 203.254.224.33 as permitted sender) smtp.mailfrom=ohoono.kwon@samsung.com X-Stat-Signature: aqze1af739cu3j1pa3qgwjsmbjntzgq8 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 8147C100251E X-HE-Tag: 1625475563-568723 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: With CONFIG_SPARSEMEM_EXTREME enabled, __section_nr() which converts mem_section to section_nr could be costly since it iterates all section roots to check if the given mem_section is in its range. On the other hand, __nr_to_section() which converts section_nr to mem_section can be done in O(1). Let's pass section_nr instead of mem_section ptr to section_mark_present() in order to reduce needless iterations. Signed-off-by: Ohhoon Kwon Acked-by: Michal Hocko Acked-by: Mike Rapoport Reviewed-by: David Hildenbrand --- mm/sparse.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/sparse.c b/mm/sparse.c index 6326cdf36c4f..b4fae2fc6276 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -187,13 +187,14 @@ void __meminit mminit_validate_memmodel_limits(unsigned long *start_pfn, * those loops early. */ unsigned long __highest_present_section_nr; -static void section_mark_present(struct mem_section *ms) +static void section_mark_present(unsigned long section_nr) { - unsigned long section_nr = __section_nr(ms); + struct mem_section *ms; if (section_nr > __highest_present_section_nr) __highest_present_section_nr = section_nr; + ms = __nr_to_section(section_nr); ms->section_mem_map |= SECTION_MARKED_PRESENT; } @@ -280,7 +281,7 @@ static void __init memory_present(int nid, unsigned long start, unsigned long en if (!ms->section_mem_map) { ms->section_mem_map = sparse_encode_early_nid(nid) | SECTION_IS_ONLINE; - section_mark_present(ms); + section_mark_present(section); } } } @@ -934,7 +935,7 @@ int __meminit sparse_add_section(int nid, unsigned long start_pfn, ms = __nr_to_section(section_nr); set_section_nid(section_nr, nid); - section_mark_present(ms); + section_mark_present(section_nr); /* Align memmap to section boundary in the subsection case */ if (section_nr_to_pfn(section_nr) != start_pfn) From patchwork Mon Jul 5 08:55:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6raM7Jik7ZuI?= X-Patchwork-Id: 12358543 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B111CC07E9A for ; Mon, 5 Jul 2021 08:59:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 55A0861260 for ; Mon, 5 Jul 2021 08:59:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55A0861260 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0AB926B006C; Mon, 5 Jul 2021 04:59:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 00D336B0073; Mon, 5 Jul 2021 04:59:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA5246B0072; Mon, 5 Jul 2021 04:59:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0033.hostedemail.com [216.40.44.33]) by kanga.kvack.org (Postfix) with ESMTP id A01AC6B006C for ; Mon, 5 Jul 2021 04:59:34 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2446321962 for ; Mon, 5 Jul 2021 08:59:34 +0000 (UTC) X-FDA: 78327935868.39.DAB5618 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by imf18.hostedemail.com (Postfix) with ESMTP id 5ECFF4002093 for ; Mon, 5 Jul 2021 08:59:33 +0000 (UTC) Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20210705085920epoutp01ee90aa546aff1184b07218e30e88ea0c~O2WkV3BM52713527135epoutp01q for ; Mon, 5 Jul 2021 08:59:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20210705085920epoutp01ee90aa546aff1184b07218e30e88ea0c~O2WkV3BM52713527135epoutp01q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1625475560; bh=Nu7PfJjCtWVRTW61Q4wznKtwiU60A+jrReXpZWdnrew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tb74QFL0PpEdef9oGX2mRQXWUeZVVIxFhvUTwSkkFy8rovlklnRkXcBgkMtPgM4Dq 5kRBhq8sobSGAGrcom1hiJv9Ufv3PKgXF7zDWT1Ua84fjfHICm3bHQCHKn8u8Sr5xF IvfYDSj8fJJTvIGqrVHtrXMFuLI4QpGy4lFle81Q= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20210705085920epcas1p3c5bd47189ebc75d43ceb42bb52964cf5~O2WkDHkHL0462004620epcas1p3z; Mon, 5 Jul 2021 08:59:20 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.40.160]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4GJKPM36wCz4x9Q1; Mon, 5 Jul 2021 08:59:19 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 99.DA.09952.6E9C2E06; Mon, 5 Jul 2021 17:59:18 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p3.samsung.com (KnoxPortal) with ESMTPA id 20210705085918epcas1p3fdaf2bc0de2f1017c3057aeb6e8c82a7~O2Wh-QiQU0407404074epcas1p3z; Mon, 5 Jul 2021 08:59:18 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210705085918epsmtrp1e6e6368dc4bde7f82e981771bb7d74ef~O2Wh_is8F0607106071epsmtrp1D; Mon, 5 Jul 2021 08:59:18 +0000 (GMT) X-AuditID: b6c32a35-447ff700000026e0-10-60e2c9e67810 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id DC.C4.08394.6E9C2E06; Mon, 5 Jul 2021 17:59:18 +0900 (KST) Received: from localhost.localdomain (unknown [10.253.98.78]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210705085918epsmtip20004ee30010958c1ff2d1d456c582996~O2WhyS4X_2653026530epsmtip2k; Mon, 5 Jul 2021 08:59:18 +0000 (GMT) From: Ohhoon Kwon To: david@redhat.com, ohoono.kwon@samsung.com, akpm@linux-foundation.org, mhocko@suse.com Cc: bhe@redhat.com, rppt@linux.ibm.com, ohkwon1043@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] mm: sparse: pass section_nr to find_memory_block Date: Mon, 5 Jul 2021 17:55:37 +0900 Message-Id: <20210705085538.14557-3-ohoono.kwon@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210705085538.14557-1-ohoono.kwon@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrIKsWRmVeSWpSXmKPExsWy7bCmge6zk48SDG48V7GYs34Nm8X5B7/Y LL6u/8VscXnXHDaLe2v+s1rc73Ow2Lvf12LXzxXMFjemNLA5cHrsnHWX3WPTp0nsHidm/Gbx mLDoAKPH+31X2Tz6tqxi9Fi/5SqLx+dNcgEcUTk2GamJKalFCql5yfkpmXnptkrewfHO8aZm Boa6hpYW5koKeYm5qbZKLj4Bum6ZOUDXKSmUJeaUAoUCEouLlfTtbIryS0tSFTLyi0tslVIL UnIKDA0K9IoTc4tL89L1kvNzrQwNDIxMgSoTcjJO7dvJVHBIvOJ8o3MDY6NIFyMHh4SAicSH O1ZdjFwcQgI7GCWmfT7BDuF8YpS4saWXGcL5xijxfcsPoAwnWMerqUtYIRJ7GSV+vFzHBJIA a1m1UwXEZhPQltjfe4IZxBYRiJaYfbUDrIZZoECiof8TC8hqYQEPif0fc0DCLAKqEiemLGcE sXkFbCR2P+tigtglL7F6wwGwMZwCthJ/Xz1hAdkrIfCWXeL/nm2MEEUuEr93fmGFsIUlXh3f AnWolMTL/jZ2iIZ+RolDfdtZIZwJjBLruxrZIQFgL/H+kgWIySygKbF+lz5Er6LEzt9zGSFu 5pN497WHFaKaV6KjTQjCVJVY9tsDolpaom/6ZTYI20PiVO8GRkjwAC16vO004wRGuVkICxYw Mq5iFE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pQf X1Sak1p8iFGag0VJnPdC18l4IYH0xJLU7NTUgtQimCwTB6dUA1PrziWLFIu+nkv+elrqI0/x 3wNXb56yeModHrXf2f6a8CtF/Vc8t69YxKx+OTf0tPAu4Y2J1bWqFgrrs1gZ7n3ZZ1/js+TA vZ9Pyy9H/3uSuML5/m2Dadw9E5fc7JrD/P/d27IXKXpzL4jl7wlLOdP2KNpJgNO+rvvB4YKr ruVf2ZLn9tuWPlCdO/9WWufDSwpxGtxq2XGTT89Ukq/bt8T5UfpeNWcmHslnIpPO/W4TuObK z6VjWDnp5c5IhtY5Z89u/3LrusSObmdBfU23u2clthaevq2fsSzGxa373O7cgt+GLKs9nx8W r1z4KGj3z8juUuHbykZcpsJJ7atN6+OrBcpsvuxp+aD+fTb30ltKLMUZiYZazEXFiQCWUt6u vAIAAA== X-CMS-MailID: 20210705085918epcas1p3fdaf2bc0de2f1017c3057aeb6e8c82a7 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210705085918epcas1p3fdaf2bc0de2f1017c3057aeb6e8c82a7 References: <20210705085538.14557-1-ohoono.kwon@samsung.com> Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=Tb74QFL0; spf=pass (imf18.hostedemail.com: domain of ohoono.kwon@samsung.com designates 203.254.224.24 as permitted sender) smtp.mailfrom=ohoono.kwon@samsung.com; dmarc=pass (policy=none) header.from=samsung.com X-Stat-Signature: wjnigun1qju8d4wqb5w8tczkzfjoyiez X-Rspamd-Queue-Id: 5ECFF4002093 X-Rspamd-Server: rspam06 X-HE-Tag: 1625475573-356456 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: With CONFIG_SPARSEMEM_EXTREME enabled, __section_nr() which converts mem_section to section_nr could be costly since it iterates all section roots to check if the given mem_section is in its range. On the other hand, __nr_to_section() which converts section_nr to mem_section can be done in O(1). Let's pass section_nr instead of mem_section ptr to find_memory_block() in order to reduce needless iterations. Signed-off-by: Ohhoon Kwon Acked-by: Michal Hocko Acked-by: Mike Rapoport Reviewed-by: David Hildenbrand --- arch/powerpc/platforms/pseries/hotplug-memory.c | 4 +--- drivers/base/memory.c | 4 ++-- include/linux/memory.h | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index 377d852f5a9a..d4f28ee4d5dc 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -211,13 +211,11 @@ static int update_lmb_associativity_index(struct drmem_lmb *lmb) static struct memory_block *lmb_to_memblock(struct drmem_lmb *lmb) { unsigned long section_nr; - struct mem_section *mem_sect; struct memory_block *mem_block; section_nr = pfn_to_section_nr(PFN_DOWN(lmb->base_addr)); - mem_sect = __nr_to_section(section_nr); - mem_block = find_memory_block(mem_sect); + mem_block = find_memory_block(section_nr); return mem_block; } diff --git a/drivers/base/memory.c b/drivers/base/memory.c index d5ffaab3cb61..e31598955cc4 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -578,9 +578,9 @@ static struct memory_block *find_memory_block_by_id(unsigned long block_id) /* * Called under device_hotplug_lock. */ -struct memory_block *find_memory_block(struct mem_section *section) +struct memory_block *find_memory_block(unsigned long section_nr) { - unsigned long block_id = memory_block_id(__section_nr(section)); + unsigned long block_id = memory_block_id(section_nr); return find_memory_block_by_id(block_id); } diff --git a/include/linux/memory.h b/include/linux/memory.h index 97e92e8b556a..d9a0b61cd432 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -90,7 +90,7 @@ int create_memory_block_devices(unsigned long start, unsigned long size, void remove_memory_block_devices(unsigned long start, unsigned long size); extern void memory_dev_init(void); extern int memory_notify(unsigned long val, void *v); -extern struct memory_block *find_memory_block(struct mem_section *); +extern struct memory_block *find_memory_block(unsigned long section_nr); typedef int (*walk_memory_blocks_func_t)(struct memory_block *, void *); extern int walk_memory_blocks(unsigned long start, unsigned long size, void *arg, walk_memory_blocks_func_t func); From patchwork Mon Jul 5 08:55:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6raM7Jik7ZuI?= X-Patchwork-Id: 12358537 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11F1BC07E99 for ; Mon, 5 Jul 2021 08:59:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 82CE661935 for ; Mon, 5 Jul 2021 08:59:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82CE661935 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 53F746B0011; Mon, 5 Jul 2021 04:59:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 515806B005D; Mon, 5 Jul 2021 04:59:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 318F46B0071; Mon, 5 Jul 2021 04:59:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0040.hostedemail.com [216.40.44.40]) by kanga.kvack.org (Postfix) with ESMTP id 06ADA6B0011 for ; Mon, 5 Jul 2021 04:59:24 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7924E21963 for ; Mon, 5 Jul 2021 08:59:24 +0000 (UTC) X-FDA: 78327935448.29.5D8DC0A Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by imf19.hostedemail.com (Postfix) with ESMTP id C0725B000182 for ; Mon, 5 Jul 2021 08:59:23 +0000 (UTC) Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20210705085921epoutp033df44c666fe3ebbc0b71fd961a789e25~O2Wk1sgWG1930019300epoutp03_ for ; Mon, 5 Jul 2021 08:59:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20210705085921epoutp033df44c666fe3ebbc0b71fd961a789e25~O2Wk1sgWG1930019300epoutp03_ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1625475561; bh=eiXtJKwEaewkgKoO/19bGdQAS0EpH99MRdSzhegqUOM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mWwnOenD4K/YBV/S4cbmg9sxQunADVdASzPt3RL9Kust3GNqffl/VdNx/cH8YHKpX E5hbMo9evWy6ZUmOPLLWypwvxOw9C7cHpfOsidqeuTzFGg436bypMuKAzdN4Zrahg+ 7my9MO5O6ZbSx7wYlGfl/ajq0EvxwmT59IF9AHgg= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20210705085920epcas1p4ced8700a53d50de330ae4969d1c39618~O2WkZuUzI0213302133epcas1p4R; Mon, 5 Jul 2021 08:59:20 +0000 (GMT) Received: from epsmges1p3.samsung.com (unknown [182.195.40.166]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4GJKPM6132z4x9QK; Mon, 5 Jul 2021 08:59:19 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p3.samsung.com (Symantec Messaging Gateway) with SMTP id 2E.6C.09468.6E9C2E06; Mon, 5 Jul 2021 17:59:18 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20210705085918epcas1p415e226a85dc289c2d306c009dbc4ef55~O2WiDm4F-0213302133epcas1p4H; Mon, 5 Jul 2021 08:59:18 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210705085918epsmtrp18bed893109164f371d7f915ba14c2335~O2WiCxa9L0607106071epsmtrp1E; Mon, 5 Jul 2021 08:59:18 +0000 (GMT) X-AuditID: b6c32a37-0b1ff700000024fc-bd-60e2c9e61895 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 7D.C4.08394.6E9C2E06; Mon, 5 Jul 2021 17:59:18 +0900 (KST) Received: from localhost.localdomain (unknown [10.253.98.78]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210705085918epsmtip2db0c596f5cdf3a853dbdd4d21f26e233~O2Wh2nZBN2867728677epsmtip2J; Mon, 5 Jul 2021 08:59:18 +0000 (GMT) From: Ohhoon Kwon To: david@redhat.com, ohoono.kwon@samsung.com, akpm@linux-foundation.org, mhocko@suse.com Cc: bhe@redhat.com, rppt@linux.ibm.com, ohkwon1043@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] mm: sparse: remove __section_nr() function Date: Mon, 5 Jul 2021 17:55:38 +0900 Message-Id: <20210705085538.14557-4-ohoono.kwon@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210705085538.14557-1-ohoono.kwon@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrIKsWRmVeSWpSXmKPExsWy7bCmvu7zk48SDO6JWsxZv4bN4vyDX2wW X9f/Yra4vGsOm8W9Nf9ZLe73OVjs3e9rsevnCmaLG1Ma2Bw4PXbOusvusenTJHaPEzN+s3hM WHSA0eP9vqtsHn1bVjF6rN9ylcXj8ya5AI6oHJuM1MSU1CKF1Lzk/JTMvHRbJe/geOd4UzMD Q11DSwtzJYW8xNxUWyUXnwBdt8wcoOOUFMoSc0qBQgGJxcVK+nY2RfmlJakKGfnFJbZKqQUp OQWGBgV6xYm5xaV56XrJ+blWhgYGRqZAlQk5GWdPX2YpOMVXsefcV/YGxgaeLkZ2DgkBE4lN LF2MXBxCAjsYJfbu62PtYuQEcj4xSlw6JQyR+MYo8fjVNUaQBEj9z+lTmSASexkl/u3uZYRw gDo2H2wDq2IT0JbY33uCGcQWEYiWmH21gwnEZhYokGjo/8QCYgsLOEn07NsLVs8ioCqxu3EC WA2vgI1ET8dEdoht8hKrNxwAm8MpYCvx99UTsFslBN6ySzw7vgvqJBeJTY8nMkPYwhKvjm+B apaSeNnfxg7R0M8ocahvOyuEM4FRYn1XI1CGA8ixl3h/yQLEZBbQlFi/Sx+iV1Fi5++5jBBH 80m8+9rDClHNK9HRJgRhqkos++0BUS0t0Tf9MhuE7SFxfPkEaJACLer90ss2gVFuFsKCBYyM qxjFUguKc9NTiw0LjJHjaxMjOO1pme9gnPb2g94hRiYOxkOMEhzMSiK8IlMeJQjxpiRWVqUW 5ccXleakFh9iNAUG3kRmKdHkfGDizSuJNzQ1MjY2tjAxMzczNVYS593JdihBSCA9sSQ1OzW1 ILUIpo+Jg1OqgalPrnBdxIyy3f8d0i5/+8G0X/7o9clHJ07jMRW/HX9L5rXE10NfGjoiv2sJ mbgteShkbHX6fH93y5xz00sST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c4UtU+JRLp6Qm1J/4pm/VltP81tyYM/G Kxdv9gX842dVUxbsy/hwbWXqPImLj9Mi2Ve9Y61P+/rLWNsu+p7HnGWTO1+K2dzevrX+gIfW miWPSo4Hl74VcN1mUFX+7Ij3l2Y9h0yHAsajDs/LwjeGziz9t1mJpTgj0VCLuag4EQD3kwSQ vgIAAA== X-CMS-MailID: 20210705085918epcas1p415e226a85dc289c2d306c009dbc4ef55 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210705085918epcas1p415e226a85dc289c2d306c009dbc4ef55 References: <20210705085538.14557-1-ohoono.kwon@samsung.com> Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=mWwnOenD; spf=pass (imf19.hostedemail.com: domain of ohoono.kwon@samsung.com designates 203.254.224.33 as permitted sender) smtp.mailfrom=ohoono.kwon@samsung.com; dmarc=pass (policy=none) header.from=samsung.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: C0725B000182 X-Stat-Signature: wnh55xc8u3tg1zutwgx9d3csj1akfkfe X-HE-Tag: 1625475563-819228 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: As the last users of __section_nr() are gone, let's remove unused function __section_nr(). Signed-off-by: Ohhoon Kwon Acked-by: Michal Hocko Acked-by: Mike Rapoport Reviewed-by: David Hildenbrand --- include/linux/mmzone.h | 1 - mm/sparse.c | 26 -------------------------- 2 files changed, 27 deletions(-) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index fcb535560028..8827f4d081d4 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1342,7 +1342,6 @@ static inline struct mem_section *__nr_to_section(unsigned long nr) return NULL; return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK]; } -extern unsigned long __section_nr(struct mem_section *ms); extern size_t mem_section_usage_size(void); /* diff --git a/mm/sparse.c b/mm/sparse.c index b4fae2fc6276..c14d2b37fd16 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -109,32 +109,6 @@ static inline int sparse_index_init(unsigned long section_nr, int nid) } #endif -#ifdef CONFIG_SPARSEMEM_EXTREME -unsigned long __section_nr(struct mem_section *ms) -{ - unsigned long root_nr; - struct mem_section *root = NULL; - - for (root_nr = 0; root_nr < NR_SECTION_ROOTS; root_nr++) { - root = __nr_to_section(root_nr * SECTIONS_PER_ROOT); - if (!root) - continue; - - if ((ms >= root) && (ms < (root + SECTIONS_PER_ROOT))) - break; - } - - VM_BUG_ON(!root); - - return (root_nr * SECTIONS_PER_ROOT) + (ms - root); -} -#else -unsigned long __section_nr(struct mem_section *ms) -{ - return (unsigned long)(ms - mem_section[0]); -} -#endif - /* * During early boot, before section_mem_map is used for an actual * mem_map, we use section_mem_map to store the section's NUMA