From patchwork Fri Jul 2 09:41:30 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: 12355779 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=-19.1 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, URIBL_BLOCKED,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 31E93C11F6A for ; Fri, 2 Jul 2021 09:45:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CF4E3613EA for ; Fri, 2 Jul 2021 09:45:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CF4E3613EA 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 016D16B0036; Fri, 2 Jul 2021 05:45:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EBA068D0002; Fri, 2 Jul 2021 05:45:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B11F06B0070; Fri, 2 Jul 2021 05:45:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0118.hostedemail.com [216.40.44.118]) by kanga.kvack.org (Postfix) with ESMTP id 83EF56B006C for ; Fri, 2 Jul 2021 05:45:03 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 2651E82E071A for ; Fri, 2 Jul 2021 09:45:03 +0000 (UTC) X-FDA: 78317164086.31.D5417DD Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by imf05.hostedemail.com (Postfix) with ESMTP id 9A4585000BE1 for ; Fri, 2 Jul 2021 09:45:01 +0000 (UTC) Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20210702094458epoutp0149b456bc3b15e5c5026eca993083b65f~N8CjTFYaQ3016330163epoutp01M for ; Fri, 2 Jul 2021 09:44:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20210702094458epoutp0149b456bc3b15e5c5026eca993083b65f~N8CjTFYaQ3016330163epoutp01M DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1625219098; bh=3SZIm72kfWLDeVLOSrwDonXCeeG3xtRkK7u1eImuk7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rlpcmwxhJ8I0Ce5obaAJNzdpwd2ZoqHwpa3WwizUqniiYOZ6WWO9srm0zKpnH/PD/ ORSTTc2xTdDq0o7d1XQLEDWp5eNvdtuCqaPwKtBbMaj4a86CSC2h93K6FJk7874unH aq3ExriFDSNf4L6ZMqWwhbK2ccvJF5zKNadZLUg4= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20210702094458epcas1p18364e87630d6b7a53996a6789409d194~N8Ci_sJ2o1141111411epcas1p1z; Fri, 2 Jul 2021 09:44:58 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.40.162]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4GGVYP2R9dz4x9Pv; Fri, 2 Jul 2021 09:44:57 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 5C.C0.09952.910EED06; Fri, 2 Jul 2021 18:44:57 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p3.samsung.com (KnoxPortal) with ESMTPA id 20210702094457epcas1p3ddac76bd3cc3e5b93fadb897cdb6dfd0~N8ChxPy8x1686016860epcas1p3I; Fri, 2 Jul 2021 09:44:57 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210702094457epsmtrp141f75960be13b61325e8107b73acd749~N8Chwgqa92300123001epsmtrp1N; Fri, 2 Jul 2021 09:44:57 +0000 (GMT) X-AuditID: b6c32a35-45dff700000026e0-85-60dee019e713 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 33.E8.08394.810EED06; Fri, 2 Jul 2021 18:44:56 +0900 (KST) Received: from localhost.localdomain (unknown [10.253.98.78]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210702094456epsmtip1bf2625fe867ff34f8d2cadf461e0d9dd~N8ChjjQiA1051310513epsmtip1s; Fri, 2 Jul 2021 09:44:56 +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 1/3] mm: sparse: pass section_nr to section_mark_present Date: Fri, 2 Jul 2021 18:41:30 +0900 Message-Id: <20210702094132.6276-2-ohoono.kwon@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210702094132.6276-1-ohoono.kwon@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCKsWRmVeSWp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xXCGpXkzd79yvBUlKLMUZiYZazEXFiQA4kWtz vgIAAA== X-CMS-MailID: 20210702094457epcas1p3ddac76bd3cc3e5b93fadb897cdb6dfd0 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210702094457epcas1p3ddac76bd3cc3e5b93fadb897cdb6dfd0 References: <20210702094132.6276-1-ohoono.kwon@samsung.com> Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=rlpcmwxh; spf=pass (imf05.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: ao3qpxq477fcooty5s7jg8s78y7q1ima X-Rspamd-Queue-Id: 9A4585000BE1 X-Rspamd-Server: rspam06 X-HE-Tag: 1625219101-514944 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 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 55c18aff3e42..4a2700e9a65f 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -186,13 +186,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; } @@ -279,7 +280,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); } } } @@ -933,7 +934,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 Fri Jul 2 09:41:31 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: 12355777 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=-19.1 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, URIBL_BLOCKED,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 5C7FFC11F68 for ; Fri, 2 Jul 2021 09:45:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EEEFD60FD8 for ; Fri, 2 Jul 2021 09:45:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EEEFD60FD8 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 D0BE68D0001; Fri, 2 Jul 2021 05:45:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C96E96B006C; Fri, 2 Jul 2021 05:45:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A26018D0001; Fri, 2 Jul 2021 05:45:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0238.hostedemail.com [216.40.44.238]) by kanga.kvack.org (Postfix) with ESMTP id 6CF8F6B0011 for ; Fri, 2 Jul 2021 05:45:03 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 14CEB2775C for ; Fri, 2 Jul 2021 09:45:03 +0000 (UTC) X-FDA: 78317164086.14.B21C78D Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by imf22.hostedemail.com (Postfix) with ESMTP id 0E4F8198A for ; Fri, 2 Jul 2021 09:45:01 +0000 (UTC) Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20210702094459epoutp04e05d79bf052270646edc95a1f87abf72~N8CkEJqtv0387303873epoutp04O for ; Fri, 2 Jul 2021 09:44:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20210702094459epoutp04e05d79bf052270646edc95a1f87abf72~N8CkEJqtv0387303873epoutp04O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1625219099; bh=PZeug9R6FQNTHC+xQXAuKq+kM6dLfUDapXf6oc2oZIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bsr65edLGuEavcVjdhi1a8+O5vPFEaFyAWJHQmgz3NrLOSUeVB29fo7nIssHXWczo EBlLCvEvHZEsFr+DMDIlLVPGNWoVdnPWWyy2zbYKWYuLo7rfk/0j9q9LLsOCxeO1LA BSegCKWHI7QYkRvmHVUYJSDgoKiD+8DCU7htFd9E= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20210702094459epcas1p281aafdc9c527ddefd3ddb64ad99e0cbb~N8CjyztZ92030120301epcas1p2p; Fri, 2 Jul 2021 09:44:59 +0000 (GMT) Received: from epsmges1p4.samsung.com (unknown [182.195.40.163]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4GGVYP657Zz4x9Py; Fri, 2 Jul 2021 09:44:57 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id C9.70.10119.910EED06; Fri, 2 Jul 2021 18:44:57 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20210702094457epcas1p40fba85e22861cf1cc85a085719030c24~N8Ch0I1FG1021710217epcas1p4p; Fri, 2 Jul 2021 09:44:57 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210702094457epsmtrp21f13f7db8a4c2b91647677929a1f7b94~N8ChzU_TM0297302973epsmtrp2M; Fri, 2 Jul 2021 09:44:57 +0000 (GMT) X-AuditID: b6c32a38-965ff70000002787-51-60dee019f743 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 43.E8.08394.810EED06; Fri, 2 Jul 2021 18:44:56 +0900 (KST) Received: from localhost.localdomain (unknown [10.253.98.78]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210702094456epsmtip1f7ec03c85a419dad0e5b17fe413911c0~N8ChncmmR0979009790epsmtip1Y; Fri, 2 Jul 2021 09:44:56 +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 2/3] mm: sparse: pass section_nr to find_memory_block Date: Fri, 2 Jul 2021 18:41:31 +0900 Message-Id: <20210702094132.6276-3-ohoono.kwon@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210702094132.6276-1-ohoono.kwon@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMKsWRmVeSWpSXmKPExsWy7bCmvq7kg3sJBhOu6FnMWb+GzeL8g19s Fl/X/2K2uLxrDpvFvTX/WS3u9zlY7N3va7Hr5wpmixtTGtgcOD12zrrL7rHp0yR2jxMzfrN4 TFh0gNHj/b6rbB59W1YxeqzfcpXF4/MmuQCOqBybjNTElNQihdS85PyUzLx0WyXv4HjneFMz A0NdQ0sLcyWFvMTcVFslF58AXbfMHKDrlBTKEnNKgUIBicXFSvp2NkX5pSWpChn5xSW2SqkF KTkFhgYFesWJucWleel6yfm5VoYGBkamQJUJORnn1gYUbBer2Db1OXsDY6twFyMnh4SAiUT/ hpPMXYxcHEICOxglZu9bzgKSEBL4xChxt7sGIvGNUeLg0oNsMB3dt+4xQiT2Mkr87LvHBuEA dWx/voERpIpNQFtif+8JZhBbRCBaYvbVDiYQm1mgQKKh/xPYCmEBV4nVM3aC2SwCqhLPnk1g BbF5Bawlfj78D7VNXmL1hgNgczgFbCROdO5lBVkmIfCSXeLs9k2MEEUuElf7Z0HZwhKvjm9h h7ClJD6/28sG0dDPKHGobztU9wRGifVdjUBVHECOvcT7SxYgJrOApsT6XfoQvYoSO3/PZYQ4 mk/i3dceVohqXomONiEIU1Vi2W8PiGppib7pl6FO9pBY9esxNICAtv5f2sk8gVFuFsKCBYyM qxjFUguKc9NTiw0LTJAjbBMjOPVpWexgn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KdXAlL9PkGPBhOcrv8ncZz21sJzt 3+KLz/eni0e8SUjatWy66umMPW4qfPKcRz6vzPnAP1nn+E+ztJgL836bnLf15FzNLfhw4jq1 9b5b4izMnGbe414ot9zk+PJzG3U+tfjp6Ww9ssT1y6KJy29L61l0OXzl0p0TFMca1Fp9QuqU UqXUx78eelI3rDSFeN7X3C18yHnqmeiCTftvBrb++ZSX8n3yooBrn+f3r3Ja6O88NWyr2auV m+Xjwz3jP5Qw/3bmdnnyKqBRiOO7lxl7+rVTdf7tLZd/+vZ5Zs790lgormH90n/ztaXHjP68 KV7m3OhjZWM201vJxK5v5e3wJe/rBCR/3noUP0HOaOWWpnMh3UosxRmJhlrMRcWJANc2qL2+ AgAA X-CMS-MailID: 20210702094457epcas1p40fba85e22861cf1cc85a085719030c24 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210702094457epcas1p40fba85e22861cf1cc85a085719030c24 References: <20210702094132.6276-1-ohoono.kwon@samsung.com> Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=bsr65edL; spf=pass (imf22.hostedemail.com: domain of ohoono.kwon@samsung.com designates 203.254.224.34 as permitted sender) smtp.mailfrom=ohoono.kwon@samsung.com; dmarc=pass (policy=none) header.from=samsung.com X-Stat-Signature: mj1crarbbyimq8zmnoifgyjdioxzyohz X-Rspamd-Queue-Id: 0E4F8198A X-Rspamd-Server: rspam06 X-HE-Tag: 1625219101-741638 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 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 8377f1f7c78e..905790092e0e 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 Fri Jul 2 09:41:32 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: 12355773 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=-19.1 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, URIBL_BLOCKED,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 A0589C11F68 for ; Fri, 2 Jul 2021 09:45:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 36E9F60FD8 for ; Fri, 2 Jul 2021 09:45:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36E9F60FD8 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 7E5876B005D; Fri, 2 Jul 2021 05:45:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7DBC66B0036; Fri, 2 Jul 2021 05:45:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5BAC36B006C; Fri, 2 Jul 2021 05:45:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0104.hostedemail.com [216.40.44.104]) by kanga.kvack.org (Postfix) with ESMTP id 3A5BE6B0011 for ; Fri, 2 Jul 2021 05:45:03 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D05DF18211CCC for ; Fri, 2 Jul 2021 09:45:02 +0000 (UTC) X-FDA: 78317164044.26.AE7D505 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by imf28.hostedemail.com (Postfix) with ESMTP id D8CD8900009F for ; Fri, 2 Jul 2021 09:45:01 +0000 (UTC) Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20210702094459epoutp04641e3799a4c69bc420db92cbc21e6263~N8CjvpUlj0387303873epoutp04N for ; Fri, 2 Jul 2021 09:44:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20210702094459epoutp04641e3799a4c69bc420db92cbc21e6263~N8CjvpUlj0387303873epoutp04N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1625219099; bh=q1Bo5tHP3Pm++tV7Sf0f+PhSILKdUAIb8tIn5N0cOf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cTBImMNZ1ohhSINerQWp27FoT8qyP8Gs44cyJ8YjV429xAnauoGbQEGJxwVm10KSw CIBb3aGKbQ52zXkpNgqRId22Hd48po6BRNhlW8vnR+cyeVTI5xusq8mIZq9Nq+A+ef msVrfevIsqn/EDhK+AKH2nDjAjDqWyfiN1Q5qfUg= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20210702094458epcas1p2d95e8fc80c3ba68340e069f241dcdc4d~N8CjcCpJf0305903059epcas1p27; Fri, 2 Jul 2021 09:44:58 +0000 (GMT) Received: from epsmges1p3.samsung.com (unknown [182.195.40.165]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4GGVYP6kRNz4x9Q7; Fri, 2 Jul 2021 09:44:57 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p3.samsung.com (Symantec Messaging Gateway) with SMTP id 54.44.09468.910EED06; Fri, 2 Jul 2021 18:44:57 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20210702094457epcas1p4e181c7b0a18338403a7ffb57f44807fe~N8Ch5Y8_I1021710217epcas1p4q; Fri, 2 Jul 2021 09:44:57 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210702094457epsmtrp1790de2480197cb01e08ee6d78fb6b37f~N8Ch4l_Sp2300123001epsmtrp1P; Fri, 2 Jul 2021 09:44:57 +0000 (GMT) X-AuditID: b6c32a37-0b1ff700000024fc-7c-60dee0193921 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E3.E8.08394.910EED06; Fri, 2 Jul 2021 18:44:57 +0900 (KST) Received: from localhost.localdomain (unknown [10.253.98.78]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20210702094456epsmtip164eeec37388c6e6e0f19a267e7bfcb19~N8Chrfzhr1051310513epsmtip1t; Fri, 2 Jul 2021 09:44:56 +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 3/3] mm: sparse: remove __section_nr() function Date: Fri, 2 Jul 2021 18:41:32 +0900 Message-Id: <20210702094132.6276-4-ohoono.kwon@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210702094132.6276-1-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sqzngrwSo6Ob UesVlxc/Us6/kvusmbE/JExEIPMvz/dd7ceWXPJ7eS300L7XGe8uKLEUZyQaajEXFScCAMMB eGO+AgAA X-CMS-MailID: 20210702094457epcas1p4e181c7b0a18338403a7ffb57f44807fe X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210702094457epcas1p4e181c7b0a18338403a7ffb57f44807fe References: <20210702094132.6276-1-ohoono.kwon@samsung.com> Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=cTBImMNZ; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf28.hostedemail.com: domain of ohoono.kwon@samsung.com designates 203.254.224.34 as permitted sender) smtp.mailfrom=ohoono.kwon@samsung.com X-Stat-Signature: 9des45jdbb7f15txdomppch6b6if7f3r X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D8CD8900009F X-HE-Tag: 1625219101-578153 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: __section_nr() was used to convert struct mem_section * to section_nr. With CONFIG_SPARSEMEM_EXTREME enabled, however, __section_nr() can 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). The only users of __section_nr() was section_mark_present() and find_memory_block(). Since I changed both functions to use section_nr directly in the preceeding patches, let's remove __section_nr() which has no users. Signed-off-by: Ohhoon Kwon Acked-by: Michal Hocko 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 0d53eba1c383..8931f95cf885 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1321,7 +1321,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 4a2700e9a65f..1b32d15593e4 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -108,32 +108,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