mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-11-28 12:35:22 +08:00
KVM: PPC: exit halt polling on need_resched()
This is inspired by commit 262de4102c
(kvm: exit halt polling on
need_resched() as well). Due to PPC implements an arch specific halt
polling logic, we have to the need_resched() check there as well. This
patch adds a helper function that can be shared between book3s and generic
halt-polling loops.
Reviewed-by: David Matlack <dmatlack@google.com>
Reviewed-by: Venkatesh Srinivas <venkateshs@chromium.org>
Cc: Ben Segall <bsegall@google.com>
Cc: Venkatesh Srinivas <venkateshs@chromium.org>
Cc: Jim Mattson <jmattson@google.com>
Cc: David Matlack <dmatlack@google.com>
Cc: Paul Mackerras <paulus@ozlabs.org>
Cc: Suraj Jitindar Singh <sjitindarsingh@gmail.com>
Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
Message-Id: <1621339235-11131-1-git-send-email-wanpengli@tencent.com>
[Make the function inline. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
28a4aa1160
commit
6bd5b74368
@ -3936,7 +3936,7 @@ static void kvmppc_vcore_blocked(struct kvmppc_vcore *vc)
|
||||
break;
|
||||
}
|
||||
cur = ktime_get();
|
||||
} while (single_task_running() && ktime_before(cur, stop));
|
||||
} while (kvm_vcpu_can_poll(cur, stop));
|
||||
|
||||
spin_lock(&vc->lock);
|
||||
vc->vcore_state = VCORE_INACTIVE;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/signal.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/sched/stat.h>
|
||||
#include <linux/bug.h>
|
||||
#include <linux/minmax.h>
|
||||
#include <linux/mm.h>
|
||||
@ -265,6 +266,11 @@ static inline bool kvm_vcpu_mapped(struct kvm_host_map *map)
|
||||
return !!map->hva;
|
||||
}
|
||||
|
||||
static inline bool kvm_vcpu_can_poll(ktime_t cur, ktime_t stop)
|
||||
{
|
||||
return single_task_running() && !need_resched() && ktime_before(cur, stop);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sometimes a large or cross-page mmio needs to be broken up into separate
|
||||
* exits for userspace servicing.
|
||||
|
@ -2973,8 +2973,7 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu)
|
||||
goto out;
|
||||
}
|
||||
poll_end = cur = ktime_get();
|
||||
} while (single_task_running() && !need_resched() &&
|
||||
ktime_before(cur, stop));
|
||||
} while (kvm_vcpu_can_poll(cur, stop));
|
||||
}
|
||||
|
||||
prepare_to_rcuwait(&vcpu->wait);
|
||||
|
Loading…
Reference in New Issue
Block a user