All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xen/sched: refactor urgent count update
@ 2026-09-25 21:28 Ruslan Ruslichenko
  2026-09-29 15:35 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Ruslan Ruslichenko @ 2026-09-25 21:28 UTC (permalink / raw)
  To: xen-devel; +Cc: dfaggioli, jgross, gwd, artem_mygaiev, Ruslan_Ruslichenko

From: Ruslan Ruslichenko <Ruslan_Ruslichenko@epam.com>

With current implementation whenever vCPU blocks on
waiting for event channel via SCHEDOP_poll hypercall,
scheduler sets 'is_urgent' flag. The flag is cleared
on vCPU runstate change, if it is no longer in
'VPF_blocked' state or its vcpu_id is not in poll_mask.

However, the only way for vCPU runstate to change in
polled state is when it's going to wakeup.

Thus when 'is_urgent' is set, inner condition will always be:

if ( unlikely(v->is_urgent) )
{
    if ( !(v->pause_flags & VPF_blocked) ||            // Always True
         !test_bit(v->vcpu_id, v->domain->poll_mask) ) // Never evaluated

This makes the second condition dead code.

Thus simplify overall code structure and remove dead code.

The patch has no functional change.

Signed-off-by: Ruslan Ruslichenko <Ruslan_Ruslichenko@epam.com>
---
 xen/common/sched/core.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index 77cbfd5226..22b3cd1007 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -241,26 +241,22 @@ static inline void trace_continue_running(const struct vcpu *v)
 
 static inline void vcpu_urgent_count_update(struct vcpu *v)
 {
+    bool cur_urgent;
+
     if ( is_idle_vcpu(v) )
         return;
 
-    if ( unlikely(v->is_urgent) )
-    {
-        if ( !(v->pause_flags & VPF_blocked) ||
-             !test_bit(v->vcpu_id, v->domain->poll_mask) )
-        {
-            v->is_urgent = 0;
-            atomic_dec(&per_cpu(sched_urgent_count, v->processor));
-        }
-    }
-    else
+    cur_urgent = (v->pause_flags & VPF_blocked) &&
+                 test_bit(v->vcpu_id, v->domain->poll_mask);
+
+    if ( unlikely(v->is_urgent != cur_urgent) )
     {
-        if ( unlikely(v->pause_flags & VPF_blocked) &&
-             unlikely(test_bit(v->vcpu_id, v->domain->poll_mask)) )
-        {
-            v->is_urgent = 1;
+        v->is_urgent = cur_urgent;
+
+        if ( cur_urgent )
             atomic_inc(&per_cpu(sched_urgent_count, v->processor));
-        }
+        else
+            atomic_dec(&per_cpu(sched_urgent_count, v->processor));
     }
 }
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-30 10:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-25 21:28 [PATCH] xen/sched: refactor urgent count update Ruslan Ruslichenko
2026-09-29 15:35 ` Jan Beulich
2026-09-30 10:36   ` [RESEND] " Ruslan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.