Skip to content

Commit 28e1745

Browse files
Villemoespmladek
authored andcommitted
printk: rename vprintk_func to vprintk
The printk code is already hard enough to understand. Remove an unnecessary indirection by renaming vprintk_func to vprintk (adding the asmlinkage annotation), and removing the vprintk definition from printk.c. That way, printk is implemented in terms of vprintk as one would expect, and there's no "vprintk_func, what's that? Some function pointer that gets set where?" The declaration of vprintk in linux/printk.h already has the __printf(1,0) attribute, there's no point repeating that with the definition - it's for diagnostics in callers. linux/printk.h already contains a static inline {return 0;} definition of vprintk when !CONFIG_PRINTK. Since the corresponding stub definition of vprintk_func was not marked "static inline", any translation unit including internal.h would get a definition of vprintk_func - it just so happens that for !CONFIG_PRINTK, there is precisely one such TU, namely printk.c. Had there been more, it would be a link error; now it's just a silly waste of a few bytes of .text, which one must assume are rather precious to anyone disabling PRINTK. $ objdump -dr kernel/printk/printk.o 00000330 <vprintk_func>: 330: 31 c0 xor %eax,%eax 332: c3 ret 333: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 33a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi Signed-off-by: Rasmus Villemoes <[email protected]> Reviewed-by: Steven Rostedt (VMware) <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Signed-off-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 505a27a commit 28e1745

File tree

3 files changed

+3
-11
lines changed

3 files changed

+3
-11
lines changed

kernel/printk/internal.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ int vprintk_store(int facility, int level,
1919

2020
__printf(1, 0) int vprintk_default(const char *fmt, va_list args);
2121
__printf(1, 0) int vprintk_deferred(const char *fmt, va_list args);
22-
__printf(1, 0) int vprintk_func(const char *fmt, va_list args);
2322
void __printk_safe_enter(void);
2423
void __printk_safe_exit(void);
2524

@@ -54,8 +53,6 @@ void defer_console_output(void);
5453

5554
#else
5655

57-
__printf(1, 0) int vprintk_func(const char *fmt, va_list args) { return 0; }
58-
5956
/*
6057
* In !PRINTK builds we still export console_sem
6158
* semaphore and some of console functions (console_unlock()/etc.), so

kernel/printk/printk.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,12 +2180,6 @@ asmlinkage int vprintk_emit(int facility, int level,
21802180
}
21812181
EXPORT_SYMBOL(vprintk_emit);
21822182

2183-
asmlinkage int vprintk(const char *fmt, va_list args)
2184-
{
2185-
return vprintk_func(fmt, args);
2186-
}
2187-
EXPORT_SYMBOL(vprintk);
2188-
21892183
int vprintk_default(const char *fmt, va_list args)
21902184
{
21912185
return vprintk_emit(0, LOGLEVEL_DEFAULT, NULL, fmt, args);
@@ -2219,7 +2213,7 @@ asmlinkage __visible int printk(const char *fmt, ...)
22192213
int r;
22202214

22212215
va_start(args, fmt);
2222-
r = vprintk_func(fmt, args);
2216+
r = vprintk(fmt, args);
22232217
va_end(args);
22242218

22252219
return r;

kernel/printk/printk_safe.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ void __printk_safe_exit(void)
357357
this_cpu_dec(printk_context);
358358
}
359359

360-
__printf(1, 0) int vprintk_func(const char *fmt, va_list args)
360+
asmlinkage int vprintk(const char *fmt, va_list args)
361361
{
362362
#ifdef CONFIG_KGDB_KDB
363363
/* Allow to pass printk() to kdb but avoid a recursion. */
@@ -411,3 +411,4 @@ void __init printk_safe_init(void)
411411
/* Flush pending messages that did not have scheduled IRQ works. */
412412
printk_safe_flush();
413413
}
414+
EXPORT_SYMBOL(vprintk);

0 commit comments

Comments
 (0)