All of lore.kernel.org
 help / color / mirror / Atom feed
From: gregory.herrero@oracle.com
To: xen-devel@lists.xen.org
Cc: sstabellini@kernel.org, wei.liu2@citrix.com,
	George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com,
	ian.jackson@eu.citrix.com, tim@xen.org, jbeulich@suse.com,
	Gregory Herrero <gregory.herrero@oracle.com>
Subject: [PATCH] xen: stop_machine: fill fn_result only in case of error.
Date: Tue, 30 May 2017 18:19:06 +0200	[thread overview]
Message-ID: <20170530161906.17896-1-gregory.herrero@oracle.com> (raw)

From: Gregory Herrero <gregory.herrero@oracle.com>

Since fn_result member is shared across all cpus, it must be filled
only if an error happens. Assume CPU1 detects an error and set fn_result
to -1, then CPU2 doesn't detect an error and set fn_result to 0. The
error detected by CPU1 will be ignored.

Signed-off-by: Gregory Herrero <gregory.herrero@oracle.com>
---
 xen/common/stop_machine.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/xen/common/stop_machine.c b/xen/common/stop_machine.c
index 304b783aae..22d246c7a4 100644
--- a/xen/common/stop_machine.c
+++ b/xen/common/stop_machine.c
@@ -94,6 +94,7 @@ int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu)
     stopmachine_data.fn_data = data;
     stopmachine_data.nr_cpus = nr_cpus;
     stopmachine_data.fn_cpu = cpu;
+    stopmachine_data.fn_result = 0;
     atomic_set(&stopmachine_data.done, 0);
     stopmachine_data.state = STOPMACHINE_START;
 
@@ -112,7 +113,11 @@ int stop_machine_run(int (*fn)(void *), void *data, unsigned int cpu)
 
     stopmachine_set_state(STOPMACHINE_INVOKE);
     if ( (cpu == smp_processor_id()) || (cpu == NR_CPUS) )
-        stopmachine_data.fn_result = (*fn)(data);
+    {
+        ret = (*fn)(data);
+        if (ret)
+            stopmachine_data.fn_result = ret;
+    }
     stopmachine_wait_state();
     ret = stopmachine_data.fn_result;
 
@@ -150,8 +155,11 @@ static void stopmachine_action(unsigned long cpu)
         case STOPMACHINE_INVOKE:
             if ( (stopmachine_data.fn_cpu == smp_processor_id()) ||
                  (stopmachine_data.fn_cpu == NR_CPUS) )
-                stopmachine_data.fn_result =
-                    stopmachine_data.fn(stopmachine_data.fn_data);
+	    {
+                int ret = stopmachine_data.fn(stopmachine_data.fn_data);
+                if (ret)
+                    stopmachine_data.fn_result = ret;
+	    }
             break;
         default:
             break;
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

             reply	other threads:[~2017-05-30 16:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-30 16:19 gregory.herrero [this message]
2017-05-31  8:30 ` [PATCH] xen: stop_machine: fill fn_result only in case of error Jan Beulich
2017-05-31  9:51   ` Gregory Herrero

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170530161906.17896-1-gregory.herrero@oracle.com \
    --to=gregory.herrero@oracle.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.