Skip to content

Commit

Permalink
printk_ratelimit() functions should use CONFIG_PRINTK
Browse files Browse the repository at this point in the history
Makes an embedded image a bit smaller.

Signed-off-by: Joe Perches <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
JoePerches authored and Linus Torvalds committed Feb 8, 2008
1 parent 36e7891 commit 7ef3d2f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
18 changes: 13 additions & 5 deletions include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ asmlinkage int printk(const char * fmt, ...)
extern int log_buf_get_len(void);
extern int log_buf_read(int idx);
extern int log_buf_copy(char *dest, int idx, int len);

extern int printk_ratelimit_jiffies;
extern int printk_ratelimit_burst;
extern int printk_ratelimit(void);
extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst);
extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
unsigned int interval_msec);
#else
static inline int vprintk(const char *s, va_list args)
__attribute__ ((format (printf, 1, 0)));
Expand All @@ -190,18 +197,19 @@ static inline int __cold printk(const char *s, ...) { return 0; }
static inline int log_buf_get_len(void) { return 0; }
static inline int log_buf_read(int idx) { return 0; }
static inline int log_buf_copy(char *dest, int idx, int len) { return 0; }
static inline int printk_ratelimit(void) { return 0; }
static inline int __printk_ratelimit(int ratelimit_jiffies, \
int ratelimit_burst) { return 0; }
static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \
unsigned int interval_msec) \
{ return false; }
#endif

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

unsigned long int_sqrt(unsigned long);

extern int printk_ratelimit(void);
extern int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst);
extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
unsigned int interval_msec);

static inline void console_silent(void)
{
console_loglevel = 0;
Expand Down
2 changes: 2 additions & 0 deletions kernel/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,7 @@ void tty_write_message(struct tty_struct *tty, char *msg)
return;
}

#if defined CONFIG_PRINTK
/*
* printk rate limiting, lifted from the networking subsystem.
*
Expand Down Expand Up @@ -1320,3 +1321,4 @@ bool printk_timed_ratelimit(unsigned long *caller_jiffies,
return false;
}
EXPORT_SYMBOL(printk_timed_ratelimit);
#endif
20 changes: 10 additions & 10 deletions kernel/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ extern int suid_dumpable;
extern char core_pattern[];
extern int pid_max;
extern int min_free_kbytes;
extern int printk_ratelimit_jiffies;
extern int printk_ratelimit_burst;
extern int pid_max_min, pid_max_max;
extern int sysctl_drop_caches;
extern int percpu_pagelist_fraction;
Expand Down Expand Up @@ -490,14 +488,6 @@ static struct ctl_table kern_table[] = {
.mode = 0644,
.proc_handler = &proc_dointvec,
},
{
.ctl_name = KERN_PRINTK,
.procname = "printk",
.data = &console_loglevel,
.maxlen = 4*sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec,
},
#ifdef CONFIG_KMOD
{
.ctl_name = KERN_MODPROBE,
Expand Down Expand Up @@ -644,6 +634,15 @@ static struct ctl_table kern_table[] = {
.mode = 0644,
.proc_handler = &proc_dointvec,
},
#if defined CONFIG_PRINTK
{
.ctl_name = KERN_PRINTK,
.procname = "printk",
.data = &console_loglevel,
.maxlen = 4*sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec,
},
{
.ctl_name = KERN_PRINTK_RATELIMIT,
.procname = "printk_ratelimit",
Expand All @@ -661,6 +660,7 @@ static struct ctl_table kern_table[] = {
.mode = 0644,
.proc_handler = &proc_dointvec,
},
#endif
{
.ctl_name = KERN_NGROUPS_MAX,
.procname = "ngroups_max",
Expand Down

0 comments on commit 7ef3d2f

Please sign in to comment.