[RFC] gfp flags annotations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 06, 2005 at 12:29:04AM +0400, Alexey Dobriyan wrote:
> > --- RC14-rc3-git4/arch/arm/mm/consistent.c
> > +++ RC14-rc3-git4-final/arch/arm/mm/consistent.c
> 
> > -vm_region_alloc(struct vm_region *head, size_t size, int gfp)
> > +vm_region_alloc(struct vm_region *head, size_t size, unsigned int gfp)
> 
> > -__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle, int gfp,
> > -	    pgprot_t prot)
> > +__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
> > +	    unsigned int gfp, pgprot_t prot)
> 
> 	unsigned int __nocast gfp
> 
> 	=> dma_alloc_coherent
> 	=> dma_alloc_writecombine

Speaking of that...  IMO we should do the following:

a) typedef unsigned int __nocast gfp_t;
b) replace __nocast uses for gfp flags with gfp_t - it gives exactly the same
warnings as far as sparse is concerned, doesn't change generated code and
documents what's going on far better.  If we are using __nocast for anything
else - sure, let it stay.
c) then replace __nocast in declaration of gfp_t with __bitwise [*], add
force cast to gfp_t to definitions of __GFP_... and deal with resulting
warnings.

Note that unlike __nocast, __bitwise is hard to lose; lossage like the above
will not go unnoticed.  We will need a couple of inline helpers to deal with
extraction of zone from gfp, etc., but after that it's basically a matter of
switching the missed chunks like the above.

I've done that several months ago, but that patch series had been killed
by bitrot (patches fixing the bugs I've found back then had been merged,
the rest had gone to bitbucket after a while).  It's not hard to reproduce,
though.

Objections?


[*] since endainness annotations are nowhere near complete, I suggest
the following: define __bitwise__ as __attribute__((bitwise)) or empty,
depending on __CHECKER__, then have

#ifdef __CHECK_ENDIAN__
#define __bitwise __bitwise__
#else
#define __bitwise
#endif
typedef unsigned int __bitwise__ gfp_t;

with -Wbitwise unconditionally in CHECKFLAGS.  Then normal run will pick
the places that use __bitwise__ and CF=-D__CHECK_ENDIAN__ will pick all
endianness warnings on top of that.  Basically, that allows to use
bitwise annotations while endianness stuff is not finished and do that
without drowning in warnings.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux