Commit eed4a2aba7ff6d8c40d3d55b81f80352765ffcee
Committed by
Linus Torvalds
1 parent
b324215190
Exists in
master
and in
7 other branches
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>
Showing 1 changed file with 18 additions and 18 deletions Side-by-side Diff
kernel/printk.c
... | ... | @@ -93,16 +93,16 @@ |
93 | 93 | */ |
94 | 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 | 97 | #define LOG_BUF(idx) (log_buf[(idx) & LOG_BUF_MASK]) |
98 | 98 | |
99 | 99 | /* |
100 | 100 | * The indices into log_buf are not constrained to log_buf_len - they |
101 | 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() */ | |
104 | -static unsigned long 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 */ | |
103 | +static unsigned log_start; /* Index into log_buf: next char to be read by syslog() */ | |
104 | +static unsigned con_start; /* Index into log_buf: next char to be sent to consoles */ | |
105 | +static unsigned log_end; /* Index into log_buf: most-recently-written-char + 1 */ | |
106 | 106 | |
107 | 107 | /* |
108 | 108 | * Array of consoles built from command line options (console=) |
109 | 109 | |
110 | 110 | |
... | ... | @@ -128,17 +128,17 @@ |
128 | 128 | static char __log_buf[__LOG_BUF_LEN]; |
129 | 129 | static char *log_buf = __log_buf; |
130 | 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 | 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 | 136 | unsigned long flags; |
137 | 137 | |
138 | 138 | if (size) |
139 | 139 | size = roundup_pow_of_two(size); |
140 | 140 | if (size > log_buf_len) { |
141 | - unsigned long start, dest_idx, offset; | |
141 | + unsigned start, dest_idx, offset; | |
142 | 142 | char *new_log_buf; |
143 | 143 | |
144 | 144 | new_log_buf = alloc_bootmem(size); |
... | ... | @@ -295,7 +295,7 @@ |
295 | 295 | */ |
296 | 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 | 299 | int do_clear = 0; |
300 | 300 | char c; |
301 | 301 | int error = 0; |
... | ... | @@ -436,7 +436,7 @@ |
436 | 436 | /* |
437 | 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 | 441 | struct console *con; |
442 | 442 | |
... | ... | @@ -463,8 +463,8 @@ |
463 | 463 | /* |
464 | 464 | * Write out chars from start to end - 1 inclusive |
465 | 465 | */ |
466 | -static void _call_console_drivers(unsigned long start, | |
467 | - unsigned long end, int msg_log_level) | |
466 | +static void _call_console_drivers(unsigned start, | |
467 | + unsigned end, int msg_log_level) | |
468 | 468 | { |
469 | 469 | if ((msg_log_level < console_loglevel || ignore_loglevel) && |
470 | 470 | console_drivers && start != end) { |
471 | 471 | |
472 | 472 | |
... | ... | @@ -484,12 +484,12 @@ |
484 | 484 | * log_buf[start] to log_buf[end - 1]. |
485 | 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 | 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 | 494 | cur_index = start; |
495 | 495 | start_print = start; |
... | ... | @@ -790,7 +790,7 @@ |
790 | 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 @@ |
983 | 983 | void release_console_sem(void) |
984 | 984 | { |
985 | 985 | unsigned long flags; |
986 | - unsigned long _con_start, _log_end; | |
987 | - unsigned long wake_klogd = 0; | |
986 | + unsigned _con_start, _log_end; | |
987 | + unsigned wake_klogd = 0; | |
988 | 988 | |
989 | 989 | if (console_suspended) { |
990 | 990 | up(&secondary_console_sem); |
... | ... | @@ -1275,7 +1275,7 @@ |
1275 | 1275 | int __printk_ratelimit(int ratelimit_jiffies, int ratelimit_burst) |
1276 | 1276 | { |
1277 | 1277 | static DEFINE_SPINLOCK(ratelimit_lock); |
1278 | - static unsigned long toks = 10 * 5 * HZ; | |
1278 | + static unsigned toks = 10 * 5 * HZ; | |
1279 | 1279 | static unsigned long last_msg; |
1280 | 1280 | static int missed; |
1281 | 1281 | unsigned long flags; |