LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Re: [PATCH] include/linux/gfp.h: use unsigned int in gfp_zone
       [not found] <1525319098-91429-1-git-send-email-yehs1@lenovo.com>
@ 2018-05-03  7:43 ` Michal Hocko
  2018-05-03 14:05   ` Huaisheng HS1 Ye
  0 siblings, 1 reply; 2+ messages in thread
From: Michal Hocko @ 2018-05-03  7:43 UTC (permalink / raw)
  To: Huaisheng Ye
  Cc: akpm, linux-mm, linux-kernel, vbabka, mgorman, alexander.levin,
	colyli, chengnt

On Thu 03-05-18 11:44:58, Huaisheng Ye wrote:
> Suggest using unsigned int instead of int for bit within gfp_zone.
> 
> The value of bit comes from flags, which's type is gfp_t. And it
> indicates the number of bits in the right shift for GFP_ZONE_TABLE.
> 
> Signed-off-by: Huaisheng Ye <yehs1@lenovo.com>

The patch looks OK but it misses the most important piece of
information. Why this is worth changing. Does it lead to a better code?
Silence a warning or...

> ---
>  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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: [PATCH] include/linux/gfp.h: use unsigned int in gfp_zone
  2018-05-03  7:43 ` [PATCH] include/linux/gfp.h: use unsigned int in gfp_zone Michal Hocko
@ 2018-05-03 14:05   ` Huaisheng HS1 Ye
  0 siblings, 0 replies; 2+ messages in thread
From: Huaisheng HS1 Ye @ 2018-05-03 14:05 UTC (permalink / raw)
  To: Michal Hocko
  Cc: akpm, linux-mm, linux-kernel, vbabka, mgorman, alexander.levin,
	colyli, NingTing Cheng

 > On Thu 03-05-18 11:44:58, Huaisheng Ye wrote:
> > Suggest using unsigned int instead of int for bit within gfp_zone.
> >
> > The value of bit comes from flags, which's type is gfp_t. And it
> > indicates the number of bits in the right shift for GFP_ZONE_TABLE.
> >
> > Signed-off-by: Huaisheng Ye <yehs1@lenovo.com>
> 
> The patch looks OK but it misses the most important piece of
> information. Why this is worth changing. Does it lead to a better code?
> Silence a warning or...
> 
Yes, thank you and I will rewrite the commit log later.

Sincerely,
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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-03 14:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1525319098-91429-1-git-send-email-yehs1@lenovo.com>
2018-05-03  7:43 ` [PATCH] include/linux/gfp.h: use unsigned int in gfp_zone Michal Hocko
2018-05-03 14:05   ` Huaisheng HS1 Ye

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).