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)