Re: [PATCH 1/2] x86/nmi: Optimize the check for being in the repeat_nmi code

From: Andy Lutomirski
Date: Thu Mar 09 2017 - 21:43:29 EST


On Thu, Mar 9, 2017 at 2:42 PM, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> From: "Steven Rostedt (Red Hat)" <rostedt@xxxxxxxxxxx>
>
> Linus mentioned that doing two compares can be replaced by a single
> compare. That is, instead of:
>
> movq $repeat_nmi, %rdx
> cmpq 8(%rsp), %rdx
> ja not_in_region
> movq $end_repeat_nmi, %rdx
> cmpq 8(%rsp), %rdx
> ja in_region
>
> we can replace that with:
>
> movq 8(%rsp), %rdx
> subq $repeat_nmi, %rdx
> cmpq $end_repeat_nmi-repeat_nmi, %rdx
> jb in_region

Seems reasonable to me. Good luck ever noticing the speedup :)

--Andy