Re: [patch 1/2] sLeAZY FPU feature - x86_64 support

From: Andi Kleen
Date: Sat Jul 01 2006 - 17:48:53 EST



> After 256 switches, this is reset and lazy behavior is returned (until
> there are 5 consecutive ones again). The reason for this is to give apps
> that do longer bursts of FPU use still the lazy behavior back after some
> time.

Cool. This has been on my todo list forever.

However I'm not sure 256 is a good number. It seems a bit too high.

> Index: linux-2.6.17-sleazyfpu/arch/x86_64/kernel/process.c
> ===================================================================
> --- linux-2.6.17-sleazyfpu.orig/arch/x86_64/kernel/process.c
> +++ linux-2.6.17-sleazyfpu/arch/x86_64/kernel/process.c
> @@ -515,6 +515,10 @@ __switch_to(struct task_struct *prev_p,
> int cpu = smp_processor_id();
> struct tss_struct *tss = &per_cpu(init_tss, cpu);
>
> + /* we're going to use this soon, after a few expensive things */
> + if (next_p->fpu_counter>5)
> + prefetch(&next->i387.fxsave);

Did you measure this prefetch makes a difference? I would expect it to
be too soon to be really worth while (normally you need hundreds of
instructions for them to make sense and that's probably not the case here)

> #endif
> + /*
> + * fpu_counter contains the number of consecutive context switches
> + * that the FPU is used. If this is over a threshold, the lazy fpu
> + * saving becomes unlazy to save the trap. This is an unsigned char
> + * so that after 256 times the counter wraps and the behavior turns
> + * lazy again; this to deal with bursty apps that only use FPU for
> + * a short time
> + */
> + unsigned char fpu_counter;

Putting it at the end is also not good because there are the rarely used
cachelines. Probably better in the thread structure
-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/