Re: Bcache v. whatever
From: Kent Overstreet
Date: Fri Apr 26 2013 - 16:55:07 EST
On Fri, Apr 26, 2013 at 01:24:38PM -0700, Andrew Morton wrote:
> > As far as I can tell the only real improvement would be to add a %p
> > format string to vsnprintf, but adding a global extension would obviously be
> > inappropriate for this. It'd be really nice to have a mechanism for
> > adding file/module private format strings to vsnprintf, but I haven't
> > cared enough yet to implement it myself.
> >
> > Of course if you know a better solution I'm all ears.
> >
> > Uhm, as for the actual bug - that is a fairly ancient gcc, I wasn't
> > aware we were supporting compilers that old but I'm sure you wouldn't be
> > bugging me about it if we weren't...
>
> Why are those things macros anyway? urgh, it's because we want to jam
> a string into the caller's stack frame without declaring any of it.
Well, it also _used_ to be the case that if DEBUG and
CONFIG_DYNAMIC_DEBUG weren't defined then pr_debug() was defined as an
empty macro, so btree_to_text() wouldn't be called.
But, I just checked and it's been converted to an empty inline
function, and some of this debug code is called from fast paths where
the overhead really does matter :/ argh
> Really I do think it would be better to do away with the C party tricks
> and have callers do
>
> char btree_buf[BTREE_BUF_SIZE];
>
> btree_to_text(btree_buf, b);
> pr_debug("%s\n", btree_buf);
>
> Nice, simple, explicit, direct and stupid. It might generate
> unused-var warnings if DEBUG is undefined but from my reading of
> pr_debug() things will be OK.
>
> Then we can poke around at btree_to_text() until gcc-3.4.5 is happy
> with it.
Well, since pr_debug() isn't an empty macro anymore there goes my main
reason for keeping these macros around.
seems like pr_debug() could still have the no_printk() call inside an
if (0) though...
argh. If there was some way to tell gcc "this function only modifies
this argument so you don't have to call it if the output is never used"
then I'd just convert it to the explicit bufs now. But I really can't
have btree_to_text()/bkey_to_text() getting called in non debug
kernels...
I'm going to mull it over a bit for now, and try and decide what's least
ugly.
--
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/