Skip to content
Commit 2ecd9d29 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Paolo Bonzini
Browse files

sched, preempt_notifier: separate notifier registration from static_key inc/dec

Commit 1cde2930 ("sched/preempt: Add static_key() to preempt_notifiers")
had two problems.  First, the preempt-notifier API needs to sleep with the
addition of the static_key, we do however need to hold off preemption
while modifying the preempt notifier list, otherwise a preemption could
observe an inconsistent list state.  KVM correctly registers and
unregisters preempt notifiers with preemption disabled, so the sleep
caused dmesg splats.

Second, KVM registers and unregisters preemption notifiers very often
(in vcpu_load/vcpu_put).  With a single uniprocessor guest the static key
would move between 0 and 1 continuously, hitting the slow path on every
userspace exit.

To fix this, wrap the static_key inc/dec in a new API, and call it from
KVM.

Fixes: 1cde2930

 ("sched/preempt: Add static_key() to preempt_notifiers")
Reported-by: default avatarPontus Fuchs <pontus.fuchs@gmail.com>
Reported-by: default avatarTakashi Iwai <tiwai@suse.de>
Tested-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 9bdc771f
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment