linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] fix sparse happy borkage when including gfp.h
       [not found]   ` <20110415143259.F7BD.A69D9226@jp.fujitsu.com>
@ 2011-04-15 14:27     ` Dave Hansen
  2011-04-26  9:24       ` Christopher Li
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Hansen @ 2011-04-15 14:27 UTC (permalink / raw)
  To: KOSAKI Motohiro; +Cc: linux-mm, linux-kernel, Andrew Morton, linux-sparse

On Fri, 2011-04-15 at 14:33 +0900, KOSAKI Motohiro wrote:
> Hello,
> > On Fri, 2011-04-15 at 12:14 +0900, KOSAKI Motohiro wrote:
> > > >  #ifdef CONFIG_DEBUG_VM
> > > > -             BUG_ON((GFP_ZONE_BAD >> bit) & 1);
> > > > +     BUG_ON((GFP_ZONE_BAD >> bit) & 1);
> > > >  #endif
> > > > -     }
> > > >       return z;
> > > 
> > > Why don't you use VM_BUG_ON?
> > 
> > I was just trying to make a minimal patch that did a single thing.
> > 
> > Feel free to submit another one that does that.  I'm sure there are a
> > couple more places that could use similar love.
> 
> I posted another approach patches a second ago. Could you please see it?

Those both look sane to me.  Those weren't biting me in particular, and
they don't fix the issue I was seeing.  But, they do seem necessary to
reduce some of the noise.

CC'ing the sparse mailing list.  We're seeing a couple of cases where
some gcc-isms are either stopping sparse from finding real bugs:

	http://marc.info/?l=linux-mm&m=130282454732689&w=2

or creating a lot of noise on some builds:

	http://marc.info/?l=linux-mm&m=130284428614058&w=2
	http://marc.info/?l=linux-mm&m=130284431014077&w=2

-- Dave

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

* Re: [PATCH] fix sparse happy borkage when including gfp.h
  2011-04-15 14:27     ` [PATCH] fix sparse happy borkage when including gfp.h Dave Hansen
@ 2011-04-26  9:24       ` Christopher Li
  0 siblings, 0 replies; 2+ messages in thread
From: Christopher Li @ 2011-04-26  9:24 UTC (permalink / raw)
  To: Dave Hansen; +Cc: KOSAKI Motohiro, Andrew Morton, linux-sparse

On Fri, Apr 15, 2011 at 7:27 AM, Dave Hansen <dave@linux.vnet.ibm.com> wrote:
> Those both look sane to me.  Those weren't biting me in particular, and
> they don't fix the issue I was seeing.  But, they do seem necessary to
> reduce some of the noise.
>
> CC'ing the sparse mailing list.  We're seeing a couple of cases where
> some gcc-isms are either stopping sparse from finding real bugs:
>
>        http://marc.info/?l=linux-mm&m=130282454732689&w=2

I take a look at this problem. The bug can be simplify as the following source:

typedef unsigned __attribute__((bitwise)) gfp_t;

void foo ( gfp_t flags)
{
	int bit = (__attribute__((force)) int) (flags &
(((__attribute__((force)) gfp_t)0x01u)|((__attribute__((force))
gfp_t)0x02u)|((__attribute__((force))
gfp_t)0x04u)|((__attribute__((force)) gfp_t)0x08u)));

	if (__builtin_constant_p(bit))
			((void)sizeof(char[1 - 2 * !!((( 1 << (0x01u | 0x02u) | 1 << (0x01u
| 0x04u) | 1 << (0x04u | 0x02u) | 1 << (0x01u | 0x04u | 0x02u) | 1 <<
(0x08u | 0x02u | 0x01u) | 1 << (0x08u | 0x04u | 0x01u) | 1 << (0x08u |
0x04u | 0x02u) | 1 << (0x08u | 0x04u | 0x01u | 0x02u) ) >> bit) &
1)]));
}

Sparse chock on variable length array. It is nothing new. It was
useful to warn about
the variable length array usage in the kernel, because it might
overflow the kernel stack.
In this case, it is just a clever trick to issue assert on compile time.

We should bite the bullet and just parse the variable length array as
expression. We can still issue
warning for non constant usage, without the early bail out from sparse.

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2011-04-26  9:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20110415121424.F7A6.A69D9226@jp.fujitsu.com>
     [not found] ` <1302844066.16562.1953.camel@nimitz>
     [not found]   ` <20110415143259.F7BD.A69D9226@jp.fujitsu.com>
2011-04-15 14:27     ` [PATCH] fix sparse happy borkage when including gfp.h Dave Hansen
2011-04-26  9:24       ` Christopher Li

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