Re: [PATCH v4 0/3] qspinlock: Introducing a 4-byte queue spinlock

From: Waiman Long
Date: Thu Feb 20 2014 - 12:54:25 EST


On 02/19/2014 03:17 PM, Linus Torvalds wrote:
On Wed, Feb 19, 2014 at 11:24 AM, Waiman Long<waiman.long@xxxxxx> wrote:
We do have a CONFIG_PARAVIRT macro that turns on or off PV support. The
queue spinlock can be easily changed into an unfair lock which allows lock
stealing. We could have a config option to make it unfair in the PARAVIRT
environment, but I don't think Linus like the idea of an unfair lock.
I could care less for the paravirt case. As long as the native case
ends up being sane (even when CONFIG_PARAVIRT is set at compile time),
I'm fine.

When actually running in a paravirtualized environment, locks are
always going to have problems.

Linus

I think we could implement 2 versions of _raw_spin_lock. The primary one is fair and the other one is unfair with a jump label that jump from the fair version to the unfair version. At boot time, the kernel can check to see it is really running in a PV environment and then activate the jump label to use the unfair version.

Now the key is how to detect if a kernel is really running in a PV environment. I need to ask some virtualization experts on that.

-Longman
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/