Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3996420imm; Mon, 30 Jul 2018 07:02:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc/VfQfdadyt0xDbDJDcGfkvL/TDYJzx92UcfAvqZvQl2chfF5iBMtURfNXl74FDVhPPSyS X-Received: by 2002:a17:902:6b4c:: with SMTP id g12-v6mr16350824plt.159.1532959353511; Mon, 30 Jul 2018 07:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532959353; cv=none; d=google.com; s=arc-20160816; b=bWFHWXEGgEo0GACIaNtq+lBzLSvyJlA509HrAIokhSVsC/F4FQMRWb4trjwsHC8L3E DWCt560jFybk00+W8nrNNnZvOQdwcoZFeSDampHL1EUHVy7Uqfoh5OyEZCn6TRr39ADf TOFJh6NWtKtExixycX3XIjiANP5UoiMiI6MEtd0dplfRoVuznTNpx1mpnKr1w6kVKEpX qm8AJU0KF7hJHBj2Fhg60BBpFBw03usGqAOGl2PxJ5ErgCBNgSEh63wqQ1LnYwu8WKVn eU5GyP/wPufs2bRHpbZ4KdepvBLkom1LhlA7aJ2lir3KOiReuvhTsSZAUjIDYs5N+uSp Gu3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=zR6KTvN9ugoUaR1nMZwalBBksSwWRJzrGHaq7fj4AZU=; b=tNYsfgmvWFUAhtZCA3gCLL6xuu23O67klTAAz9zyWyXxITRSZeZAjAEUzU+3epnH+A UDi8XLGYA6xEY42GbxxA//sgVMr41DXQZNrntJW4MLucYbeqX0uUmCtE3TBWs4ELNWo2 IIDzxzk2Ws9kMTCrmNpRs6CxyHvMBZw8PIL85iPbtLRMC4QPSn998phlo2iPAcqVHbrQ m3AkPO0DIGdODhASbqdpqfPU9FKWyvpEU3w3YopxF1N0oWRVuUBmoB4xdk9R4DDMYPte 9yR13TI5ZsbNhvK5pq/Bz+E0WY8li9PLyxnwslYKXjZWxXGodoha5gHGQrTVt1+dVy0A P0EQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n2-v6si11149131pge.74.2018.07.30.07.02.18; Mon, 30 Jul 2018 07:02:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730797AbeG3PgL (ORCPT + 99 others); Mon, 30 Jul 2018 11:36:11 -0400 Received: from mx2.suse.de ([195.135.220.15]:33122 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730790AbeG3PgL (ORCPT ); Mon, 30 Jul 2018 11:36:11 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 5ABD5AE5B; Mon, 30 Jul 2018 14:01:01 +0000 (UTC) Date: Mon, 30 Jul 2018 16:00:59 +0200 From: Michal Hocko To: osalvador@techadventures.net Cc: akpm@linux-foundation.org, vbabka@suse.cz, sfr@canb.auug.org.au, rientjes@google.com, pasha.tatashin@oracle.com, kemi.wang@intel.com, jia.he@hxt-semitech.com, ptesarik@suse.com, aryabinin@virtuozzo.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, dan.j.williams@intel.com, Oscar Salvador Subject: Re: [PATCH] mm: Remove zone_id() and make use of zone_idx() in is_dev_zone() Message-ID: <20180730140059.GU24267@dhcp22.suse.cz> References: <20180730133718.28683-1-osalvador@techadventures.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180730133718.28683-1-osalvador@techadventures.net> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 30-07-18 15:37:18, osalvador@techadventures.net wrote: > From: Oscar Salvador > > is_dev_zone() is using zone_id() to check if the zone is ZONE_DEVICE. > zone_id() looks pretty much the same as zone_idx(), and while the use of > zone_idx() is quite spread in the kernel, zone_id() is only being > used by is_dev_zone(). > > This patch removes zone_id() and makes is_dev_zone() use zone_idx() > to check the zone, so we do not have two things with the same > functionality around. Yes this looks like a pointless code duplication. I guess Dan just wasn't aware of zone_idx() macro. > Signed-off-by: Oscar Salvador Acked-by: Michal Hocko > --- > include/linux/mmzone.h | 31 ++++++++++++------------------- > 1 file changed, 12 insertions(+), 19 deletions(-) > > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h > index 83b1d11e90eb..dbe7635c33dd 100644 > --- a/include/linux/mmzone.h > +++ b/include/linux/mmzone.h > @@ -755,25 +755,6 @@ static inline bool pgdat_is_empty(pg_data_t *pgdat) > return !pgdat->node_start_pfn && !pgdat->node_spanned_pages; > } > > -static inline int zone_id(const struct zone *zone) > -{ > - struct pglist_data *pgdat = zone->zone_pgdat; > - > - return zone - pgdat->node_zones; > -} > - > -#ifdef CONFIG_ZONE_DEVICE > -static inline bool is_dev_zone(const struct zone *zone) > -{ > - return zone_id(zone) == ZONE_DEVICE; > -} > -#else > -static inline bool is_dev_zone(const struct zone *zone) > -{ > - return false; > -} > -#endif > - > #include > > void build_all_zonelists(pg_data_t *pgdat); > @@ -824,6 +805,18 @@ static inline int local_memory_node(int node_id) { return node_id; }; > */ > #define zone_idx(zone) ((zone) - (zone)->zone_pgdat->node_zones) > > +#ifdef CONFIG_ZONE_DEVICE > +static inline bool is_dev_zone(const struct zone *zone) > +{ > + return zone_idx(zone) == ZONE_DEVICE; > +} > +#else > +static inline bool is_dev_zone(const struct zone *zone) > +{ > + return false; > +} > +#endif > + > /* > * Returns true if a zone has pages managed by the buddy allocator. > * All the reclaim decisions have to use this function rather than > -- > 2.13.6 > -- Michal Hocko SUSE Labs