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: <alpine.LNX.2.00.0909112318190.31018@swampdragon.chaosbits.net>
Date:	Fri, 11 Sep 2009 23:30:42 +0200 (CEST)
From:	Jesper Juhl <jj@...osbits.net>
To:	Ingo Molnar <mingo@...e.hu>
cc:	Linus Torvalds <torvalds@...ux-foundation.org>,
	linux-kernel@...r.kernel.org, "H. Peter Anvin" <hpa@...or.com>,
	Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [GIT PULL] x86/fpu for v2.6.32


Hi Ingo,

First of all, I want to say that I have no real objections to the patch 
what-so-ever. The following is merely to satisfy my own personal 
curiosity - and I'm sure you have better things to do than satisfy my 
curiosity, so if you want to ignore me; feel free :-)

On Fri, 11 Sep 2009, Ingo Molnar wrote:

[...]
> +	bool preload_fpu;
>  
>  	/* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
>  
> -	__unlazy_fpu(prev_p);
> +	/*
> +	 * If the task has used fpu the last 5 timeslices, just do a full
> +	 * restore of the math state immediately to avoid the trap; the
> +	 * chances of needing FPU soon are obviously high now
> +	 */
> +	preload_fpu = tsk_used_math(next_p) && next_p->fpu_counter > 5;
>  
> +	__unlazy_fpu(prev_p);
>  
[...]
> +	 * If the task has used fpu the last 5 timeslices, just do a full
> +	 * restore of the math state immediately to avoid the trap; the
> +	 * chances of needing FPU soon are obviously high now
> +	 */
> +	preload_fpu = tsk_used_math(next_p) && next_p->fpu_counter > 5;
>  

I'm wondering about two things:

1) Where did that magic constant "5" come from?
Is there some fundamental thing about CPU's, cache layout, scheduling, 
benchmarks or something else that I just don't know that makes 5 the magic 
"right number"?  Why not 2, 3, 9 or 42?

2) Instead of writing that constant "5" multiple places, wouldn't it be 
nicer to use a  '#define FPU_RESTORE_TIMESLICES 5'  or  'static const 
unsigned int FPU_RESTORE_TIMESLICES = 5;'  instead?
Personally I hate magic numbers that are used in more than one location. 
I'd much rather have a constant with a sane name defined once (with a 
comment explaining it) and then see the name used in multiple places.


That's all.  :)


-- 
Jesper Juhl <jj@...osbits.net>             http://www.chaosbits.net/
Plain text mails only, please      http://www.expita.com/nomime.html
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html

--
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