Received: by 10.192.165.148 with SMTP id m20csp53022imm; Fri, 4 May 2018 06:36:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrBogTJ2ktQEHK82Ugu5RNPZBs+VZSfK2brYX+UL4OgWXRVhnaZNs7MN3lyXxQfM/BLEVJs X-Received: by 2002:a63:6445:: with SMTP id y66-v6mr22356296pgb.206.1525440969756; Fri, 04 May 2018 06:36:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525440969; cv=none; d=google.com; s=arc-20160816; b=pgXGXfNjMCv+crFaJoQuOU9i0sTVdn7vuimM8KZ30gEH1v2rtjCsvrzCdBOTOVlsOq 7h0B4fc3Nq0MP8/92WRNeMAvFM4pNqC84/SBWJ4vrSivM0C1rqmFpJ2hd9nZf7yFTV2e /9Zc03+9boodHBrkAHUtL/3h9vJGrxp9mY2d17OOaoAL/VCrhKc2zMHlPeSllUC9cYfr xPgHpLeSwOcjrojVreI0KQAo1nignQbpiPb7DT7YljvJ6z8fQX3QiwLFcu4Pcq8rDOwH o/3kf2CjQaKrbQ9t7vIwiMV38sLxG//8g86Q80X+3phGF23J5wdnxVT9Lff15OzbwlQ7 IIoA== 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=JmUMG9PmvK70DaBylxxhK/W1iReOK6BFZJO5U295ohk=; b=ezT/FV0/l3YR6Xe5lCpDQc+6dDio/EQlNleBVaeH1RAAh0LbWjHIhFw05CYtuu6gFr 30DGDuBwHraPlRl0bTLT5eKEOdm+3F1gmeiqLvfKd7XsPp76Q9z1osXv4giYYbl1s14Q hTVhUEiyMQzi18hPI/bFY/mW+tzLxfhBeTtBhpNk9A0rbH2yxpIUyYCj0UZ8O9OhZAVh hkqkRJfPrjv/lGNdtWJsr8MXOXpT+ocPKzsI0UcwiL+JCNliO5PZdKUvfj+uISmb0D93 JwiZUKXmpyKW4NJOvKgsht2duhLFvQD+81rBydf4X3FKLWhXq+khBmnfIRWGGtR7e+53 haZg== 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 d20si1630134pfn.213.2018.05.04.06.35.55; Fri, 04 May 2018 06:36:09 -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 S1751278AbeEDNfg (ORCPT + 99 others); Fri, 4 May 2018 09:35:36 -0400 Received: from mx2.suse.de ([195.135.220.15]:60936 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750820AbeEDNff (ORCPT ); Fri, 4 May 2018 09:35:35 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 05605AC43; Fri, 4 May 2018 13:35:33 +0000 (UTC) Date: Fri, 4 May 2018 15:35:33 +0200 From: Michal Hocko To: Huaisheng Ye Cc: akpm@linux-foundation.org, linux-mm@kvack.org, vbabka@suse.cz, mgorman@techsingularity.net, pasha.tatashin@oracle.com, alexander.levin@verizon.com, hannes@cmpxchg.org, penguin-kernel@I-love.SAKURA.ne.jp, colyli@suse.de, chengnt@lenovo.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] include/linux/gfp.h: use unsigned int in gfp_zone Message-ID: <20180504133533.GR4535@dhcp22.suse.cz> References: <1525416729-108201-1-git-send-email-yehs1@lenovo.com> <1525416729-108201-3-git-send-email-yehs1@lenovo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1525416729-108201-3-git-send-email-yehs1@lenovo.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 04-05-18 14:52:08, Huaisheng Ye wrote: > Suggest using unsigned int instead of int for bit within gfp_zone. > > Within function gfp_zone, the value of local variable bit comes from > formal parameter flags, which's type is gfp_t. Local variable bit > indicates the number of bits in the right shift for GFP_ZONE_TABLE > with GFP_ZONES_SHIFT. So, variable bit shall always be unsigned > integer, it doesn't make sense that forcing it to be a signed integer. > > Current GFP_ZONEMASK is just valid as low four bits, the largest > value of bit shall be less or equal 0x0F. But in the future, as the > mask expands to higher bits, there will be a risk of confusion. I am highly skeptical we will ever grow the number of zones enough that signed vs. unsigned would matter. So I guess this all boils down to aesthetic. I do not care either way. The generated code seems the be the same. > Signed-off-by: Huaisheng Ye > --- > include/linux/gfp.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/gfp.h b/include/linux/gfp.h > index 1a4582b..21551fc 100644 > --- a/include/linux/gfp.h > +++ b/include/linux/gfp.h > @@ -401,7 +401,7 @@ static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags) > static inline enum zone_type gfp_zone(gfp_t flags) > { > enum zone_type z; > - int bit = (__force int) (flags & GFP_ZONEMASK); > + unsigned int bit = (__force unsigned int) (flags & GFP_ZONEMASK); > > z = (GFP_ZONE_TABLE >> (bit * GFP_ZONES_SHIFT)) & > ((1 << GFP_ZONES_SHIFT) - 1); > -- > 1.8.3.1 > -- Michal Hocko SUSE Labs