From patchwork Tue May 30 16:19:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gregory Herrero X-Patchwork-Id: 9754849 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2288F602BF for ; Tue, 30 May 2017 16:22:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1445D1FF87 for ; Tue, 30 May 2017 16:22:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0874226E49; Tue, 30 May 2017 16:22:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3293D1FF87 for ; Tue, 30 May 2017 16:22:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dFjs1-0005xn-08; Tue, 30 May 2017 16:19:45 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dFjs0-0005xg-CQ for xen-devel@lists.xen.org; Tue, 30 May 2017 16:19:44 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 91/F4-03058-F9B9D295; Tue, 30 May 2017 16:19:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJLMWRWlGSWpSXmKPExsUyZ7p8oO782bq RBmc+8lss+biYxYHR4+ju30wBjFGsmXlJ+RUJrBlvNy9gLjjAXzHvoVUD41vuLkYuDiGBiUwS cx9dY4RwLjJKnO1eyNrFyMnBJqAg8XzmSzBbREBa4trny2BFzAINTBId/SfBEsICnhKfd84Gs jk4WARUJR5e4wUJ8wrYS0w6tZIFxJYQkJfY1XaRFcI2lPi8cSnzBEauBYwMqxjVi1OLylKLdA 31kooy0zNKchMzc3QNDcz0clOLixPTU3MSk4r1kvNzNzECvcgABDsYdz53OsQoycGkJMrrbK0 bKcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mCl3kWUE6wKDU9tSItMwcYTjBpCQ4eJRFecZA0b3FB Ym5xZjpE6hSjopQ4b+9MoIQASCKjNA+uDRbClxhlpYR5GYEOEeIpSC3KzSxBlX/FKM7BqCTMe x9kCk9mXgnc9FdAi5mAFu/aoQ2yuCQRISXVwDhz3syZG9u+FW602Porg7vuXfC/nCB+0wefY+ c0hbQcrZuVImvVWTn5w/Q15wULeiMXp03kDWs+5XLjb41SheikvAJHqVe/2u7m14ityjv5Nm2 3sYshT3CXwNqmvVyH7siX3VOIlSzvsb/COW3zqcfn3U4a6AgaNk97cfrQ8ukfj2zsnLoo+LYS S3FGoqEWc1FxIgA4xVs3XAIAAA== X-Env-Sender: gregory.herrero@oracle.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1496161181!48380118!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 62637 invoked from network); 30 May 2017 16:19:42 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-6.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 30 May 2017 16:19:42 -0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v4UGJYur030063 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 May 2017 16:19:34 GMT Received: from localhost.localdomain (dhcp-ukc1-twvpn-3-vpnpool-10-175-245-4.vpn.oracle.com [10.175.245.4]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v4UGJUH1003910; Tue, 30 May 2017 16:19:31 GMT From: gregory.herrero@oracle.com To: xen-devel@lists.xen.org Date: Tue, 30 May 2017 18:19:06 +0200 Message-Id: <20170530161906.17896-1-gregory.herrero@oracle.com> X-Mailer: git-send-email 2.11.0 X-Source-IP: userv0022.oracle.com [156.151.31.74] 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 Subject: [Xen-devel] [PATCH] xen: stop_machine: fill fn_result only in case of error. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gregory Herrero 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 --- 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;