[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 08/10] arm: context_switch: allow to run with IRQs already disabled


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Tue, 23 Feb 2021 02:34:58 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hLZbFCdGG+G9vwfGEiWEMpY27lBaZZM8a/Rntb3OeZ8=; b=XqiDlF5qgZCsTMuVSdUW8Hdg2NKXBhCKIyUORsD7cXbl6M67tEHTLL3zeCHiRTppAhFCAZFM8R1VWgAmlo5Q6hMX8CQt9HdGAoucy6LOaa9+z7XShl2z2tmWdLOiQxSjtjvNRM73OxJYmH2Q3DMf5q6ae2hcakNiU+Mud+4mRFAAvCbNWaA7q/CHzIF/ExtnMKATPuE6OLH2kEM8BDXWjF9TY+wZ1zDiuXntkBQ4rOTVEZ2TASIaxObDlVSMkdm/rLqoTnfd82Pl5CjoE/LIkl5LkdYz0xyIxcWOWqL5BzMTxEfVKtwTD/0xVKW2QPjgKBU8ThTfFwYHoVGQmmb5DQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fnsoOYeaZ5ap723wZNcX5IBljYGd+jOoU5tg7D29IJwkoifiWlQ29yEkQiI8det8eYG/walXrTRJaZunRIUKKe0Bd/7fH4yHvsMgJRkL3DVPW4If/ciKu5l60yOozxyg+BzaePt+nhASfCNSynePIhSdxXXvBLDPisGHfiJDx8+suA9ZzYWcFnnfm3zXx+Sp9PDGjHlN+NHGp5XEQgO6kPFwoJm1dQVDmYOCCjNLce5cPG6JgsgzJQpctQtr6pBOEGHJw5erGcc0FG6H2pOg9qq1UPpFjaRZSMbky0z4E+zjtkT4Bw8DZ1rDLvfoeucJr7QBhzqTvjzJR/baKYaxZw==
  • Authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=epam.com;
  • Cc: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 23 Feb 2021 02:35:19 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHXCYx6+wvu0Xd3nESKdamktRGE6w==
  • Thread-topic: [RFC PATCH 08/10] arm: context_switch: allow to run with IRQs already disabled

With upcoming full hypervisor preemption it is possible that context
switching code will be called with IRQs already disabled. In this case
we don't want to enable them back. So we need to add logic that tracks
if IRQs are already disabled.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
---
 xen/arch/arm/domain.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 2ccf4449ea..3d4a1df4a4 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -310,7 +310,7 @@ static void update_runstate_area(struct vcpu *v)
     }
 }
 
-static void schedule_tail(struct vcpu *prev)
+static void schedule_tail(struct vcpu *prev, bool enable_irqs)
 {
     ASSERT(prev != current);
 
@@ -318,7 +318,8 @@ static void schedule_tail(struct vcpu *prev)
 
     ctxt_switch_to(current);
 
-    local_irq_enable();
+    if (enable_irqs)
+        local_irq_enable();
 
     sched_context_switched(prev, current);
 
@@ -333,7 +334,7 @@ static void continue_new_vcpu(struct vcpu *prev)
     current->arch.actlr = READ_SYSREG32(ACTLR_EL1);
     processor_vcpu_initialise(current);
 
-    schedule_tail(prev);
+    schedule_tail(prev, true);
 
     /* This matches preempt_disable() in schedule() */
     preempt_enable_no_sched();
@@ -350,19 +351,21 @@ static void continue_new_vcpu(struct vcpu *prev)
 
 void context_switch(struct vcpu *prev, struct vcpu *next)
 {
-    ASSERT(local_irq_is_enabled());
+    bool need_to_disable_irqs = local_irq_is_enabled();
+
     ASSERT(prev != next);
     ASSERT(!vcpu_cpu_dirty(next));
 
     update_runstate_area(prev);
 
-    local_irq_disable();
+    if (need_to_disable_irqs)
+        local_irq_disable();
 
     set_current(next);
 
     prev = __context_switch(prev, next);
 
-    schedule_tail(prev);
+    schedule_tail(prev, need_to_disable_irqs);
 }
 
 void continue_running(struct vcpu *same)
-- 
2.29.2



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.