diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2008-02-06 04:37:02 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-06 13:41:04 -0500 |
commit | eed4a2aba7ff6d8c40d3d55b81f80352765ffcee (patch) | |
tree | 8cfeca1d26aa56ca83210cf3628399333e98c90e /kernel/printk.c | |
parent | b3242151906372f30f57feaa43b4cac96a23edb1 (diff) |
printk.c: use unsigned ints instead of longs for logbuf index
Stop using unsigned _longs_ for printk buffer indexes. Log buffer is way
smaller than 2 gigabytes and unsigned ints will work too . Indeed, they do
work nicely on all 32-bit platforms where longs and ints are the same.
With this patch, we have following size savings on amd64:
text data bss dec hex filename
5997 313 17736 24046 5dee 2.6.23.1.t64/kernel/printk.o
5858 313 17700 23871 5d3f 2.6.23.1.printk.t64/kernel/printk.o
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/printk.c')
-rw-r--r-- | kernel/printk.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/kernel/printk.c b/kernel/printk.c index 29ae1e99cde0..4a090621f379 100644 --- a/kernel/printk.c +++ b/kernel/printk.c | |||
@@ -93,16 +93,16 @@ static int console_locked, console_suspended; | |||
93 | */ | 93 | */ |
94 | static DEFINE_SPINLOCK(logbuf_lock); | 94 | static DEFINE_SPINLOCK(logbuf_lock); |
95 | 95 | ||
96 | #define LOG_BUF_MASK (log_buf_len-1) | 96 | #define LOG_BUF_MASK (log_buf_len-1) |
97 | #define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK]) | 97 | #define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK]) |
98 | 98 | ||
99 | /* | 99 | /* |
100 | * The indices into log_buf are not constrained to log_buf_len - they | 100 | * The indices into log_buf are not constrained to log_buf_len - they |
101 | * must be masked before subscripting | 101 | * must be masked before subscripting |
102 | */ | 102 | */ |
103 | static unsigned long log_start; /* Index into log_buf: next char to be read by syslog() */ | 103 | static unsigned log_start; /* Index into log_buf: next char to be read by syslog() */ |
104 | static unsigned long con_start; /* Index into log_buf: next char to be sent to consoles */ | 104 | static unsigned con_start; /* Index into log_buf: next char to be sent to consoles */ |
105 | static unsigned long log_end; /* Index into log_buf: most-recently-written-char + 1 */ | 105 | static unsigned log_end; /* Index into log_buf: most-recently-written-char + 1 */ |
106 | 106 | ||
107 | /* | 107 | /* |
108 | * Array of consoles built from command line options (console=) | 108 | * Array of consoles built from command line options (console=) |
@@ -128,17 +128,17 @@ static int console_may_schedule; | |||
128 | static char __log_buf[__LOG_BUF_LEN]; | 128 | static char __log_buf[__LOG_BUF_LEN]; |
129 | static char *log_buf = __log_buf; | 129 | static char *log_buf = __log_buf; |
130 | static int log_buf_len = __LOG_BUF_LEN; | 130 | static int log_buf_len = __LOG_BUF_LEN; |
131 | static unsigned long logged_chars; /* Number of chars produced since last read+clear operation */ | 131 | static unsigned logged_chars; /* Number of chars produced since last read+clear operation */ |
132 | 132 | ||
133 | static int __init log_buf_len_setup(char *str) | 133 | static int __init log_buf_len_setup(char *str) |
134 | { | 134 | { |
135 | unsigned long size = memparse(str, &str); | 135 | unsigned size = memparse(str, &str); |
136 | unsigned long flags; | 136 | unsigned long flags; |
137 | 137 | ||
138 | if (size) | 138 | if (size) |
139 | size = roundup_pow_of_two(size); | 139 | size = roundup_pow_of_two(size); |
140 | if (size > log_buf_len) { | 140 | if (size > log_buf_len) { |
141 | unsigned long start, dest_idx, offset; | 141 | unsigned start, dest_idx, offset; |
142 | char *new_log_buf; | 142 | char *new_log_buf; |
143 | 143 | ||
144 | new_log_buf = alloc_bootmem(size); | 144 | new_log_buf = alloc_bootmem(size); |
@@ -295,7 +295,7 @@ int log_buf_read(int idx) | |||
295 | */ | 295 | */ |
296 | int do_syslog(int type, char __user *buf, int len) | 296 | int do_syslog(int type, char __user *buf, int len) |
297 | { | 297 | { |
298 | unsigned long i, j, limit, count; | 298 | unsigned i, j, limit, count; |
299 | int do_clear = 0; | 299 | int do_clear = 0; |
300 | char c; | 300 | char c; |
301 | int error = 0; | 301 | int error = 0; |
@@ -436,7 +436,7 @@ asmlinkage long sys_syslog(int type, char __user *buf, int len) | |||
436 | /* | 436 | /* |
437 | * Call the console drivers on a range of log_buf | 437 | * Call the console drivers on a range of log_buf |
438 | */ | 438 | */ |
439 | static void __call_console_drivers(unsigned long start, unsigned long end) | 439 | static void __call_console_drivers(unsigned start, unsigned end) |
440 | { | 440 | { |
441 | struct console *con; | 441 | struct console *con; |
442 | 442 | ||
@@ -463,8 +463,8 @@ early_param("ignore_loglevel", ignore_loglevel_setup); | |||
463 | /* | 463 | /* |
464 | * Write out chars from start to end - 1 inclusive | 464 | * Write out chars from start to end - 1 inclusive |
465 | */ | 465 | */ |
466 | static void _call_console_drivers(unsigned long start, | 466 | static void _call_console_drivers(unsigned start, |
467 | unsigned long end, int msg_log_level) | 467 | unsigned end, int msg_log_level) |
468 | { | 468 | { |
469 | if ((msg_log_level < console_loglevel || ignore_loglevel) && | 469 | if ((msg_log_level < console_loglevel || ignore_loglevel) && |
470 | console_drivers && start != end) { | 470 | console_drivers && start != end) { |
@@ -484,12 +484,12 @@ static void _call_console_drivers(unsigned long start, | |||
484 | * log_buf[start] to log_buf[end - 1]. | 484 | * log_buf[start] to log_buf[end - 1]. |
485 | * The console_sem must be held. | 485 | * The console_sem must be held. |
486 | */ | 486 | */ |
487 | static void call_console_drivers(unsigned long start, unsigned long end) | 487 | static void call_console_drivers(unsigned start, unsigned end) |
488 | { | 488 | { |
489 | unsigned long cur_index, start_print; | 489 | unsigned cur_index, start_print; |
490 | static int msg_level = -1; | 490 | static int msg_level = -1; |
491 | 491 | ||
492 | BUG_ON(((long)(start - end)) > 0); | 492 | BUG_ON(((int)(start - end)) > 0); |
493 | 493 | ||
494 | cur_index = start; | 494 | cur_index = start; |
495 | start_print = start; | 495 | start_print = start; |
@@ -790,7 +790,7 @@ asmlinkage long sys_syslog(int type, char __user *buf, int len) | |||
790 | return -ENOSYS; | 790 | return -ENOSYS; |
791 | } | 791 | } |
792 | 792 | ||
793 | static void call_console_drivers(unsigned long start, unsigned long end) | 793 | static void call_console_drivers(unsigned start, unsigned end) |
794 | { | 794 | { |
795 | } | 795 | } |
796 | 796 | ||
@@ -983,8 +983,8 @@ void wake_up_klogd(void) | |||
983 | void release_console_sem(void) | 983 | void release_console_sem(void) |
984 | { | 984 | { |
985 | unsigned long flags; | 985 | unsigned long flags; |
986 | unsigned long _con_start, _log_end; | 986 | unsigned _con_start, _log_end; |
987 | unsigned long wake_klogd = 0; | 987 | unsigned wake_klogd = 0; |
988 | 988 | ||
989 | if (console_suspended) { | 989 | if (console_suspended) { |
990 | up(&secondary_console_sem); | 990 | up(&secondary_console_sem); |
@@ -1275,7 +1275,7 @@ void tty_write_message(struct tty_struct *tty, char *msg) | |||
1275 | int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst) | 1275 | int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst) |
1276 | { | 1276 | { |
1277 | static DEFINE_SPINLOCK(ratelimit_lock); | 1277 | static DEFINE_SPINLOCK(ratelimit_lock); |
1278 | static unsigned long toks = 10 * 5 * HZ; | 1278 | static unsigned toks = 10 * 5 * HZ; |
1279 | static unsigned long last_msg; | 1279 | static unsigned long last_msg; |
1280 | static int missed; | 1280 | static int missed; |
1281 | unsigned long flags; | 1281 | unsigned long flags; |