Re: [PATCH 1/2] x86: eliminate TS_XSAVE

H. Peter Anvin
2010-05-04T18:24:02Z

On 05/04/2010 11:15 AM, Suresh Siddha wrote:
> On Tue, 2010-05-04 at 00:41 -0700, Avi Kivity wrote:
>> On 05/04/2010 12:45 AM, H. Peter Anvin wrote:
>>>
>>>> I was trying to avoid a performance regression relative to the current
>>>> code, as it appears that some care was taken to avoid the memory reference.
>>>>
>>>> I agree that it's probably negligible compared to the save/restore
>>>> code. If the x86 maintainers agree as well, I'll replace it with
>>>> cpu_has_xsave.
>>>>
>>>>
>>> I asked Suresh to comment on this, since he wrote the original code. He
>>> did confirm that the intent was to avoid a global memory reference.
>>>
>>>
>>
>> Ok, so you're happy with the patch as is?
>
> As use_xsave() is in the hot context switch path, I would like to go
> with Avi's proposal.
>

I would tend to agree. Saving a likely cache miss in the hot context
switch path is worthwhile.

I would like to request one change, however. I would like to see the
alternatives code to be:

movb $0,reg
movb $1,reg

... instead of using xor (which has to be padded with NOPs, which is of
course pointless since the slot is a fixed size.) I would suggest using
a byte-sized variable instead of a dword-size variable to save a few
bytes, too.

Once the jump label framework is integrated and has matured, I think we
should consider using it to save the mov/test/jump.

-hpa