printk: create pr_<level> functions

Using functions instead of macros can reduce overall code size by
eliminating unnecessary "KERN_SOH<digit>" prefixes from format strings.

  defconfig x86-64:

  $ size vmlinux*
     text    data     bss      dec     hex  filename
  10193570 4331464 1105920 15630954  ee826a vmlinux.new
  10192623 4335560 1105920 15634103  ee8eb7 vmlinux.old

As the return value are unimportant and unused in the kernel tree, these
new functions return void.

Miscellanea:

 - change pr_<level> macros to call new __pr_<level> functions
 - change vprintk_nmi and vprintk_default to add LOGLEVEL_<level> argument

[akpm@linux-foundation.org: fix LOGLEVEL_INFO, per Joe]
Link: http://lkml.kernel.org/r/e16cc34479dfefcae37c98b481e6646f0f69efc3.1466718827.git.joe@perches.com
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Joe Perches
2016-08-02 14:03:53 -07:00
zatwierdzone przez Linus Torvalds
rodzic bebca05281
commit 874f9c7da9
4 zmienionych plików z 78 dodań i 26 usunięć

Wyświetl plik

@@ -58,7 +58,7 @@ static DEFINE_PER_CPU(struct nmi_seq_buf, nmi_print_seq);
* one writer running. But the buffer might get flushed from another
* CPU, so we need to be careful.
*/
static int vprintk_nmi(const char *fmt, va_list args)
static int vprintk_nmi(int level, const char *fmt, va_list args)
{
struct nmi_seq_buf *s = this_cpu_ptr(&nmi_print_seq);
int add = 0;
@@ -79,7 +79,16 @@ again:
if (!len)
smp_rmb();
add = vsnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, args);
if (level != LOGLEVEL_DEFAULT) {
add = snprintf(s->buffer + len, sizeof(s->buffer) - len,
KERN_SOH "%c", '0' + level);
add += vsnprintf(s->buffer + len + add,
sizeof(s->buffer) - len - add,
fmt, args);
} else {
add = vsnprintf(s->buffer + len, sizeof(s->buffer) - len,
fmt, args);
}
/*
* Do it once again if the buffer has been flushed in the meantime.