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-ohoono.kwon@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvr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PJ7eS300L7XGe8uKLEUZyQaajEXFScCAMMB 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