Re: [patch 1/3] x86/process: Optimize TIF checks in switch_to_extra()

From: Peter Zijlstra
Date: Thu Dec 15 2016 - 12:20:40 EST


On Thu, Dec 15, 2016 at 04:44:02PM -0000, Thomas Gleixner wrote:
> void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p,
> struct tss_struct *tss)
> {
> struct thread_struct *prev, *next;
> + unsigned long tifp, tifn;
>
> prev = &prev_p->thread;
> next = &next_p->thread;
>
> + tifn = task_thread_info(next_p)->flags;
> + tifp = task_thread_info(prev_p)->flags;
> + switch_to_bitmap(tss, prev, next, tifp, tifn);
> +
> + propagate_user_return_notify(prev_p, next_p);
> +
> + if ((tifp ^ tifn) & _TIF_BLOCKSTEP) {
> unsigned long debugctl = get_debugctlmsr();
>
> debugctl &= ~DEBUGCTLMSR_BTF;
> + if (tifn & _TIF_BLOCKSTEP)
> debugctl |= DEBUGCTLMSR_BTF;
> update_debugctlmsr(debugctl);
> }

Going by the toggle patter you have elsewhere, wouldn't that then be:

if ((tifp ^ tifn) & _TIF_BLOCKSTEP) {
unsigned long debugctl = get_debugctlmsr();

debugctl ^= DEBUGCTLMSR_BTF;
update_debugctlmsr(debugctl);
}

?