mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-25 06:51:49 +00:00
hv: clear NEED_RESCHEDULE flag in schedule
Now, need_reschedule will test_and_clear the bit NEED_RESCHEDULE in schedule context, then call schedule. It is not a exact match with the name. This patch move the flag clearing into scheudle, and need_reschedule just check and return. Tracked-On: #1821 Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com> Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
This commit is contained in:
parent
2c70a1e115
commit
3e9f4b958d
@ -44,7 +44,7 @@ void vcpu_thread(struct acrn_vcpu *vcpu)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (need_reschedule(vcpu->pcpu_id) != 0) {
|
||||
if (need_reschedule(vcpu->pcpu_id)) {
|
||||
/*
|
||||
* In extrem case, schedule() could return. Which
|
||||
* means the vcpu resume happens before schedule()
|
||||
|
@ -106,11 +106,11 @@ void make_reschedule_request(const struct acrn_vcpu *vcpu)
|
||||
}
|
||||
}
|
||||
|
||||
int32_t need_reschedule(uint16_t pcpu_id)
|
||||
bool need_reschedule(uint16_t pcpu_id)
|
||||
{
|
||||
struct sched_context *ctx = &per_cpu(sched_ctx, pcpu_id);
|
||||
|
||||
return bitmap_test_and_clear_lock(NEED_RESCHEDULE, &ctx->flags);
|
||||
return bitmap_test(NEED_RESCHEDULE, &ctx->flags);
|
||||
}
|
||||
|
||||
static void context_switch_out(struct acrn_vcpu *vcpu)
|
||||
@ -172,7 +172,7 @@ void default_idle(void)
|
||||
uint16_t pcpu_id = get_cpu_id();
|
||||
|
||||
while (1) {
|
||||
if (need_reschedule(pcpu_id) != 0) {
|
||||
if (need_reschedule(pcpu_id)) {
|
||||
schedule();
|
||||
} else if (need_offline(pcpu_id) != 0) {
|
||||
cpu_dead();
|
||||
@ -225,11 +225,13 @@ static void switch_to(struct acrn_vcpu *curr)
|
||||
void schedule(void)
|
||||
{
|
||||
uint16_t pcpu_id = get_cpu_id();
|
||||
struct sched_context *ctx = &per_cpu(sched_ctx, pcpu_id);
|
||||
struct acrn_vcpu *next = NULL;
|
||||
struct acrn_vcpu *prev = per_cpu(sched_ctx, pcpu_id).curr_vcpu;
|
||||
struct acrn_vcpu *prev = ctx->curr_vcpu;
|
||||
|
||||
get_schedule_lock(pcpu_id);
|
||||
next = select_next_vcpu(pcpu_id);
|
||||
bitmap_clear_lock(NEED_RESCHEDULE, &ctx->flags);
|
||||
|
||||
if (prev == next) {
|
||||
release_schedule_lock(pcpu_id);
|
||||
|
@ -32,7 +32,7 @@ void remove_vcpu_from_runqueue(struct acrn_vcpu *vcpu);
|
||||
void default_idle(void);
|
||||
|
||||
void make_reschedule_request(const struct acrn_vcpu *vcpu);
|
||||
int32_t need_reschedule(uint16_t pcpu_id);
|
||||
bool need_reschedule(uint16_t pcpu_id);
|
||||
void make_pcpu_offline(uint16_t pcpu_id);
|
||||
int32_t need_offline(uint16_t pcpu_id);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user