-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split vcpu lock #81
base: upstream
Are you sure you want to change the base?
Split vcpu lock #81
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -296,7 +296,8 @@ bool psci_secondary_vm_handler(struct vcpu *vcpu, uint32_t func, uintreg_t arg0, | |
cpu_id_t target_affinity = arg0; | ||
uint32_t lowest_affinity_level = arg1; | ||
struct vm *vm = vcpu->vm; | ||
struct vcpu_locked target_vcpu; | ||
struct vcpu *target_vcpu; | ||
struct vcpu_execution_locked target_vcpu_locked; | ||
spci_vcpu_index_t target_vcpu_index = | ||
vcpu_id_to_index(target_affinity); | ||
|
||
|
@@ -311,10 +312,20 @@ bool psci_secondary_vm_handler(struct vcpu *vcpu, uint32_t func, uintreg_t arg0, | |
break; | ||
} | ||
|
||
target_vcpu = vcpu_lock(vm_get_vcpu(vm, target_vcpu_index)); | ||
*ret = vcpu_is_off(target_vcpu) ? PSCI_RETURN_OFF | ||
: PSCI_RETURN_ON; | ||
vcpu_unlock(&target_vcpu); | ||
target_vcpu = vm_get_vcpu(vm, target_vcpu_index); | ||
if (target_vcpu == current()) { | ||
*ret = PSCI_RETURN_ON; | ||
break; | ||
} | ||
|
||
if (!vcpu_try_lock(target_vcpu, &target_vcpu_locked)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 지점에서 vCPU가 켜져 있는지를 확인하기 위해서 락을 겁니다. 따라서 실행 중이 아니더라도 execution lock 을 걸어야 하는 경우가 발생하는데, 이것을 어떻게 하는 게 맞을까요?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
이 lock은 state_lock 같은 이름이 맞을 것 같은데, 그대로 둔다면 secondary VM A의
Primary VM은 vCPU 1의 실행을 실패할 수 있습니다. 이것이 옳은 semantics인가요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Semantics가 틀려보이긴 하네요... 원래 구현은 어땠는지 궁금합니다. |
||
*ret = PSCI_RETURN_ON; | ||
break; | ||
} | ||
|
||
*ret = vcpu_is_off(target_vcpu_locked) ? PSCI_RETURN_OFF | ||
: PSCI_RETURN_ON; | ||
vcpu_unlock(&target_vcpu_locked); | ||
break; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
* the guarantees provided by atomic instructions introduced in Armv8.1 LSE. | ||
*/ | ||
|
||
#include <stdatomic.h> | ||
#include <stdint.h> | ||
|
||
#include "hf/arch/types.h" | ||
|
@@ -61,6 +62,12 @@ static inline void sl_lock(struct spinlock *l) | |
: "cc"); | ||
} | ||
|
||
static inline bool sl_try_lock(struct spinlock *l) | ||
{ | ||
return !atomic_flag_test_and_set_explicit((volatile atomic_flag *)&l->v, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Linter를 통과했는지 궁금합니다. indent가 이상해 보이는데 손으로 한 것 같진 않아서.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
memory_order_acquire); | ||
} | ||
|
||
static inline void sl_unlock(struct spinlock *l) | ||
{ | ||
/* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.