From patchwork Wed Jul 7 13:14:43 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: 12362631 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 9F2D4C07E9B for ; Wed, 7 Jul 2021 13:18:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 31D8761A2B for ; Wed, 7 Jul 2021 13:18:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31D8761A2B 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 CC9266B0036; Wed, 7 Jul 2021 09:18:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C534B6B005D; Wed, 7 Jul 2021 09:18:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA55C6B006C; Wed, 7 Jul 2021 09:18:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0198.hostedemail.com [216.40.44.198]) by kanga.kvack.org (Postfix) with ESMTP id 863CA6B0036 for ; Wed, 7 Jul 2021 09:18:48 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id CEBA61807F65B for ; Wed, 7 Jul 2021 13:18:47 +0000 (UTC) X-FDA: 78335846694.29.6E867D6 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by imf01.hostedemail.com (Postfix) with ESMTP id A94875006097 for ; Wed, 7 Jul 2021 13:18:46 +0000 (UTC) Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20210707131843epoutp03c7d752010ec152c759cf87e96ddaaded~PhLmyFUsj0974209742epoutp03K for ; Wed, 7 Jul 2021 13:18:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20210707131843epoutp03c7d752010ec152c759cf87e96ddaaded~PhLmyFUsj0974209742epoutp03K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1625663923; bh=rjLVc5Pk7mEfS5QJsbX09lDUXd0mFsvlZisGIyejgVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=laCqJy/7OOmoasl+F2BV5g9Mesa48lbVO1D7ZC/Gj4XaWUY2nsi6gKgwWAL8bEuef CfG6pgoA2ACs9voy2kH482URfHqVecc0SqQWMUNUEkctoZwPQQ+Uo2bQwab86TZI19 41jBl3aoMheKfBRkA+scqj+P2qLSfVPcz1L2G0Qs= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20210707131843epcas1p4c49d010c9b1244e466218b1c655343b7~PhLmZx1QF0134701347epcas1p4B; Wed, 7 Jul 2021 13:18:43 +0000 (GMT) Received: from epsmges1p4.samsung.com (unknown [182.195.40.161]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4GKg3k1r9pz4x9Pv; Wed, 7 Jul 2021 13:18:42 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id C4.D8.10119.2B9A5E06; Wed, 7 Jul 2021 22:18:42 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20210707131841epcas1p129d1c10efdbbe403e80f45245b0b5afd~PhLlJjxy21869818698epcas1p1k; Wed, 7 Jul 2021 13:18:41 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210707131841epsmtrp1a4aa7983947469a7278fbf25f01564dd~PhLlIydgd1302713027epsmtrp1B; Wed, 7 Jul 2021 13:18:41 +0000 (GMT) X-AuditID: b6c32a38-965ff70000002787-3d-60e5a9b28c8d Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id AF.36.08289.1B9A5E06; Wed, 7 Jul 2021 22:18:41 +0900 (KST) Received: from localhost.localdomain (unknown [10.253.98.78]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210707131841epsmtip2f9cf584be63033435fbada1bdfede54a~PhLk6i74G2143921439epsmtip29; Wed, 7 Jul 2021 13:18:41 +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 v3 1/1] mm: sparse: pass section_nr to section_mark_present Date: Wed, 7 Jul 2021 22:14:43 +0900 Message-Id: <20210707131443.6242-2-ohoono.kwon@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210707131443.6242-1-ohoono.kwon@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCKsWRmVeSWpSXmKPExsWy7bCmvu6m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RmJhlrMRcWJABtZ CbK+AgAA X-CMS-MailID: 20210707131841epcas1p129d1c10efdbbe403e80f45245b0b5afd X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210707131841epcas1p129d1c10efdbbe403e80f45245b0b5afd References: <20210707131443.6242-1-ohoono.kwon@samsung.com> Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b="laCqJy/7"; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf01.hostedemail.com: domain of ohoono.kwon@samsung.com designates 203.254.224.33 as permitted sender) smtp.mailfrom=ohoono.kwon@samsung.com X-Rspamd-Server: rspam02 X-Stat-Signature: 18koq5djy3ajqdsim4qdp7dikdot9deh X-Rspamd-Queue-Id: A94875006097 X-HE-Tag: 1625663926-412680 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 Reviewed-by: David Hildenbrand Acked-by: Michal Hocko --- 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)