mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-04 14:36:55 +00:00
Commitd575edf79a
changes the internal implementation of wait_event and signal_event to use a counter instead of a boolean value. The background was: ACRN utilizes vcpu_make_request and signal_event pair to shoot down other vcpus and let them wait for signals. vcpu_make_request eventually leads to target vcpu calling wait_event. However vcpu_make_request/signal_event pair was not thread-safe, and concurrent calls of this pair of API could lead to problems. One such example is the concurrent wbinvd emulation, where vcpus may concurrently issue vcpu_make_request/signal_event to synchronize wbinvd emulation.d575edf
commit uses a counter in internal implementation of wait_event/signal_event to avoid data races. However by using a counter, the wait/signal pair now carries semantics of semaphores instead of events. Semaphores require caller to carefully plan their calls instead of multiply signaling any number of times to the same event, which deviates from the original "event" semantics. This patch changes the API implementation back to boolean-based, and re-resolve the issue of concurrent wbinvd in next patch. This also partially reverts commit10963b04d1
, which was introduced because of thed575edf
. Tracked-On: #7887 Signed-off-by: Yifan Liu <yifan1.liu@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
17 lines
357 B
C
17 lines
357 B
C
#ifndef EVENT_H
|
|
#define EVENT_H
|
|
#include <asm/lib/spinlock.h>
|
|
|
|
struct sched_event {
|
|
spinlock_t lock;
|
|
bool set;
|
|
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 */
|