From mboxrd@z Thu Jan 1 00:00:00 1970 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=-15.8 required=3.0 tests=BAYES_00,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 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 6ADB3C11F68 for ; Fri, 2 Jul 2021 12:18:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DEEED61423 for ; Fri, 2 Jul 2021 12:18:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DEEED61423 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7AEE56B0011; Fri, 2 Jul 2021 08:18:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 786436B005D; Fri, 2 Jul 2021 08:18:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6273D6B006C; Fri, 2 Jul 2021 08:18:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0091.hostedemail.com [216.40.44.91]) by kanga.kvack.org (Postfix) with ESMTP id 3EC856B0011 for ; Fri, 2 Jul 2021 08:18:41 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E333C252DF for ; Fri, 2 Jul 2021 12:18:40 +0000 (UTC) X-FDA: 78317551200.27.A1ADC64 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf19.hostedemail.com (Postfix) with ESMTP id 84E0FB0000A3 for ; Fri, 2 Jul 2021 12:18:40 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 5A5C422989; Fri, 2 Jul 2021 12:18:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1625228319; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tafCEo0yQeDqyI1Ey6/WGCSopcKZ7s02+Wi5y5dZTAI=; b=FnKWHedlFVULx5aCP3jFRg0wcDsQg6Sa2NPo83SBoHS3qwD+LLXeOq3SnfMF1eCNjuV97k fVxwYj/dP16vUi3TF5j0zB0RW5Qb3UNVX7oJqZl+UrtW6MmTps7BCRz73hmjet5ahHseOd JA9VSlhXs5nX9X3TciS1lpWP0DboDq4= Received: from suse.cz (unknown [10.100.201.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id A62DBA3B83; Fri, 2 Jul 2021 12:18:38 +0000 (UTC) Date: Fri, 2 Jul 2021 14:18:37 +0200 From: Michal Hocko To: Ohhoon Kwon Cc: david@redhat.com, akpm@linux-foundation.org, bhe@redhat.com, rppt@linux.ibm.com, ohkwon1043@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] mm: sparse: remove __section_nr() function Message-ID: References: <20210702094132.6276-1-ohoono.kwon@samsung.com> <20210702094132.6276-4-ohoono.kwon@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210702094132.6276-4-ohoono.kwon@samsung.com> Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=FnKWHedl; spf=pass (imf19.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.28 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 84E0FB0000A3 X-Stat-Signature: 3zsekc3okmisw8uuxjjisyokhiprfwfa X-HE-Tag: 1625228320-537487 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: On Fri 02-07-21 18:41:32, Ohhoon Kwon wrote: > __section_nr() was used to convert struct mem_section * to section_nr. > > With CONFIG_SPARSEMEM_EXTREME enabled, however, __section_nr() can 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). > > The only users of __section_nr() was section_mark_present() and > find_memory_block(). > > Since I changed both functions to use section_nr directly in the > preceeding patches, let's remove __section_nr() which has no users. > > Signed-off-by: Ohhoon Kwon I would go with a much shorter changelog. The function is not used anymore so it can be simply dropped. Acked-by: Michal Hocko > --- > include/linux/mmzone.h | 1 - > mm/sparse.c | 26 -------------------------- > 2 files changed, 27 deletions(-) > > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h > index 0d53eba1c383..8931f95cf885 100644 > --- a/include/linux/mmzone.h > +++ b/include/linux/mmzone.h > @@ -1321,7 +1321,6 @@ static inline struct mem_section *__nr_to_section(unsigned long nr) > return NULL; > return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK]; > } > -extern unsigned long __section_nr(struct mem_section *ms); > extern size_t mem_section_usage_size(void); > > /* > diff --git a/mm/sparse.c b/mm/sparse.c > index 4a2700e9a65f..1b32d15593e4 100644 > --- a/mm/sparse.c > +++ b/mm/sparse.c > @@ -108,32 +108,6 @@ static inline int sparse_index_init(unsigned long section_nr, int nid) > } > #endif > > -#ifdef CONFIG_SPARSEMEM_EXTREME > -unsigned long __section_nr(struct mem_section *ms) > -{ > - unsigned long root_nr; > - struct mem_section *root = NULL; > - > - for (root_nr = 0; root_nr < NR_SECTION_ROOTS; root_nr++) { > - root = __nr_to_section(root_nr * SECTIONS_PER_ROOT); > - if (!root) > - continue; > - > - if ((ms >= root) && (ms < (root + SECTIONS_PER_ROOT))) > - break; > - } > - > - VM_BUG_ON(!root); > - > - return (root_nr * SECTIONS_PER_ROOT) + (ms - root); > -} > -#else > -unsigned long __section_nr(struct mem_section *ms) > -{ > - return (unsigned long)(ms - mem_section[0]); > -} > -#endif > - > /* > * During early boot, before section_mem_map is used for an actual > * mem_map, we use section_mem_map to store the section's NUMA > -- > 2.17.1 -- Michal Hocko SUSE Labs