* [PATCH] printk_ratelimit functions should use CONFIG_PRINTK
@ 2007-12-14 19:00 Joe Perches
2007-12-14 19:12 ` Matt Mackall
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2007-12-14 19:00 UTC (permalink / raw)
To: linux-kernel; +Cc: Matt Mackall, Linus Torvalds
Makes an embedded image a bit smaller
Signed-off-by: Joe Perches <joe@perches.com>
---
include/linux/kernel.h | 20 +++++++++++++++-----
kernel/printk.c | 2 ++
kernel/sysctl.c | 20 ++++++++++----------
3 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 94bc996..db2d5e7 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -182,6 +182,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)));
@@ -192,15 +199,18 @@ 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
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;
diff --git a/kernel/printk.c b/kernel/printk.c
index a30fe33..2259540 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1235,6 +1235,7 @@ void tty_write_message(struct tty_struct *tty, char *msg)
return;
}
+#if defined CONFIG_PRINTK
/*
* printk rate limiting, lifted from the networking subsystem.
*
@@ -1304,3 +1305,4 @@ bool printk_timed_ratelimit(unsigned long *caller_jiffies,
return false;
}
EXPORT_SYMBOL(printk_timed_ratelimit);
+#endif
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 8ac5171..f60b9e4 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -72,8 +72,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;
@@ -462,14 +460,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,
@@ -616,6 +606,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",
@@ -633,6 +632,7 @@ static struct ctl_table kern_table[] = {
.mode = 0644,
.proc_handler = &proc_dointvec,
},
+#endif
{
.ctl_name = KERN_NGROUPS_MAX,
.procname = "ngroups_max",
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] printk_ratelimit functions should use CONFIG_PRINTK
2007-12-14 19:00 [PATCH] printk_ratelimit functions should use CONFIG_PRINTK Joe Perches
@ 2007-12-14 19:12 ` Matt Mackall
2007-12-14 20:11 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Matt Mackall @ 2007-12-14 19:12 UTC (permalink / raw)
To: Joe Perches; +Cc: linux-kernel, Linus Torvalds, Andrew Morton
On Fri, Dec 14, 2007 at 11:00:35AM -0800, Joe Perches wrote:
> Makes an embedded image a bit smaller
Looks good to me. This should probably go to Andrew first though. And
it wouldn't hurt to see some size(1) results.
Acked-by: Matt Mackall <mpm@selenic.com>
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> include/linux/kernel.h | 20 +++++++++++++++-----
> kernel/printk.c | 2 ++
> kernel/sysctl.c | 20 ++++++++++----------
> 3 files changed, 27 insertions(+), 15 deletions(-)
>
> diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> index 94bc996..db2d5e7 100644
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -182,6 +182,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)));
> @@ -192,15 +199,18 @@ 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
>
> 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;
> diff --git a/kernel/printk.c b/kernel/printk.c
> index a30fe33..2259540 100644
> --- a/kernel/printk.c
> +++ b/kernel/printk.c
> @@ -1235,6 +1235,7 @@ void tty_write_message(struct tty_struct *tty, char *msg)
> return;
> }
>
> +#if defined CONFIG_PRINTK
> /*
> * printk rate limiting, lifted from the networking subsystem.
> *
> @@ -1304,3 +1305,4 @@ bool printk_timed_ratelimit(unsigned long *caller_jiffies,
> return false;
> }
> EXPORT_SYMBOL(printk_timed_ratelimit);
> +#endif
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index 8ac5171..f60b9e4 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -72,8 +72,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;
> @@ -462,14 +460,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,
> @@ -616,6 +606,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",
> @@ -633,6 +632,7 @@ static struct ctl_table kern_table[] = {
> .mode = 0644,
> .proc_handler = &proc_dointvec,
> },
> +#endif
> {
> .ctl_name = KERN_NGROUPS_MAX,
> .procname = "ngroups_max",
>
--
Mathematics is the supreme nostalgia of our time.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] printk_ratelimit functions should use CONFIG_PRINTK
2007-12-14 19:12 ` Matt Mackall
@ 2007-12-14 20:11 ` Joe Perches
0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2007-12-14 20:11 UTC (permalink / raw)
To: Matt Mackall; +Cc: linux-kernel, Linus Torvalds, Andrew Morton
On Fri, 2007-12-14 at 13:12 -0600, Matt Mackall wrote:
> On Fri, Dec 14, 2007 at 11:00:35AM -0800, Joe Perches wrote:
> > Makes an embedded image a bit smaller
>
> Looks good to me. This should probably go to Andrew first though. And
> it wouldn't hurt to see some size(1) results.
For instance:
x86 32 Allnoconfig, CONFIG_EMBEDDED=y CONFIG_PRINTK not set
with:
$ size -A vmlinux
vmlinux :
section size addr
.text 697864 3222274240
.rodata 121988 3222974464
.data 75952 3223097344
.bss 69632 3223289856
Total 1095589
without:
$ size -A vmlinux
vmlinux :
section size addr
.text 698376 3222274240
.rodata 122032 3222978560
.data 76080 3223101440
.bss 69632 3223298048
Total 1096273
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-12-14 20:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-14 19:00 [PATCH] printk_ratelimit functions should use CONFIG_PRINTK Joe Perches
2007-12-14 19:12 ` Matt Mackall
2007-12-14 20:11 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox