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.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 06EC0C43460 for ; Mon, 26 Apr 2021 06:18:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 64259611CC for ; Mon, 26 Apr 2021 06:18:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 64259611CC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D300A6B006C; Mon, 26 Apr 2021 02:18:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CE1156B006E; Mon, 26 Apr 2021 02:18:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA9786B0070; Mon, 26 Apr 2021 02:18:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0208.hostedemail.com [216.40.44.208]) by kanga.kvack.org (Postfix) with ESMTP id A0D0A6B006C for ; Mon, 26 Apr 2021 02:18:36 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4F8832484 for ; Mon, 26 Apr 2021 06:18:36 +0000 (UTC) X-FDA: 78073514232.11.2989CEF Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf04.hostedemail.com (Postfix) with ESMTP id 77D4C12E for ; Mon, 26 Apr 2021 06:18:32 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CB11131B; Sun, 25 Apr 2021 23:18:34 -0700 (PDT) Received: from [10.163.75.66] (unknown [10.163.75.66]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7BA993F70D; Sun, 25 Apr 2021 23:18:32 -0700 (PDT) Subject: Re: [PATCH 2/2] mm/mmzone.h: simplify is_highmem_idx() To: Mike Rapoport , Andrew Morton Cc: Jonathan Corbet , Mike Rapoport , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20210423203811.1247508-1-rppt@kernel.org> <20210423203811.1247508-3-rppt@kernel.org> From: Anshuman Khandual Message-ID: Date: Mon, 26 Apr 2021 11:49:25 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210423203811.1247508-3-rppt@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 77D4C12E X-Stat-Signature: rhh7u88se9xqw9azdwjyd6sakmqbuffz Received-SPF: none (arm.com>: No applicable sender policy available) receiver=imf04; identity=mailfrom; envelope-from=""; helo=foss.arm.com; client-ip=217.140.110.172 X-HE-DKIM-Result: none/none X-HE-Tag: 1619417912-489322 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 4/24/21 2:08 AM, Mike Rapoport wrote: > From: Mike Rapoport > > There is a lot of historical ifdefery in is_highmem_idx() and its helper > zone_movable_is_highmem() that was required because of two different paths > for nodes and zones initialization that were selected at compile time. > > Until commit 3f08a302f533 ("mm: remove CONFIG_HAVE_MEMBLOCK_NODE_MAP > option") the movable_zone variable was only available for configurations > that had CONFIG_HAVE_MEMBLOCK_NODE_MAP enabled so the test in > zone_movable_is_highmem() used that variable only for such configurations. > For other configurations the test checked if the index of ZONE_MOVABLE was > greater by 1 than the index of ZONE_HIGMEM and then movable zone was > considered a highmem zone. Needless to say, ZONE_MOVABLE - 1 equals > ZONE_HIGMEM by definition when CONFIG_HIGHMEM=y. Right with CONFIG_HIGHMEM is enabled, ZONE_MOVABLE = ZONE_HIGHMEM + 1 holds always true from the very definition in enum zone_type { }. > > Commit 3f08a302f533 ("mm: remove CONFIG_HAVE_MEMBLOCK_NODE_MAP option") > made movable_zone variable always available. Since this variable is set to > ZONE_HIGHMEM if CONFIG_HIGHMEM is enabled and highmem zone is populated, it > is enough to check whether > > zone_idx == ZONE_MOVABLE && movable_zone == ZONE_HIGMEM Right. A small nit. s/HIGMEM/HIGHMEM > > to test if zone index points to a highmem zone. If the CONFIG_HIGHMEM is enabled but ZONE_HIGHMEM is not populated, then movable_node would point to a zone below ZONE_HIGHMEM and is_highmem_idx() would also return false. > > Remove zone_movable_is_highmem() that is not used anywhere except > is_highmem_idx() and use the test above in is_highmem_idx() instead. > > Signed-off-by: Mike Rapoport > --- > include/linux/mmzone.h | 13 +------------ > 1 file changed, 1 insertion(+), 12 deletions(-) > > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h > index 3b2205741048..6a1ac643b65e 100644 > --- a/include/linux/mmzone.h > +++ b/include/linux/mmzone.h > @@ -968,22 +968,11 @@ static inline void zone_set_nid(struct zone *zone, int nid) {} > > extern int movable_zone; > > -#ifdef CONFIG_HIGHMEM > -static inline int zone_movable_is_highmem(void) > -{ > -#ifdef CONFIG_NEED_MULTIPLE_NODES > - return movable_zone == ZONE_HIGHMEM; > -#else > - return (ZONE_MOVABLE - 1) == ZONE_HIGHMEM; > -#endif > -} > -#endif > - > static inline int is_highmem_idx(enum zone_type idx) > { > #ifdef CONFIG_HIGHMEM > return (idx == ZONE_HIGHMEM || > - (idx == ZONE_MOVABLE && zone_movable_is_highmem())); > + (idx == ZONE_MOVABLE && movable_zone == ZONE_HIGHMEM)); > #else > return 0; > #endif > LGTM. Reviewed-by: Anshuman Khandual