From patchwork Wed Jul 7 15:02:10 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: 12362761 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 C576DC07E9E for ; Wed, 7 Jul 2021 15:05:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 68BED61CC6 for ; Wed, 7 Jul 2021 15:05:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68BED61CC6 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 ADAB06B006C; Wed, 7 Jul 2021 11:05:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC0B86B0070; Wed, 7 Jul 2021 11:05:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 903976B0070; Wed, 7 Jul 2021 11:05:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0063.hostedemail.com [216.40.44.63]) by kanga.kvack.org (Postfix) with ESMTP id 701BD6B005D for ; Wed, 7 Jul 2021 11:05:45 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id CE0771944E for ; Wed, 7 Jul 2021 15:05:44 +0000 (UTC) X-FDA: 78336116208.18.397C60F Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by imf05.hostedemail.com (Postfix) with ESMTP id C7A485006090 for ; Wed, 7 Jul 2021 15:05:43 +0000 (UTC) Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20210707150540epoutp02fa48dedfd364ac260f8e6291377417db~Pio-ZjbGw1863918639epoutp020 for ; Wed, 7 Jul 2021 15:05:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20210707150540epoutp02fa48dedfd364ac260f8e6291377417db~Pio-ZjbGw1863918639epoutp020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1625670340; bh=vie/MD3bp15OOdNkmszQP60mktTrs2rhI3koi1uWjBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CVrQDKgSdAUi/LvubJpSOWLmBcpQlAfWLV6TD5iyos4kDRlWl3aMAGyfFzMnAFKEF LdTyFRS6q4M23DE1z0XyBig8ePZxd0RGpBFY4xGrBQJsbt6MKhT9EMr1Q6OHaIrAe+ U7K1hm626wOmJUrymDQfw1eGL8WRkaBYKfIf3/14= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20210707150540epcas1p12159d4c80c6fd1eb77d57e7c0ac17c60~Pio-HL-ts0349803498epcas1p1J; Wed, 7 Jul 2021 15:05:40 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.40.161]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4GKjR73wgKz4x9Pw; Wed, 7 Jul 2021 15:05:39 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 2C.01.09952.3C2C5E06; Thu, 8 Jul 2021 00:05:39 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20210707150538epcas1p4b893d4fcd9eab24e4e06714efc24299e~Pio9awENd2640426404epcas1p4B; Wed, 7 Jul 2021 15:05:38 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210707150538epsmtrp112acc4da4fe30925052138cfe2657ff4~Pio9ZgyOu3041830418epsmtrp1i; Wed, 7 Jul 2021 15:05:38 +0000 (GMT) X-AuditID: b6c32a35-45dff700000026e0-f1-60e5c2c31ee1 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 3E.19.08289.2C2C5E06; Thu, 8 Jul 2021 00:05:38 +0900 (KST) Received: from localhost.localdomain (unknown [10.253.98.78]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210707150538epsmtip256ce86beebcb9af87f2e14b30de15558~Pio9Rfqqg0193201932epsmtip2V; Wed, 7 Jul 2021 15:05:38 +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 v4 1/3] mm: sparse: pass section_nr to section_mark_present Date: Thu, 8 Jul 2021 00:02:10 +0900 Message-Id: <20210707150212.855-2-ohoono.kwon@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210707150212.855-1-ohoono.kwon@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKKsWRmVeSWpSXmKPExsWy7bCmge7h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kQA0Z/A zb4CAAA= X-CMS-MailID: 20210707150538epcas1p4b893d4fcd9eab24e4e06714efc24299e X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210707150538epcas1p4b893d4fcd9eab24e4e06714efc24299e References: <20210707150212.855-1-ohoono.kwon@samsung.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C7A485006090 X-Stat-Signature: sp891u96aueiwonsp3s64sk7bx1kwpti Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=CVrQDKgS; dmarc=pass (policy=none) header.from=samsung.com; spf=pass (imf05.hostedemail.com: domain of ohoono.kwon@samsung.com designates 203.254.224.25 as permitted sender) smtp.mailfrom=ohoono.kwon@samsung.com X-HE-Tag: 1625670343-876084 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 Acked-by: Michal Hocko Reviewed-by: David Hildenbrand --- 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)