diff mbox

[v2,2/2] Input: amikbd - Allocate temporary keymap buffer on the stack

Message ID 1417339820-5285-2-git-send-email-geert@linux-m68k.org (mailing list archive)
State New, archived
Headers show

Commit Message

Geert Uytterhoeven Nov. 30, 2014, 9:30 a.m. UTC
Allocate the temporary buffer needed for initialization of the console
keyboard maps (512 bytes, as NR_KEYS = 256) on the stack instead of
statically, to reduce kernel size.

add/remove: 0/1 grow/shrink: 0/0 up/down: 0/-512 (-512)
function                                     old     new   delta
temp_map                                     512       -    -512

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
v2:
  - Allocate temp_map[] on the stack instead of using kmalloc().
---
 drivers/input/keyboard/amikbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dmitry Torokhov Dec. 3, 2014, 10:59 p.m. UTC | #1
On Sun, Nov 30, 2014 at 10:30:20AM +0100, Geert Uytterhoeven wrote:
> Allocate the temporary buffer needed for initialization of the console
> keyboard maps (512 bytes, as NR_KEYS = 256) on the stack instead of
> statically, to reduce kernel size.
> 
> add/remove: 0/1 grow/shrink: 0/0 up/down: 0/-512 (-512)
> function                                     old     new   delta
> temp_map                                     512       -    -512

So because it is marked __initdata and is placed into a separate
section we have to allocate the space in the image?

Anyway, applied both, thank you.

> 
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> v2:
>   - Allocate temp_map[] on the stack instead of using kmalloc().
> ---
>  drivers/input/keyboard/amikbd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c
> index 4f81e65d9e35cb7d..60580d8104b9f970 100644
> --- a/drivers/input/keyboard/amikbd.c
> +++ b/drivers/input/keyboard/amikbd.c
> @@ -147,10 +147,10 @@ static unsigned char amikbd_keycode[0x78] __initdata = {
>  
>  static void __init amikbd_init_console_keymaps(void)
>  {
> +	unsigned short temp_map[NR_KEYS];
>  	int i, j;
>  
>  	for (i = 0; i < MAX_NR_KEYMAPS; i++) {
> -		static u_short temp_map[NR_KEYS] __initdata;
>  		if (!key_maps[i])
>  			continue;
>  		memset(temp_map, 0, sizeof(temp_map));
> -- 
> 1.9.1
>
Geert Uytterhoeven Dec. 4, 2014, 9 a.m. UTC | #2
Hi Dmitry,

On Wed, Dec 3, 2014 at 11:59 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Sun, Nov 30, 2014 at 10:30:20AM +0100, Geert Uytterhoeven wrote:
>> Allocate the temporary buffer needed for initialization of the console
>> keyboard maps (512 bytes, as NR_KEYS = 256) on the stack instead of
>> statically, to reduce kernel size.
>>
>> add/remove: 0/1 grow/shrink: 0/0 up/down: 0/-512 (-512)
>> function                                     old     new   delta
>> temp_map                                     512       -    -512
>
> So because it is marked __initdata and is placed into a separate
> section we have to allocate the space in the image?

Indeed. __initdata consumes space in both the vmlinux image and in
memory.
Note that we don't have __initbss for uninitialized data, which would
obviously still consume space in memory.

> Anyway, applied both, thank you.

Thanks!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c
index 4f81e65d9e35cb7d..60580d8104b9f970 100644
--- a/drivers/input/keyboard/amikbd.c
+++ b/drivers/input/keyboard/amikbd.c
@@ -147,10 +147,10 @@  static unsigned char amikbd_keycode[0x78] __initdata = {
 
 static void __init amikbd_init_console_keymaps(void)
 {
+	unsigned short temp_map[NR_KEYS];
 	int i, j;
 
 	for (i = 0; i < MAX_NR_KEYMAPS; i++) {
-		static u_short temp_map[NR_KEYS] __initdata;
 		if (!key_maps[i])
 			continue;
 		memset(temp_map, 0, sizeof(temp_map));