From patchwork Thu Mar 10 05:27:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 8554061 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B4071C0553 for ; Thu, 10 Mar 2016 05:30:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D8B87202F2 for ; Thu, 10 Mar 2016 05:30:21 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 87A48202E5 for ; Thu, 10 Mar 2016 05:30:20 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1adt86-0000RO-FY; Thu, 10 Mar 2016 05:27:22 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1adt84-0000Qz-VC for xen-devel@lists.xen.org; Thu, 10 Mar 2016 05:27:21 +0000 Received: from [193.109.254.147] by server-2.bemta-14.messagelabs.com id DB/56-03301-8B501E65; Thu, 10 Mar 2016 05:27:20 +0000 X-Env-Sender: jgross@suse.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1457587639!30002295!1 X-Originating-IP: [195.135.220.15] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 51450 invoked from network); 10 Mar 2016 05:27:19 -0000 Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by server-12.tower-27.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 10 Mar 2016 05:27:19 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1E73BABE7; Thu, 10 Mar 2016 05:27:17 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xen.org Date: Thu, 10 Mar 2016 06:27:12 +0100 Message-Id: <1457587634-22819-2-git-send-email-jgross@suse.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1457587634-22819-1-git-send-email-jgross@suse.com> References: <1457587634-22819-1-git-send-email-jgross@suse.com> Cc: Juergen Gross , Wei Liu , Ian Jackson , Stefano Stabellini Subject: [Xen-devel] [PATCH v4 1/3] libxc: do some retries in xc_cpupool_removecpu() for EBUSY case 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The hypervisor might return EBUSY when trying to remove a cpu from a cpupool when a domain running in this cpupool has pinned a vcpu temporarily. Do some retries in this case, perhaps the situation cleans up. Cc: Ian Jackson Cc: Stefano Stabellini Cc: Wei Liu Signed-off-by: Juergen Gross Reviewed-by: Dario Faggioli Acked-by: Wei Liu --- V3: adjust coding style as requested by Wei Liu V4: minor code modifications as suggested by Dario Faggioli --- tools/libxc/xc_cpupool.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/libxc/xc_cpupool.c b/tools/libxc/xc_cpupool.c index c42273e..261b9c9 100644 --- a/tools/libxc/xc_cpupool.c +++ b/tools/libxc/xc_cpupool.c @@ -20,6 +20,7 @@ */ #include +#include #include "xc_private.h" static int do_sysctl_save(xc_interface *xch, struct xen_sysctl *sysctl) @@ -137,17 +138,34 @@ int xc_cpupool_addcpu(xc_interface *xch, return do_sysctl_save(xch, &sysctl); } +/* + * The hypervisor might return EBUSY when trying to remove a cpu from a + * cpupool when a domain running in this cpupool has pinned a vcpu + * temporarily. Do some retries in this case, perhaps the situation + * cleans up. + */ +#define NUM_RMCPU_BUSY_RETRIES 5 + int xc_cpupool_removecpu(xc_interface *xch, uint32_t poolid, int cpu) { + unsigned retries; + int err; DECLARE_SYSCTL; sysctl.cmd = XEN_SYSCTL_cpupool_op; sysctl.u.cpupool_op.op = XEN_SYSCTL_CPUPOOL_OP_RMCPU; sysctl.u.cpupool_op.cpupool_id = poolid; sysctl.u.cpupool_op.cpu = (cpu < 0) ? XEN_SYSCTL_CPUPOOL_PAR_ANY : cpu; - return do_sysctl_save(xch, &sysctl); + for ( retries = 0; retries < NUM_RMCPU_BUSY_RETRIES; retries++ ) { + err = do_sysctl_save(xch, &sysctl); + if ( err < 0 && errno == EBUSY ) + sleep(1); + else + break; + } + return err; } int xc_cpupool_movedomain(xc_interface *xch,