Skip to content

Commit 7ef3d2f

Browse files
JoePerchesLinus Torvalds
authored andcommitted
printk_ratelimit() functions should use CONFIG_PRINTK
Makes an embedded image a bit smaller. 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>
1 parent 36e7891 commit 7ef3d2f

File tree

3 files changed

+25
-15
lines changed

3 files changed

+25
-15
lines changed

include/linux/kernel.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@ asmlinkage int printk(const char * fmt, ...)
180180
extern int log_buf_get_len(void);
181181
extern int log_buf_read(int idx);
182182
extern int log_buf_copy(char *dest, int idx, int len);
183+
184+
extern int printk_ratelimit_jiffies;
185+
extern int printk_ratelimit_burst;
186+
extern int printk_ratelimit(void);
187+
extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst);
188+
extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
189+
unsigned int interval_msec);
183190
#else
184191
static inline int vprintk(const char *s, va_list args)
185192
__attribute__ ((format (printf, 1, 0)));
@@ -190,18 +197,19 @@ static inline int __cold printk(const char *s, ...) { return 0; }
190197
static inline int log_buf_get_len(void) { return 0; }
191198
static inline int log_buf_read(int idx) { return 0; }
192199
static inline int log_buf_copy(char *dest, int idx, int len) { return 0; }
200+
static inline int printk_ratelimit(void) { return 0; }
201+
static inline int __printk_ratelimit(int ratelimit_jiffies, \
202+
int ratelimit_burst) { return 0; }
203+
static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \
204+
unsigned int interval_msec) \
205+
{ return false; }
193206
#endif
194207

195208
extern void __attribute__((format(printf, 1, 2)))
196209
early_printk(const char *fmt, ...);
197210

198211
unsigned long int_sqrt(unsigned long);
199212

200-
extern int printk_ratelimit(void);
201-
extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst);
202-
extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
203-
unsigned int interval_msec);
204-
205213
static inline void console_silent(void)
206214
{
207215
console_loglevel = 0;

kernel/printk.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,6 +1251,7 @@ void tty_write_message(struct tty_struct *tty, char *msg)
12511251
return;
12521252
}
12531253

1254+
#if defined CONFIG_PRINTK
12541255
/*
12551256
* printk rate limiting, lifted from the networking subsystem.
12561257
*
@@ -1320,3 +1321,4 @@ bool printk_timed_ratelimit(unsigned long *caller_jiffies,
13201321
return false;
13211322
}
13221323
EXPORT_SYMBOL(printk_timed_ratelimit);
1324+
#endif

kernel/sysctl.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ extern int suid_dumpable;
7373
extern char core_pattern[];
7474
extern int pid_max;
7575
extern int min_free_kbytes;
76-
extern int printk_ratelimit_jiffies;
77-
extern int printk_ratelimit_burst;
7876
extern int pid_max_min, pid_max_max;
7977
extern int sysctl_drop_caches;
8078
extern int percpu_pagelist_fraction;
@@ -490,14 +488,6 @@ static struct ctl_table kern_table[] = {
490488
.mode = 0644,
491489
.proc_handler = &proc_dointvec,
492490
},
493-
{
494-
.ctl_name = KERN_PRINTK,
495-
.procname = "printk",
496-
.data = &console_loglevel,
497-
.maxlen = 4*sizeof(int),
498-
.mode = 0644,
499-
.proc_handler = &proc_dointvec,
500-
},
501491
#ifdef CONFIG_KMOD
502492
{
503493
.ctl_name = KERN_MODPROBE,
@@ -644,6 +634,15 @@ static struct ctl_table kern_table[] = {
644634
.mode = 0644,
645635
.proc_handler = &proc_dointvec,
646636
},
637+
#if defined CONFIG_PRINTK
638+
{
639+
.ctl_name = KERN_PRINTK,
640+
.procname = "printk",
641+
.data = &console_loglevel,
642+
.maxlen = 4*sizeof(int),
643+
.mode = 0644,
644+
.proc_handler = &proc_dointvec,
645+
},
647646
{
648647
.ctl_name = KERN_PRINTK_RATELIMIT,
649648
.procname = "printk_ratelimit",
@@ -661,6 +660,7 @@ static struct ctl_table kern_table[] = {
661660
.mode = 0644,
662661
.proc_handler = &proc_dointvec,
663662
},
663+
#endif
664664
{
665665
.ctl_name = KERN_NGROUPS_MAX,
666666
.procname = "ngroups_max",

0 commit comments

Comments
 (0)