Commit cf3b429b authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds

vsprintf.c: use noinline_for_stack

Mark static functions with noinline_for_stack

Before:

  akpm:/usr/src/25> objdump -d lib/vsprintf.o | perl scripts/checkstack.pl
  0x00000e82 pointer [vsprintf.o]:                        344
  0x0000198c pointer [vsprintf.o]:                        344
  0x000025d6 scnprintf [vsprintf.o]:                      216
  0x00002648 scnprintf [vsprintf.o]:                      216
  0x00002565 snprintf [vsprintf.o]:                       208
  0x0000267c sprintf [vsprintf.o]:                        208
  0x000030a3 bprintf [vsprintf.o]:                        208
  0x00003b1e sscanf [vsprintf.o]:                         208
  0x00000608 number [vsprintf.o]:                         136
  0x00000937 number [vsprintf.o]:                         136

After:

  akpm:/usr/src/25> objdump -d lib/vsprintf.o | perl scripts/checkstack.pl
  0x00000a7c symbol_string [vsprintf.o]:                  248
  0x00000ae8 symbol_string [vsprintf.o]:                  248
  0x00002310 scnprintf [vsprintf.o]:                      216
  0x00002382 scnprintf [vsprintf.o]:                      216
  0x0000229f snprintf [vsprintf.o]:                       208
  0x000023b6 sprintf [vsprintf.o]:                        208
  0x00002ddd bprintf [vsprintf.o]:                        208
  0x00003858 sscanf [vsprintf.o]:                         208
  0x00000625 number [vsprintf.o]:                         136
  0x00000954 number [vsprintf.o]:                         136
Signed-off-by: default avatarJoe Perches <joe@perches.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 59592d0c
...@@ -267,7 +267,8 @@ int strict_strtoll(const char *cp, unsigned int base, long long *res) ...@@ -267,7 +267,8 @@ int strict_strtoll(const char *cp, unsigned int base, long long *res)
} }
EXPORT_SYMBOL(strict_strtoll); EXPORT_SYMBOL(strict_strtoll);
static int skip_atoi(const char **s) static noinline_for_stack
int skip_atoi(const char **s)
{ {
int i = 0; int i = 0;
...@@ -287,7 +288,8 @@ static int skip_atoi(const char **s) ...@@ -287,7 +288,8 @@ static int skip_atoi(const char **s)
/* Formats correctly any integer in [0,99999]. /* Formats correctly any integer in [0,99999].
* Outputs from one to five digits depending on input. * Outputs from one to five digits depending on input.
* On i386 gcc 4.1.2 -O2: ~250 bytes of code. */ * On i386 gcc 4.1.2 -O2: ~250 bytes of code. */
static char *put_dec_trunc(char *buf, unsigned q) static noinline_for_stack
char *put_dec_trunc(char *buf, unsigned q)
{ {
unsigned d3, d2, d1, d0; unsigned d3, d2, d1, d0;
d1 = (q>>4) & 0xf; d1 = (q>>4) & 0xf;
...@@ -324,7 +326,8 @@ static char *put_dec_trunc(char *buf, unsigned q) ...@@ -324,7 +326,8 @@ static char *put_dec_trunc(char *buf, unsigned q)
return buf; return buf;
} }
/* Same with if's removed. Always emits five digits */ /* Same with if's removed. Always emits five digits */
static char *put_dec_full(char *buf, unsigned q) static noinline_for_stack
char *put_dec_full(char *buf, unsigned q)
{ {
/* BTW, if q is in [0,9999], 8-bit ints will be enough, */ /* BTW, if q is in [0,9999], 8-bit ints will be enough, */
/* but anyway, gcc produces better code with full-sized ints */ /* but anyway, gcc produces better code with full-sized ints */
...@@ -366,7 +369,8 @@ static char *put_dec_full(char *buf, unsigned q) ...@@ -366,7 +369,8 @@ static char *put_dec_full(char *buf, unsigned q)
return buf; return buf;
} }
/* No inlining helps gcc to use registers better */ /* No inlining helps gcc to use registers better */
static noinline char *put_dec(char *buf, unsigned long long num) static noinline_for_stack
char *put_dec(char *buf, unsigned long long num)
{ {
while (1) { while (1) {
unsigned rem; unsigned rem;
...@@ -417,7 +421,8 @@ struct printf_spec { ...@@ -417,7 +421,8 @@ struct printf_spec {
s16 precision; /* # of digits/chars */ s16 precision; /* # of digits/chars */
}; };
static char *number(char *buf, char *end, unsigned long long num, static noinline_for_stack
char *number(char *buf, char *end, unsigned long long num,
struct printf_spec spec) struct printf_spec spec)
{ {
/* we are called with base 8, 10 or 16, only, thus don't need "G..." */ /* we are called with base 8, 10 or 16, only, thus don't need "G..." */
...@@ -537,7 +542,8 @@ static char *number(char *buf, char *end, unsigned long long num, ...@@ -537,7 +542,8 @@ static char *number(char *buf, char *end, unsigned long long num,
return buf; return buf;
} }
static char *string(char *buf, char *end, const char *s, struct printf_spec spec) static noinline_for_stack
char *string(char *buf, char *end, const char *s, struct printf_spec spec)
{ {
int len, i; int len, i;
...@@ -567,7 +573,8 @@ static char *string(char *buf, char *end, const char *s, struct printf_spec spec ...@@ -567,7 +573,8 @@ static char *string(char *buf, char *end, const char *s, struct printf_spec spec
return buf; return buf;
} }
static char *symbol_string(char *buf, char *end, void *ptr, static noinline_for_stack
char *symbol_string(char *buf, char *end, void *ptr,
struct printf_spec spec, char ext) struct printf_spec spec, char ext)
{ {
unsigned long value = (unsigned long) ptr; unsigned long value = (unsigned long) ptr;
...@@ -588,7 +595,8 @@ static char *symbol_string(char *buf, char *end, void *ptr, ...@@ -588,7 +595,8 @@ static char *symbol_string(char *buf, char *end, void *ptr,
#endif #endif
} }
static char *resource_string(char *buf, char *end, struct resource *res, static noinline_for_stack
char *resource_string(char *buf, char *end, struct resource *res,
struct printf_spec spec, const char *fmt) struct printf_spec spec, const char *fmt)
{ {
#ifndef IO_RSRC_PRINTK_SIZE #ifndef IO_RSRC_PRINTK_SIZE
...@@ -690,7 +698,8 @@ static char *resource_string(char *buf, char *end, struct resource *res, ...@@ -690,7 +698,8 @@ static char *resource_string(char *buf, char *end, struct resource *res,
return string(buf, end, sym, spec); return string(buf, end, sym, spec);
} }
static char *mac_address_string(char *buf, char *end, u8 *addr, static noinline_for_stack
char *mac_address_string(char *buf, char *end, u8 *addr,
struct printf_spec spec, const char *fmt) struct printf_spec spec, const char *fmt)
{ {
char mac_addr[sizeof("xx:xx:xx:xx:xx:xx")]; char mac_addr[sizeof("xx:xx:xx:xx:xx:xx")];
...@@ -714,7 +723,8 @@ static char *mac_address_string(char *buf, char *end, u8 *addr, ...@@ -714,7 +723,8 @@ static char *mac_address_string(char *buf, char *end, u8 *addr,
return string(buf, end, mac_addr, spec); return string(buf, end, mac_addr, spec);
} }
static char *ip4_string(char *p, const u8 *addr, const char *fmt) static noinline_for_stack
char *ip4_string(char *p, const u8 *addr, const char *fmt)
{ {
int i; int i;
bool leading_zeros = (fmt[0] == 'i'); bool leading_zeros = (fmt[0] == 'i');
...@@ -763,7 +773,8 @@ static char *ip4_string(char *p, const u8 *addr, const char *fmt) ...@@ -763,7 +773,8 @@ static char *ip4_string(char *p, const u8 *addr, const char *fmt)
return p; return p;
} }
static char *ip6_compressed_string(char *p, const char *addr) static noinline_for_stack
char *ip6_compressed_string(char *p, const char *addr)
{ {
int i, j, range; int i, j, range;
unsigned char zerolength[8]; unsigned char zerolength[8];
...@@ -843,7 +854,8 @@ static char *ip6_compressed_string(char *p, const char *addr) ...@@ -843,7 +854,8 @@ static char *ip6_compressed_string(char *p, const char *addr)
return p; return p;
} }
static char *ip6_string(char *p, const char *addr, const char *fmt) static noinline_for_stack
char *ip6_string(char *p, const char *addr, const char *fmt)
{ {
int i; int i;
...@@ -858,7 +870,8 @@ static char *ip6_string(char *p, const char *addr, const char *fmt) ...@@ -858,7 +870,8 @@ static char *ip6_string(char *p, const char *addr, const char *fmt)
return p; return p;
} }
static char *ip6_addr_string(char *buf, char *end, const u8 *addr, static noinline_for_stack
char *ip6_addr_string(char *buf, char *end, const u8 *addr,
struct printf_spec spec, const char *fmt) struct printf_spec spec, const char *fmt)
{ {
char ip6_addr[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255")]; char ip6_addr[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255")];
...@@ -871,7 +884,8 @@ static char *ip6_addr_string(char *buf, char *end, const u8 *addr, ...@@ -871,7 +884,8 @@ static char *ip6_addr_string(char *buf, char *end, const u8 *addr,
return string(buf, end, ip6_addr, spec); return string(buf, end, ip6_addr, spec);
} }
static char *ip4_addr_string(char *buf, char *end, const u8 *addr, static noinline_for_stack
char *ip4_addr_string(char *buf, char *end, const u8 *addr,
struct printf_spec spec, const char *fmt) struct printf_spec spec, const char *fmt)
{ {
char ip4_addr[sizeof("255.255.255.255")]; char ip4_addr[sizeof("255.255.255.255")];
...@@ -881,7 +895,8 @@ static char *ip4_addr_string(char *buf, char *end, const u8 *addr, ...@@ -881,7 +895,8 @@ static char *ip4_addr_string(char *buf, char *end, const u8 *addr,
return string(buf, end, ip4_addr, spec); return string(buf, end, ip4_addr, spec);
} }
static char *uuid_string(char *buf, char *end, const u8 *addr, static noinline_for_stack
char *uuid_string(char *buf, char *end, const u8 *addr,
struct printf_spec spec, const char *fmt) struct printf_spec spec, const char *fmt)
{ {
char uuid[sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")]; char uuid[sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")];
...@@ -970,7 +985,8 @@ static char *uuid_string(char *buf, char *end, const u8 *addr, ...@@ -970,7 +985,8 @@ static char *uuid_string(char *buf, char *end, const u8 *addr,
* function pointers are really function descriptors, which contain a * function pointers are really function descriptors, which contain a
* pointer to the real address. * pointer to the real address.
*/ */
static char *pointer(const char *fmt, char *buf, char *end, void *ptr, static noinline_for_stack
char *pointer(const char *fmt, char *buf, char *end, void *ptr,
struct printf_spec spec) struct printf_spec spec)
{ {
if (!ptr) if (!ptr)
...@@ -1040,7 +1056,8 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, ...@@ -1040,7 +1056,8 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr,
* @precision: precision of a number * @precision: precision of a number
* @qualifier: qualifier of a number (long, size_t, ...) * @qualifier: qualifier of a number (long, size_t, ...)
*/ */
static int format_decode(const char *fmt, struct printf_spec *spec) static noinline_for_stack
int format_decode(const char *fmt, struct printf_spec *spec)
{ {
const char *start = fmt; const char *start = fmt;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment