From patchwork Wed Jul 7 15:02:10 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: 12362761 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 C576DC07E9E for ; Wed, 7 Jul 2021 15:05:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 68BED61CC6 for ; Wed, 7 Jul 2021 15:05:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68BED61CC6 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 ADAB06B006C; Wed, 7 Jul 2021 11:05:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC0B86B0070; Wed, 7 Jul 2021 11:05:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 903976B0070; Wed, 7 Jul 2021 11:05:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id 701BD6B005D for ; Wed, 7 Jul 2021 11:05:45 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id CE0771944E for ; Wed, 7 Jul 2021 15:05:44 +0000 (UTC) X-FDA: 78336116208.18.397C60F Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by imf05.hostedemail.com (Postfix) with ESMTP id C7A485006090 for ; Wed, 7 Jul 2021 15:05:43 +0000 (UTC) Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20210707150540epoutp02fa48dedfd364ac260f8e6291377417db~Pio-ZjbGw1863918639epoutp020 for ; Wed, 7 Jul 2021 15:05:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20210707150540epoutp02fa48dedfd364ac260f8e6291377417db~Pio-ZjbGw1863918639epoutp020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1625670340; bh=vie/MD3bp15OOdNkmszQP60mktTrs2rhI3koi1uWjBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CVrQDKgSdAUi/LvubJpSOWLmBcpQlAfWLV6TD5iyos4kDRlWl3aMAGyfFzMnAFKEF LdTyFRS6q4M23DE1z0XyBig8ePZxd0RGpBFY4xGrBQJsbt6MKhT9EMr1Q6OHaIrAe+ U7K1hm626wOmJUrymDQfw1eGL8WRkaBYKfIf3/14= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20210707150540epcas1p12159d4c80c6fd1eb77d57e7c0ac17c60~Pio-HL-ts0349803498epcas1p1J; Wed, 7 Jul 2021 15:05:40 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.40.161]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4GKjR73wgKz4x9Pw; Wed, 7 Jul 2021 15:05:39 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 2C.01.09952.3C2C5E06; Thu, 8 Jul 2021 00:05:39 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20210707150538epcas1p4b893d4fcd9eab24e4e06714efc24299e~Pio9awENd2640426404epcas1p4B; Wed, 7 Jul 2021 15:05:38 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210707150538epsmtrp112acc4da4fe30925052138cfe2657ff4~Pio9ZgyOu3041830418epsmtrp1i; Wed, 7 Jul 2021 15:05:38 +0000 (GMT) X-AuditID: b6c32a35-45dff700000026e0-f1-60e5c2c31ee1 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 3E.19.08289.2C2C5E06; Thu, 8 Jul 2021 00:05:38 +0900 (KST) Received: from localhost.localdomain (unknown [10.253.98.78]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210707150538epsmtip256ce86beebcb9af87f2e14b30de15558~Pio9Rfqqg0193201932epsmtip2V; Wed, 7 Jul 2021 15:05:38 +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 v4 1/3] mm: sparse: pass section_nr to section_mark_present Date: Thu, 8 Jul 2021 00:02:10 +0900 Message-Id: <20210707150212.855-2-ohoono.kwon@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210707150212.855-1-ohoono.kwon@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKKsWRmVeSWpSXmKPExsWy7bCmge7h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kQA0Z/A zb4CAAA= X-CMS-MailID: 20210707150538epcas1p4b893d4fcd9eab24e4e06714efc24299e X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210707150538epcas1p4b893d4fcd9eab24e4e06714efc24299e References: <20210707150212.855-1-ohoono.kwon@samsung.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C7A485006090 X-Stat-Signature: sp891u96aueiwonsp3s64sk7bx1kwpti Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=CVrQDKgS; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf05.hostedemail.com: domain of ohoono.kwon@samsung.com designates 203.254.224.25 as permitted sender) smtp.mailfrom=ohoono.kwon@samsung.com X-HE-Tag: 1625670343-876084 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. Since both callers of section_mark_present already know section_nr, let's also pass section_nr as well as mem_section in order to reduce costly translation. Signed-off-by: Ohhoon Kwon Acked-by: Mike Rapoport Acked-by: Michal Hocko Reviewed-by: David Hildenbrand --- mm/sparse.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mm/sparse.c b/mm/sparse.c index 6326cdf36c4f..8018ee7fcda5 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -187,10 +187,9 @@ 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(struct mem_section *ms, + unsigned long section_nr) { - unsigned long section_nr = __section_nr(ms); - if (section_nr > __highest_present_section_nr) __highest_present_section_nr = section_nr; @@ -280,7 +279,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(ms, section); } } } @@ -934,7 +933,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(ms, section_nr); /* Align memmap to section boundary in the subsection case */ if (section_nr_to_pfn(section_nr) != start_pfn) From patchwork Wed Jul 7 15:02:11 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: 12362765 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 0DEA7C07E95 for ; Wed, 7 Jul 2021 15:05:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AF68A61CC1 for ; Wed, 7 Jul 2021 15:05:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF68A61CC1 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 00B9A6B0070; Wed, 7 Jul 2021 11:05:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ED0406B0071; Wed, 7 Jul 2021 11:05:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D97186B0073; Wed, 7 Jul 2021 11:05:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0213.hostedemail.com [216.40.44.213]) by kanga.kvack.org (Postfix) with ESMTP id B02F96B0071 for ; Wed, 7 Jul 2021 11:05:45 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 0D29780E1C5E for ; Wed, 7 Jul 2021 15:05:45 +0000 (UTC) X-FDA: 78336116250.28.88E20D5 Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by imf17.hostedemail.com (Postfix) with ESMTP id 0BFDEF001F96 for ; Wed, 7 Jul 2021 15:05:43 +0000 (UTC) Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20210707150541epoutp019bb33959056364a834232b5853b4b257~Pio-svHoi1928219282epoutp011 for ; Wed, 7 Jul 2021 15:05:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20210707150541epoutp019bb33959056364a834232b5853b4b257~Pio-svHoi1928219282epoutp011 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1625670341; bh=Nu7PfJjCtWVRTW61Q4wznKtwiU60A+jrReXpZWdnrew=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uP+CLyn/jm5XBnK2i89WFmvJ6VIhmOlxZcZbKrrumath/tO58OOSV9XjEsDM6yXR6 42FKZmiGSp3+X3TNwfVRItB9QEuyijv9Ql1oAWO8TamcIEEY2VE9RQV6YSHW4JAkc1 Ws/H874J6fBauLJAc/Uc0BCCp/xq64t6+l0VrYvU= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20210707150540epcas1p47228373b8397b4ec0fbf75fb7a09944c~Pio-GzkSQ2556725567epcas1p4H; Wed, 7 Jul 2021 15:05:40 +0000 (GMT) Received: from epsmges1p3.samsung.com (unknown [182.195.40.166]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4GKjR73FZWz4x9Pw; Wed, 7 Jul 2021 15:05:39 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p3.samsung.com (Symantec Messaging Gateway) with SMTP id FC.46.09468.3C2C5E06; Thu, 8 Jul 2021 00:05:39 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p2.samsung.com (KnoxPortal) with ESMTPA id 20210707150538epcas1p2b2424d8303874d62d3ede60c38db6b59~Pio9kG32D0400804008epcas1p2I; Wed, 7 Jul 2021 15:05:38 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210707150538epsmtrp10fb213ab2216b92da0e966f1244307f2~Pio9eOpJ43041830418epsmtrp1j; Wed, 7 Jul 2021 15:05:38 +0000 (GMT) X-AuditID: b6c32a37-0c7ff700000024fc-7a-60e5c2c39668 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id A3.E7.08394.2C2C5E06; Thu, 8 Jul 2021 00:05:38 +0900 (KST) Received: from localhost.localdomain (unknown [10.253.98.78]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210707150538epsmtip281dbc6f35b95aa9a88a820967a9669f1~Pio9UfKUd0863308633epsmtip2_; Wed, 7 Jul 2021 15:05:38 +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 v4 2/3] mm: sparse: pass section_nr to find_memory_block Date: Thu, 8 Jul 2021 00:02:11 +0900 Message-Id: <20210707150212.855-3-ohoono.kwon@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210707150212.855-1-ohoono.kwon@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrIKsWRmVeSWpSXmKPExsWy7bCmvu7hQ08TDN6sErGYs34Nm8X5B7/Y LL6u/8VscXnXHDaLe2v+s1rc73Ow2Lvf12LXzxXMFjemNLA5cHrsnHWX3WPTp0nsHidm/Gbx mLDoAKPH+31X2Tz6tqxi9Fi/5SqLx+dNcgEcUTk2GamJKalFCql5yfkpmXnptkrewfHO8aZm Boa6hpYW5koKeYm5qbZKLj4Bum6ZOUDXKSmUJeaUAoUCEouLlfTtbIryS0tSFTLyi0tslVIL UnIKDA0K9IoTc4tL89L1kvNzrQwNDIxMgSoTcjJO7dvJVHBIvOJ8o3MDY6NIFyMnh4SAicTm wweYuhi5OIQEdjBKTPs1gw3C+cQocXXedyaQKiGBb4wSvYc4YDqmN25khijayyjRMG89M1zH nomz2EGq2AS0Jfb3nmAGsUUEoiVmX+0Am8QsUCDR0P+JpYuRg0NYwEOi6bAbiMkioCrxrMkW pIJXwEriyp6rzBC75CVWbzgAZnMKWEtcXnePFWSVhMBLdom+tm4WiCIXids7J7JB2MISr45v YYewpSRe9rexQzT0M0oc6tsO1T2BUWJ9VyM7yGYJAXuJ95csQExmAU2J9bv0IXoVJXb+nssI cTKfxLuvPawQ1bwSHW1CEKaqxLLfHhDV0hJ90y9DXeAhsfDffXZIiPQxSvzYe4t1AqPcLIQF CxgZVzGKpRYU56anFhsWGCNH1yZGcNrTMt/BOO3tB71DjEwcjIcYJTiYlUR4GR2eJgjxpiRW VqUW5ccXleakFh9iNAWG3URmKdHkfGDizSuJNzQ1MjY2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+GbyvnLPv34V1uYvJmjknCM8/udDpx8ole zY2lfa0bX0WKzVmw9jtrTX95e1jg1YRDR6NKrqSn2YqGZ8dW25nu/JXofn6yAPfqCR0BpZuq p6tNzd52KE6/TV6E53bbXcb4wxL7OCd3XzLeMEHy4rlqkYnPU0unmXoETVJJ2z9ZfdO3xu3n Z0+KT07iaXW7s4+lcM5seVvbMxN1/31eut/ux3qdoAu+F0wfvtx4XbL58v0b9/9Zp/1zdF6y vmLC1dazi+4b8VvP4EtZWdmffoB/l+kcQeWKP4c9fNg/8x95qcRSnJFoqMVcVJwIAEQGAbi7 AgAA X-CMS-MailID: 20210707150538epcas1p2b2424d8303874d62d3ede60c38db6b59 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210707150538epcas1p2b2424d8303874d62d3ede60c38db6b59 References: <20210707150212.855-1-ohoono.kwon@samsung.com> Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b="uP+CLyn/"; spf=pass (imf17.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: 3gxm4qrbc1jxjkhn1ag6tgomrmab6n8q X-Rspamd-Queue-Id: 0BFDEF001F96 X-Rspamd-Server: rspam06 X-HE-Tag: 1625670343-512177 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 Wed Jul 7 15:02:12 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: 12362763 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 0CDD3C07E9E for ; Wed, 7 Jul 2021 15:05:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9B39961CC0 for ; Wed, 7 Jul 2021 15:05:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B39961CC0 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 D25226B005D; Wed, 7 Jul 2021 11:05:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CFBD36B0072; Wed, 7 Jul 2021 11:05:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B89856B005D; Wed, 7 Jul 2021 11:05:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0117.hostedemail.com [216.40.44.117]) by kanga.kvack.org (Postfix) with ESMTP id 9576F6B005D for ; Wed, 7 Jul 2021 11:05:45 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id CA59418F5D for ; Wed, 7 Jul 2021 15:05:44 +0000 (UTC) X-FDA: 78336116208.08.F0A4FD7 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by imf29.hostedemail.com (Postfix) with ESMTP id BD6319000252 for ; Wed, 7 Jul 2021 15:05:43 +0000 (UTC) Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20210707150540epoutp027407f55fd3d69907e287ac44b167dd87~Pio-dJleV1849818498epoutp026 for ; Wed, 7 Jul 2021 15:05:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20210707150540epoutp027407f55fd3d69907e287ac44b167dd87~Pio-dJleV1849818498epoutp026 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1625670341; bh=P5M8iJ0a8JoZjAfb3+Emp7S0S3yFYTSdXdTiNiKaSQ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oz2EID+NPPci3E7yui3aLjzoaF6bbmqpI6qTE2kW9akurRAH6IWDqCTZ6escq44iZ YzDNki4jFEUwgS9JDRwy+288rTLxggSTjyAyTf087P0RM2e6iF4oIcCm+pKfLkAo0p aHobp6FEF89CNS2BfMtO2jV6dB4u5BIp5Spmt4GU= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20210707150540epcas1p35127497ebc4c06bea2994816587d02b1~Pio-DHeUO2341123411epcas1p3Y; Wed, 7 Jul 2021 15:05:40 +0000 (GMT) Received: from epsmges1p5.samsung.com (unknown [182.195.40.166]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4GKjR732q2z4x9Pv; Wed, 7 Jul 2021 15:05:39 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id 77.86.09586.3C2C5E06; Thu, 8 Jul 2021 00:05:39 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20210707150538epcas1p149f866bf9b4c900a091c006df7162a23~Pio9gHBUq2525925259epcas1p1B; Wed, 7 Jul 2021 15:05:38 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210707150538epsmtrp2e431a65e97bd64b1b1f3fcdea03c8936~Pio9dxCx_0232302323epsmtrp2W; Wed, 7 Jul 2021 15:05:38 +0000 (GMT) X-AuditID: b6c32a39-86dff70000002572-ee-60e5c2c3f8b7 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id B3.E7.08394.2C2C5E06; Thu, 8 Jul 2021 00:05:38 +0900 (KST) Received: from localhost.localdomain (unknown [10.253.98.78]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210707150538epsmtip21326e8759022e7ff91c8dc79645e971f~Pio9W6_ob1222712227epsmtip2N; Wed, 7 Jul 2021 15:05:38 +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 v4 3/3] mm: sparse: remove __section_nr() function Date: Thu, 8 Jul 2021 00:02:12 +0900 Message-Id: <20210707150212.855-4-ohoono.kwon@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210707150212.855-1-ohoono.kwon@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrEKsWRmVeSWpSX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vSuX5G6VUzLUOZs6dFuE44DSizFGYmGWsxFxYkAOpX8Wb0C AAA= X-CMS-MailID: 20210707150538epcas1p149f866bf9b4c900a091c006df7162a23 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210707150538epcas1p149f866bf9b4c900a091c006df7162a23 References: <20210707150212.855-1-ohoono.kwon@samsung.com> Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=oz2EID+N; spf=pass (imf29.hostedemail.com: domain of ohoono.kwon@samsung.com designates 203.254.224.25 as permitted sender) smtp.mailfrom=ohoono.kwon@samsung.com; dmarc=pass (policy=none) header.from=samsung.com X-Stat-Signature: zy71tu6z6744apzgetcisy8q1bz17iyh X-Rspamd-Queue-Id: BD6319000252 X-Rspamd-Server: rspam06 X-HE-Tag: 1625670343-136057 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 8018ee7fcda5..d85655242ed9 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