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)