From patchwork Fri Jul 2 09:41:31 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: 12355777 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 5C7FFC11F68 for ; Fri, 2 Jul 2021 09:45:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EEEFD60FD8 for ; Fri, 2 Jul 2021 09:45:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EEEFD60FD8 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 D0BE68D0001; Fri, 2 Jul 2021 05:45:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C96E96B006C; 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 A26018D0001; Fri, 2 Jul 2021 05:45:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0238.hostedemail.com [216.40.44.238]) by kanga.kvack.org (Postfix) with ESMTP id 6CF8F6B0011 for ; Fri, 2 Jul 2021 05:45:03 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 14CEB2775C for ; Fri, 2 Jul 2021 09:45:03 +0000 (UTC) X-FDA: 78317164086.14.B21C78D Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by imf22.hostedemail.com (Postfix) with ESMTP id 0E4F8198A for ; Fri, 2 Jul 2021 09:45:01 +0000 (UTC) Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20210702094459epoutp04e05d79bf052270646edc95a1f87abf72~N8CkEJqtv0387303873epoutp04O for ; Fri, 2 Jul 2021 09:44:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20210702094459epoutp04e05d79bf052270646edc95a1f87abf72~N8CkEJqtv0387303873epoutp04O DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1625219099; bh=PZeug9R6FQNTHC+xQXAuKq+kM6dLfUDapXf6oc2oZIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bsr65edLGuEavcVjdhi1a8+O5vPFEaFyAWJHQmgz3NrLOSUeVB29fo7nIssHXWczo EBlLCvEvHZEsFr+DMDIlLVPGNWoVdnPWWyy2zbYKWYuLo7rfk/0j9q9LLsOCxeO1LA BSegCKWHI7QYkRvmHVUYJSDgoKiD+8DCU7htFd9E= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20210702094459epcas1p281aafdc9c527ddefd3ddb64ad99e0cbb~N8CjyztZ92030120301epcas1p2p; Fri, 2 Jul 2021 09:44:59 +0000 (GMT) Received: from epsmges1p4.samsung.com (unknown [182.195.40.163]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4GGVYP657Zz4x9Py; Fri, 2 Jul 2021 09:44:57 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id C9.70.10119.910EED06; Fri, 2 Jul 2021 18:44:57 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p4.samsung.com (KnoxPortal) with ESMTPA id 20210702094457epcas1p40fba85e22861cf1cc85a085719030c24~N8Ch0I1FG1021710217epcas1p4p; Fri, 2 Jul 2021 09:44:57 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20210702094457epsmtrp21f13f7db8a4c2b91647677929a1f7b94~N8ChzU_TM0297302973epsmtrp2M; Fri, 2 Jul 2021 09:44:57 +0000 (GMT) X-AuditID: b6c32a38-965ff70000002787-51-60dee019f743 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 43.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 20210702094456epsmtip1f7ec03c85a419dad0e5b17fe413911c0~N8ChncmmR0979009790epsmtip1Y; 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 2/3] mm: sparse: pass section_nr to find_memory_block Date: Fri, 2 Jul 2021 18:41:31 +0900 Message-Id: <20210702094132.6276-3-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+NgFvrMKsWRmVeSWpSXm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3UosxRmJhlrMRcWJANc2qL2+ AgAA X-CMS-MailID: 20210702094457epcas1p40fba85e22861cf1cc85a085719030c24 X-Msg-Generator: CA X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210702094457epcas1p40fba85e22861cf1cc85a085719030c24 References: <20210702094132.6276-1-ohoono.kwon@samsung.com> Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=samsung.com header.s=mail20170921 header.b=bsr65edL; spf=pass (imf22.hostedemail.com: domain of ohoono.kwon@samsung.com designates 203.254.224.34 as permitted sender) smtp.mailfrom=ohoono.kwon@samsung.com; dmarc=pass (policy=none) header.from=samsung.com X-Stat-Signature: mj1crarbbyimq8zmnoifgyjdioxzyohz X-Rspamd-Queue-Id: 0E4F8198A X-Rspamd-Server: rspam06 X-HE-Tag: 1625219101-741638 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 find_memory_block() in order to reduce needless iterations. Signed-off-by: Ohhoon Kwon Acked-by: Michal Hocko Reviewed-by: David Hildenbrand --- arch/powerpc/platforms/pseries/hotplug-memory.c | 4 +--- drivers/base/memory.c | 4 ++-- include/linux/memory.h | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c index 8377f1f7c78e..905790092e0e 100644 --- a/arch/powerpc/platforms/pseries/hotplug-memory.c +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c @@ -211,13 +211,11 @@ static int update_lmb_associativity_index(struct drmem_lmb *lmb) static struct memory_block *lmb_to_memblock(struct drmem_lmb *lmb) { unsigned long section_nr; - struct mem_section *mem_sect; struct memory_block *mem_block; section_nr = pfn_to_section_nr(PFN_DOWN(lmb->base_addr)); - mem_sect = __nr_to_section(section_nr); - mem_block = find_memory_block(mem_sect); + mem_block = find_memory_block(section_nr); return mem_block; } diff --git a/drivers/base/memory.c b/drivers/base/memory.c index d5ffaab3cb61..e31598955cc4 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -578,9 +578,9 @@ static struct memory_block *find_memory_block_by_id(unsigned long block_id) /* * Called under device_hotplug_lock. */ -struct memory_block *find_memory_block(struct mem_section *section) +struct memory_block *find_memory_block(unsigned long section_nr) { - unsigned long block_id = memory_block_id(__section_nr(section)); + unsigned long block_id = memory_block_id(section_nr); return find_memory_block_by_id(block_id); } diff --git a/include/linux/memory.h b/include/linux/memory.h index 97e92e8b556a..d9a0b61cd432 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -90,7 +90,7 @@ int create_memory_block_devices(unsigned long start, unsigned long size, void remove_memory_block_devices(unsigned long start, unsigned long size); extern void memory_dev_init(void); extern int memory_notify(unsigned long val, void *v); -extern struct memory_block *find_memory_block(struct mem_section *); +extern struct memory_block *find_memory_block(unsigned long section_nr); typedef int (*walk_memory_blocks_func_t)(struct memory_block *, void *); extern int walk_memory_blocks(unsigned long start, unsigned long size, void *arg, walk_memory_blocks_func_t func);