Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1632170 > unrolled thread

Re: [RFC PATCH] printk: Make functions of pr_<level> macros

Started byPetr Mladek <pmladek@suse.com>
First post2017-04-27 17:20 +0200
Last post2017-04-27 18:30 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [RFC PATCH] printk: Make functions of pr_<level> macros Petr Mladek <pmladek@suse.com> - 2017-04-27 17:20 +0200
    Re: [RFC PATCH] printk: Make functions of pr_<level> macros Joe Perches <joe@perches.com> - 2017-04-27 18:10 +0200
    Re: [RFC PATCH] printk: Make functions of pr_<level> macros Steven Rostedt <rostedt@goodmis.org> - 2017-04-27 18:30 +0200

#1632170 — Re: [RFC PATCH] printk: Make functions of pr_<level> macros

FromPetr Mladek <pmladek@suse.com>
Date2017-04-27 17:20 +0200
SubjectRe: [RFC PATCH] printk: Make functions of pr_<level> macros
Message-ID<tATn4-2pt-29@gated-at.bofh.it>
On Wed 2017-03-01 21:58:54, Joe Perches wrote:
> On Thu, 2017-03-02 at 14:35 +0900, Sergey Senozhatsky wrote:
> > Hello Joe,
> > 
> > On (02/28/17 19:17), Joe Perches wrote:
> > > Can save the space that the KERN_<LEVEL> headers require.
> > > 
> > > The biggest negative here is the %pV use which needs
> > > recursion and adds stack depth.
> > > 
> > > $ size vmlinux.o* (defconfig, x86-64)
> > >    text     data     bss      dec     hex  filename
> > > 12586135  1909841  777528 15273504  e90e20 vmlinux.o.new
> > > 12590348  1909841  777528 15277717  e91e95 vmlinux.o.old
> > 
> > interesting. 4K.
> 
> Yeah, more when more calls are converted,
> 
> Maybe more like 12k, still the goal is to 
> create singletons for the pr_fmt prefixes
> and whatever __func__ uses that are most
> common via a SOH + flag and using
> __builtin_return_address where possible and
> appropriate.  That could shrink another 10k
> or so.
> 
> > [..]
> > > +#define define_pr_func(func, level)			\
> > > +asmlinkage __visible int func(const char *fmt, ...)	\
> > > +{							\ 
> > > +	va_list args;					\
> > > +	int r;						\
> > > +	struct va_format vaf;				\
> > > +							\
> > > +	va_start(args, fmt);				\
> > > +	vaf.fmt = fmt;					\
> > > +	vaf.va = &args;					\
> > > +							\
> > > +	r = printk(level "%pV", &vaf);			\
> > > +							\
> > > +	va_end(args);					\
> > > +							\
> > > +	return r;					\
> > > +}							\
> > 
> > hm. that's really hacky (which is a compliment) and a bit complicated.
> > my quick thought was to tweak vprintk_emit() for 'facility != 0' so it
> > could get loglevel (and adjust lflags) from the passed level, not from
> > the text, and then do something like this
> 
> 
> > #define define_pr_func(func, level) asmlinkage __visible int func(const char *fmt, ...)
> > {
> > 	va_start(args, fmt);
> > 	r = vprintk_emit(level[0], level[1], NULL, 0, fmt, args);
> > 	va_end();
> > }
> > 
> > but this won't do the trick. because func()->vprintk_emit() shortcut
> > disables the printk-safe mechanism:
> > 	func()->printk()->vprintk_func()->this_cpu(printk_context)::print()
> 
> That was what I had done originally a while ago
> https://lkml.org/lkml/2016/6/23/652

BTW: The above mentioned commit adds one argument to
vprintk_default(). But the symbol is exported. I am
not sure if we could break the API.

We might need to create alternative vprintk_* functions
(called vlprintk_* or so) that would have the extra parameter.
And call them from the existing vprintk_* ones. Sigh.

Also note that we might need to pass more information
via the extra parameter, for example, KERN_ERR + KERN_CONT.

> Now the with "safe" version, it's a bit more complicated.

:-(

> [stack depth can be high, ~400 bytes per recursion]
> 
> > dunno, at the moment I'm not really comfortable with %pV recursion
> > for every pr_foo() call

Same here. We should avoid the recursion.

Best Regards,
Petr

[toc] | [next] | [standalone]


#1632226

FromJoe Perches <joe@perches.com>
Date2017-04-27 18:10 +0200
Message-ID<tAU9s-2Zz-17@gated-at.bofh.it>
In reply to#1632170
On Thu, 2017-04-27 at 17:11 +0200, Petr Mladek wrote:
> On Wed 2017-03-01 21:58:54, Joe Perches wrote:
> > On Thu, 2017-03-02 at 14:35 +0900, Sergey Senozhatsky wrote:
> > > On (02/28/17 19:17), Joe Perches wrote:
> > > > Can save the space that the KERN_<LEVEL> headers require.
> > > > 
> > > > The biggest negative here is the %pV use which needs
> > > > recursion and adds stack depth.
[]
> > Maybe more like 12k, still the goal is to 
> > create singletons for the pr_fmt prefixes
> > and whatever __func__ uses that are most
> > common via a SOH + flag and using
> > __builtin_return_address where possible and
> > appropriate.  That could shrink another 10k
> > or so.
[]
> > #define define_pr_func(func, level) asmlinkage __visible int func(const char *fmt, ...)
> > > {
> > > 	va_start(args, fmt);
> > > 	r = vprintk_emit(level[0], level[1], NULL, 0, fmt, args);
> > > 	va_end();
> > > }
> > > 
> > > but this won't do the trick. because func()->vprintk_emit() shortcut
> > > disables the printk-safe mechanism:
> > > 	func()->printk()->vprintk_func()->this_cpu(printk_context)::print()
> > 
> > That was what I had done originally a while ago
> > https://lkml.org/lkml/2016/6/23/652
> 
> BTW: The above mentioned commit adds one argument to
> vprintk_default(). But the symbol is exported. I am
> not sure if we could break the API.

I believe EXPORT_SYMBOL functions have been modified
in the past, but don't have an example at hand.

> We might need to create alternative vprintk_* functions
> (called vlprintk_* or so) that would have the extra parameter.
> And call them from the existing vprintk_* ones. Sigh.

That might work.

> Also note that we might need to pass more information
> via the extra parameter, for example, KERN_ERR + KERN_CONT.
> 
> > Now the with "safe" version, it's a bit more complicated.
> 
> :-(

Yeah, that too.

[toc] | [prev] | [next] | [standalone]


#1632241

FromSteven Rostedt <rostedt@goodmis.org>
Date2017-04-27 18:30 +0200
Message-ID<tAUsN-36Q-13@gated-at.bofh.it>
In reply to#1632170
On Thu, 27 Apr 2017 17:11:21 +0200
Petr Mladek <pmladek@suse.com> wrote:

> BTW: The above mentioned commit adds one argument to
> vprintk_default(). But the symbol is exported. I am
> not sure if we could break the API.

There is no kernel ABI/API. Exported kernel functions can change at will
as long as a make allmodconfig still works. We don't care about out of
tree users.

-- Steve

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web