Re: [RESEND PATCH 0/2] Make functions of dev_<level> macros, recursivevsnprintf

From: Linus Torvalds
Date: Sat Mar 06 2010 - 17:53:12 EST




On Sat, 6 Mar 2010, Joe Perches wrote:
>
> Maybe limit the %pV recursion depth to 1 with something like:
> (in vsprintf.c: pointer() )

Nope. Think about concurrent users.

The thing is, you have to hide it in local storage. We could make it
thread-local (not cpu-local), but even that interacts badly with
interrupts.

The only really workable approach would be to have a stack slot that is
created by the externally visible routines (and initialized to zero), and
those then passe the address of that as an argument to the lower levels,
and then the recursion happens entirely within those lower level functions
that update the value.

So it's doable, it's just not pretty.

> > and I'd also love to see some actual numbers of > > how deep the vsnprintf stack frame is, but I don't see how to do the
> > first, and I'm hoping the second isn't too horrible.
>
> I believe it's the arguments, a long long, a couple of pointers,
> and a struct printf_spec. Not too bad.

I'm not convinced. We pass that 'printf_spec' around a lot, including
nesting. Not as a pointer, either.

(Bjorn Helgaas has a patch that gets rid of _some_ of the stack usage, but
not nearly all).

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