Re: [PATCH] HV: add pcpu id check before send IPI


Minggui Cao
 

OK,will do it, and then submit a PR.

-----Original Message-----
From: Xu, Anthony
Sent: Saturday, August 11, 2018 5:55 AM
To: acrn-dev@...
Cc: Cao, Minggui <minggui.cao@...>
Subject: RE: [acrn-dev] [PATCH] HV: add pcpu id check before send IPI

Can you fix below code as well?

Anthony

void make_pcpu_offline(uint16_t pcpu_id) {
struct sched_context *ctx = &per_cpu(sched_ctx, pcpu_id);

bitmap_set_lock(NEED_OFFLINE, &ctx->flags);
send_single_ipi(pcpu_id, VECTOR_NOTIFY_VCPU); }



-----Original Message-----
From: acrn-dev@...
[mailto:acrn-dev@...]
On Behalf Of Minggui Cao
Sent: Thursday, August 9, 2018 11:36 PM
To: acrn-dev@...
Cc: Cao, Minggui <minggui.cao@...>
Subject: [acrn-dev] [PATCH] HV: add pcpu id check before send IPI

to avoid send IPI to self, also improve the related code:
1. get_cpu_id is uint16_t now
2. MISRA-C requirement. like add {}

Signed-off-by: Minggui Cao <minggui.cao@...>
---
hypervisor/arch/x86/virq.c | 3 ++-
hypervisor/arch/x86/vmexit.c | 2 +-
hypervisor/common/schedule.c | 4 +++-
3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/hypervisor/arch/x86/virq.c b/hypervisor/arch/x86/virq.c
index e9c46f7..4d3cf35 100644
--- a/hypervisor/arch/x86/virq.c
+++ b/hypervisor/arch/x86/virq.c
@@ -104,8 +104,9 @@ void vcpu_make_request(struct vcpu *vcpu, uint16_t
eventid)
* scheduling, we need change here to determine it target vcpu is
* VMX non-root or root mode
*/
- if ((int)get_cpu_id() != vcpu->pcpu_id)
+ if (get_cpu_id() != vcpu->pcpu_id) {
send_single_ipi(vcpu->pcpu_id, VECTOR_NOTIFY_VCPU);
+ }
}

static int vcpu_do_pending_event(struct vcpu *vcpu) diff --git
a/hypervisor/arch/x86/vmexit.c b/hypervisor/arch/x86/vmexit.c index
7f6eb40..ac908d1 100644
--- a/hypervisor/arch/x86/vmexit.c
+++ b/hypervisor/arch/x86/vmexit.c
@@ -157,7 +157,7 @@ int vmexit_handler(struct vcpu *vcpu)
uint16_t basic_exit_reason;
int ret;

- if ((int)get_cpu_id() != vcpu->pcpu_id) {
+ if (get_cpu_id() != vcpu->pcpu_id) {
pr_fatal("vcpu is not running on its pcpu!");
return -EINVAL;
}
diff --git a/hypervisor/common/schedule.c
b/hypervisor/common/schedule.c index 1670d5f..ead3435 100644
--- a/hypervisor/common/schedule.c
+++ b/hypervisor/common/schedule.c
@@ -101,7 +101,9 @@ void make_reschedule_request(struct vcpu *vcpu)
struct sched_context *ctx = &per_cpu(sched_ctx, vcpu->pcpu_id);

bitmap_set_lock(NEED_RESCHEDULE, &ctx->flags);
- send_single_ipi(vcpu->pcpu_id, VECTOR_NOTIFY_VCPU);
+ if (get_cpu_id() != vcpu->pcpu_id) {
+ send_single_ipi(vcpu->pcpu_id, VECTOR_NOTIFY_VCPU);
+ }
}

int need_reschedule(uint16_t pcpu_id)
--
2.7.4


Join acrn-dev@lists.projectacrn.org to automatically receive all group messages.