lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87mvtubcst.fsf@rasmusvillemoes.dk>
Date:	Tue, 01 Dec 2015 12:58:42 +0100
From:	Rasmus Villemoes <linux@...musvillemoes.dk>
To:	Ingo Molnar <mingo@...nel.org>
Cc:	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...hat.com>,
	"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
	linux-kernel@...r.kernel.org, Borislav Petkov <bp@...en8.de>,
	Toshi Kani <toshi.kani@...com>
Subject: Re: [PATCH] x86, mtrr: mark range_new in mtrr_calc_range_state() as __initdata

On Fri, Nov 27 2015, Ingo Molnar <mingo@...nel.org> wrote:

> * Rasmus Villemoes <linux@...musvillemoes.dk> wrote:
>
>> range_new doesn't seem to be used after init. It is only passed to
>> memset, sum_ranges, memcmp and x86_get_mtrr_mem_range, the latter of
>> which also only passes it on to various *range* library functions. So
>> mark it __initdata to free up an extra page after init.
>> 
>> nr_range_new is unconditionally assigned to before it is read, so
>> there's no point in having it static.
>> 
>> Signed-off-by: Rasmus Villemoes <linux@...musvillemoes.dk>
>> ---
>>  arch/x86/kernel/cpu/mtrr/cleanup.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/arch/x86/kernel/cpu/mtrr/cleanup.c b/arch/x86/kernel/cpu/mtrr/cleanup.c
>> index 70d7c93f4550..b1a9ad366f67 100644
>> --- a/arch/x86/kernel/cpu/mtrr/cleanup.c
>> +++ b/arch/x86/kernel/cpu/mtrr/cleanup.c
>> @@ -593,9 +593,9 @@ mtrr_calc_range_state(u64 chunk_size, u64 gran_size,
>>  		      unsigned long x_remove_base,
>>  		      unsigned long x_remove_size, int i)
>>  {
>> -	static struct range range_new[RANGE_NUM];
>> +	static struct range range_new[RANGE_NUM] __initdata;
>>  	unsigned long range_sums_new;
>> -	static int nr_range_new;
>> +	int nr_range_new;
>>  	int num_reg;
>>  
>>  	/* Convert ranges to var ranges state: */
>
> So this static variable actually surprised me - I never realized it was there - 
> and it's not some simple 'once' flag, but something that is essential semantics.
>
> So marking it __initdata is correct, but please also move it out of function local 
> variables scope, into file scope - and name it properly as well, like 
> mtrr_new_range[] or so?

I can certainly do that, but isn't the usual preference to keep the
scope as small as possible? IOW, why do you want to make this a
file-scoped variable?

Also, I don't really see how the 'static' has 'essential semantics'. AFAICT, the
contents are wiped on every invocation of mtrr_calc_range_state, so the
only reason it's static is to avoid blowing the stack.

Rasmus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ