Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Joe Perches and committed by
Linus Torvalds
7ef3d2fd 36e78914

+25 -15
+13 -5
include/linux/kernel.h
··· 180 180 extern int log_buf_get_len(void); 181 181 extern int log_buf_read(int idx); 182 182 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); 183 190 #else 184 191 static inline int vprintk(const char *s, va_list args) 185 192 __attribute__ ((format (printf, 1, 0))); ··· 197 190 static inline int log_buf_get_len(void) { return 0; } 198 191 static inline int log_buf_read(int idx) { return 0; } 199 192 static inline int log_buf_copy(char *dest, int idx, int len) { return 0; } 193 + static inline int printk_ratelimit(void) { return 0; } 194 + static inline int __printk_ratelimit(int ratelimit_jiffies, \ 195 + int ratelimit_burst) { return 0; } 196 + static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \ 197 + unsigned int interval_msec) \ 198 + { return false; } 200 199 #endif 201 200 202 201 extern void __attribute__((format(printf, 1, 2))) 203 202 early_printk(const char *fmt, ...); 204 203 205 204 unsigned long int_sqrt(unsigned long); 206 - 207 - extern int printk_ratelimit(void); 208 - extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst); 209 - extern bool printk_timed_ratelimit(unsigned long *caller_jiffies, 210 - unsigned int interval_msec); 211 205 212 206 static inline void console_silent(void) 213 207 {
+2
kernel/printk.c
··· 1251 1251 return; 1252 1252 } 1253 1253 1254 + #if defined CONFIG_PRINTK 1254 1255 /* 1255 1256 * printk rate limiting, lifted from the networking subsystem. 1256 1257 * ··· 1321 1320 return false; 1322 1321 } 1323 1322 EXPORT_SYMBOL(printk_timed_ratelimit); 1323 + #endif
+10 -10
kernel/sysctl.c
··· 73 73 extern char core_pattern[]; 74 74 extern int pid_max; 75 75 extern int min_free_kbytes; 76 - extern int printk_ratelimit_jiffies; 77 - extern int printk_ratelimit_burst; 78 76 extern int pid_max_min, pid_max_max; 79 77 extern int sysctl_drop_caches; 80 78 extern int percpu_pagelist_fraction; ··· 488 490 .mode = 0644, 489 491 .proc_handler = &proc_dointvec, 490 492 }, 491 - { 492 - .ctl_name = KERN_PRINTK, 493 - .procname = "printk", 494 - .data = &console_loglevel, 495 - .maxlen = 4*sizeof(int), 496 - .mode = 0644, 497 - .proc_handler = &proc_dointvec, 498 - }, 499 493 #ifdef CONFIG_KMOD 500 494 { 501 495 .ctl_name = KERN_MODPROBE, ··· 634 644 .mode = 0644, 635 645 .proc_handler = &proc_dointvec, 636 646 }, 647 + #if defined CONFIG_PRINTK 648 + { 649 + .ctl_name = KERN_PRINTK, 650 + .procname = "printk", 651 + .data = &console_loglevel, 652 + .maxlen = 4*sizeof(int), 653 + .mode = 0644, 654 + .proc_handler = &proc_dointvec, 655 + }, 637 656 { 638 657 .ctl_name = KERN_PRINTK_RATELIMIT, 639 658 .procname = "printk_ratelimit", ··· 660 661 .mode = 0644, 661 662 .proc_handler = &proc_dointvec, 662 663 }, 664 + #endif 663 665 { 664 666 .ctl_name = KERN_NGROUPS_MAX, 665 667 .procname = "ngroups_max",