[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALCETrUOiN92SjeNJjNeY+=QWk84EBWF6xS6nv6JL+tL5CKBCQ@mail.gmail.com>
Date: Mon, 18 Jan 2016 09:49:31 -0800
From: Andy Lutomirski <luto@...capital.net>
To: Brian Gerst <brgerst@...il.com>
Cc: Borislav Petkov <bp@...e.de>,
"the arch/x86 maintainers" <x86@...nel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>,
Denys Vlasenko <dvlasenk@...hat.com>,
Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH] x86: static_cpu_has_safe: discard dynamic check after init
On Mon, Jan 18, 2016 at 8:52 AM, Brian Gerst <brgerst@...il.com> wrote:
> On Sun, Jan 17, 2016 at 5:33 AM, Borislav Petkov <bp@...e.de> wrote:
>> On Sat, Jan 16, 2016 at 02:58:21PM -0500, Brian Gerst wrote:
>>> It saves space. The only thing left in main text is one jump
>>> instruction (5 bytes).
>>
>> How do I measure this?
>>
>> Because with my tailored config here, the only thing I'm seeing is a growth of
>> text by 730 bytes:
>>
>> before:
>> text data bss dec hex filename
>> 10926552 3598944 16642048 31167544 1db9438 vmlinux
>>
>> [ 0.056552] Freeing SMP alternatives memory: 24K (ffffffff81dd7000 - ffffffff81ddd000)
>> [ 2.883728] Freeing unused kernel memory: 2904K (ffffffff81b01000 - ffffffff81dd7000)
>>
>>
>> after:
>> text data bss dec hex filename
>> 10927282 3598944 16642048 31168274 1db9712 vmlinux
>>
>> [ 0.052559] Freeing SMP alternatives memory: 24K (ffffffff81dd7000 - ffffffff81ddd000)
>> [ 3.225318] Freeing unused kernel memory: 2904K (ffffffff81b01000 - ffffffff81dd7000)
>
> It is due to page alignment padding. It was not enough to lose a
> whole page from .text in your case.
>
> The size command includes any section that is marked executable in the
> text count, including init text. If you use readelf -S vmlinux.o
> instead you will notice that .text is the same size or smaller, and
> .static_cpu_has (which is freed after boot) is the difference.
>
If I'm understanding this correctly, the total non-init overhead from
static_cpu_has_safe with your patch is five bytes. I'd imagine that
the short jmp optimization in regular static_cpu_has essentially never
works, which means it will also use five bytes of text, which makes me
wonder whether we should just make static_cpu_has safe and remove the
distinction.
Also, someone should write a little script to measure kernel size
minus .init stuff.
--Andy
Powered by blists - more mailing lists