From: Linus Torvalds on


On Thu, 4 Mar 2010, Andrew Morton wrote:
>
> What would I need to do to make it recur more than once? Include a %pV
> in a string, like dev_printk("%s", %%pV")?

I would argue that if somebody does that, they're just broken.

The single level of recursion is really nice - it solves a real annoyance.
But if somebody starts trying to do multiple levels, that's just crazy.

Of course, I guess we don't relly have any way of sanely _counting_ the
recursion level, so we'd have to just trust people to not do crazy things.

And that's a big thing to take on trust ;)

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


On Sat, 6 Mar 2010, Joe Perches wrote:
>
> Is that an ack, a nack or a get the hell out?

It's mostly an Ack. I think the concept is great. I'd love to have some
way to limit recursion, 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.

Linus

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


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(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Linus Torvalds on


On Sat, 6 Mar 2010, Linus Torvalds wrote:
>
> I'm not convinced. We pass that 'printf_spec' around a lot, including
> nesting. Not as a pointer, either.

Btw, I wonder if those fields could become bitfields, or 'unsigned char'
etc. That printf_spec really is unnecessarily big. It should _easily_ fit
in a single register on a 64-bit platform, possibly even a 32-bit one (we
could limit field width and precision to 5 bits, for example)

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


On Sat, 6 Mar 2010, Linus Torvalds wrote:
>
> width: 5 (make it 6 bits and signed)
> precision: 5 (make it 6 bits, and signed)

Oh, actually, no, we do that whole left-justification with the flags, we
don't need that signed stuff. We do need one special value for the "no
width, no precision", though.

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