]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
xen: update the comment about smp_processor_id() in do_softirq(). wip/tracing/xen-internals gitlab/wip/tracing/xen-internals
authorDario Faggioli <dario.faggioli@citrix.com>
Tue, 19 Sep 2017 11:59:46 +0000 (13:59 +0200)
committerDario Faggioli <dfaggioli@suse.com>
Fri, 23 Mar 2018 14:34:26 +0000 (15:34 +0100)
It's said that "SCHEDULE_SOFTIRQ may move us to another processor",
which I don't find it very clear, nor that much representative of
what the situation actually is.

We have two possible situations:
- context_switch() is a "terminal function" (i.e., it jumps,
  rather than returning normally. This happens on x86;
- context_switch() "just" returns, and another step of the
  loop is executed. This happens on ARM.

The real reason why we need to re-sample smp_processor_id() is
that, on ARM, where the function return, we get back inside
of the loop, with (potentially) a different stack (because
context_switch() changed what's in the stack pointer register).
And in this case, what's in the new stack, at the address of
the local variable 'cpu', may not be consistent.

State this in the comment.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
---
Changes from v1:
* v1 had a patch that was getting rid of the call to smp_processor_id(), but
  that is wrong (on ARM). So, it has been replaced with this, which only
  adjust the comment.
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Julien Grall <julien.grall@arm.com>
Cc: Tim Deegan <tim@xen.org>
xen/common/softirq.c

index 83c3c09bd5bd3603351b1ef6c734809fe52f77b3..10bd0880e20dd8fcf4986b7789973aa45b84815a 100644 (file)
@@ -33,8 +33,12 @@ static void __do_softirq(unsigned long ignore_mask)
     for ( ; ; )
     {
         /*
-         * Initialise @cpu on every iteration: SCHEDULE_SOFTIRQ may move
-         * us to another processor.
+         * When handling SCHEDULE_SOFTIRQ, schedule() is called. It then
+         * calls context_switch() which, either, jumps away (on x86), or
+         * returns here in the loop (on ARM). To be safe, in the case where
+         * it returns, we need to re-sample smp_processor_id() at every
+         * iteration, as context_switch() may have changed what's in
+         * the stack pointer register.
          */
         cpu = smp_processor_id();