acrn-hypervisor/hypervisor/include/common/event.h
Yifan Liu ffc142d9be hv: sched_event: Change nqueued from int8_t to int32_t
This patch changes the type of nqueued in struct sched_event from int8_t
to int32_t.

In commit d575edf79, the 1 bit flag in struct sched_event has been
changed to int8_t counter to resolve race condition. Signal_event
will decrease the counter and wait_event will increase it and loop if
the counter is greater than 0.

In most cases the uses of signal_event and wait_event are consistent,
except VCPU_EVENT_VIRTUAL_INTERRUPT. In our logic, we signal this event
whenever there is an virtual interrupt, but we wait on it only in
hlt_vmexit_handler, and we reset this event before VMEnter.

In most cases this worked fine. However it has been found that in
certain GPU stress testing scenario, the signaling of this event
happened too frequently to the point where this int8_t counter underflowed
(i.e., hit -128 and then became 127). Then in subsequent
hlt_vmexit_handler, hv waited on this event and stuck there as the
counter was too large.

This patch changes the type from int8_t to int32_t to avoid underflow.

Tracked-On: #7567
Signed-off-by: Yifan Liu <yifan1.liu@intel.com>
2022-05-25 09:37:04 +08:00

17 lines
364 B
C

#ifndef EVENT_H
#define EVENT_H
#include <asm/lib/spinlock.h>
struct sched_event {
spinlock_t lock;
int32_t nqueued;
struct thread_object* waiting_thread;
};
void init_event(struct sched_event *event);
void reset_event(struct sched_event *event);
void wait_event(struct sched_event *event);
void signal_event(struct sched_event *event);
#endif /* EVENT_H */