]> git.baikalelectronics.ru Git - kernel.git/commit
sched, preempt_notifier: separate notifier registration from static_key inc/dec
authorPeter Zijlstra <peterz@infradead.org>
Fri, 3 Jul 2015 16:53:58 +0000 (18:53 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 3 Jul 2015 16:55:00 +0000 (18:55 +0200)
commiteb16681d62d3e513cebd5f5c886431c65a5e4a61
tree2c31785e4dff264db31ee0dea5f74c5d29905898
parentc771d6bb6309e7d82a0b05216e708e86da44d7a8
sched, preempt_notifier: separate notifier registration from static_key inc/dec

Commit 9dc0b8df0f33 ("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: 9dc0b8df0f33 ("sched/preempt: Add static_key() to preempt_notifiers")
Reported-by: Pontus Fuchs <pontus.fuchs@gmail.com>
Reported-by: Takashi Iwai <tiwai@suse.de>
Tested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/linux/preempt.h
kernel/sched/core.c
virt/kvm/kvm_main.c