Re: 2.6.39-rc6-mmotm0506 and -next - __kfree_rcu breaksthird-party kernel code

From: Paul E. McKenney
Date: Tue May 10 2011 - 11:42:30 EST


On Mon, May 09, 2011 at 10:14:30AM -0700, Randy Dunlap wrote:
> On 05/09/11 09:56, Valdis.Kletnieks@xxxxxx wrote:
> > On Mon, 09 May 2011 09:17:57 PDT, Randy Dunlap said:
> >
> >> I'd be happy to see a simple fix, but we don't generally support building
> >> external modules without using the kernel kbuild infrastructure AFAIK --
> >> and when I add a Makefile along with your kernconf.c file, it builds successfully
> >> on mmotm-2011-0506-1639.
> >
> > And in fact the module *does* use the Makefile stuff for the actual build - it
> > was just the installer's "am I looking at a sane 2.6 tree" sanity check that
> > bombed. So I go looking for what special sauce the Makefile adds to make it
> > work, and....
> >
> > OK, *now* I'm confused. The magic sauce appears to be "-Os". Adding that makes
> > the compile work. And for no obvious reason - there's something in there that
> > causes indigestion, but only if the optimizer isn't invoked.
>
> You can disable that by disabling:
> CONFIG_CC_OPTIMIZE_FOR_SIZE=y
>
> > *WTF*?
>
> I dunno either.

It appears that some compilers at some optimization levels aren't willing
to trace build-time constants through local parameters... Could you please
try out the following patch?

Thanx, Paul

------------------------------------------------------------------------

rcu: avoid build error for third-party modules

The initial definition of __kfree_rcu() checked a static inline function
argument to see if it was a compile-time constant. Apparently not all
compilers are willing to put up with this at all optimization levels.
Add a nasty comment and remove the warning, relying on the fact that
__kfree_rcu() is called only from kfree_rcu(), which always passes in
a compile-time constant.

Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxxxxxxxxxx>

diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 99f9aa7..58b13f1 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -814,13 +814,14 @@ static __always_inline bool __is_kfree_rcu_offset(unsigned long offset)
return offset < 4096;
}

+/*
+ * Intended to be called only from the kfree_rcu() macro.
+ */
static __always_inline
void __kfree_rcu(struct rcu_head *head, unsigned long offset)
{
typedef void (*rcu_callback)(struct rcu_head *);

- BUILD_BUG_ON(!__builtin_constant_p(offset));
-
/* See the kfree_rcu() header comment. */
BUILD_BUG_ON(!__is_kfree_rcu_offset(offset));

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/