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

From: Andy Lutomirski
Date: Thu Mar 09 2017 - 22:51:29 EST


On Thu, Mar 9, 2017 at 7:49 PM, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
>
> On March 9, 2017 9:42:57 PM EST, Andy Lutomirski <luto@xxxxxxxxxxxxxx> wrote:
>>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 :)
>>
>
> It had nothing to do with speedup. Linus said that the current code makes the assembly programmer in him die a little. I want to cure that.
>

One might argue that the world would be a better place if the assembly
programmer in some people died a little.