Re: [PATCH v2] x86/vdso: Use RDPID in preference to LSL when available

From: Borislav Petkov
Date: Thu Apr 21 2016 - 12:26:37 EST


On Thu, Apr 21, 2016 at 08:25:45AM -0700, Andy Lutomirski wrote:
> Didn't I?

Bah, I cut off the line which has the "=a" and then did the commenting.
Sorry about the noise.

> I thought about it, and there were two reasons:
>
> 1. I don't think we want to use __getcpu in the kernel. LSL is fairly
> slow, and we'd still need to mask off the node number.
> raw_smp_processor_id(), in contrast, is a single load.

Right.

> 2. I have no way to benchmark this thing. I'm assuming the RDPID will
> be faster than LSL, but that doesn't mean it's faster than a load.
> (It could be -- it will save a cache line.)

But the RDPID reads an MSR. So it probably is microcode and thus slower
than a load... I guess one of the reasons for the RDPID is to avoid the
serialization cost of RDTSCP.

> So we might actually want something that does an alternative where the
> two choices are the percpu load and RDPID ; AND, but that wouldn't end
> up sharing code. But I'll leave that to someone with an actual
> RDPID-supporting CPU :)

Right.

--
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.