From patchwork Thu Mar 3 16:48:48 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: 8494021 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 9748BC0554 for ; Thu, 3 Mar 2016 16:51:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B927020374 for ; Thu, 3 Mar 2016 16:51:35 +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 D5CB720364 for ; Thu, 3 Mar 2016 16:51:33 +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 1abWR4-0005O4-AT; Thu, 03 Mar 2016 16:49:10 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1abWR2-0005M6-F2 for xen-devel@lists.xen.org; Thu, 03 Mar 2016 16:49:08 +0000 Received: from [193.109.254.147] by server-12.bemta-14.messagelabs.com id 3A/B0-02979-30B68D65; Thu, 03 Mar 2016 16:49:07 +0000 X-Env-Sender: jgross@suse.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1457023746!28588274!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 28197 invoked from network); 3 Mar 2016 16:49:07 -0000 Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by server-10.tower-27.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 3 Mar 2016 16:49:07 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 60120ADDA; Thu, 3 Mar 2016 16:49:06 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xen.org Date: Thu, 3 Mar 2016 17:48:48 +0100 Message-Id: <1457023730-10997-5-git-send-email-jgross@suse.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1457023730-10997-1-git-send-email-jgross@suse.com> References: <1457023730-10997-1-git-send-email-jgross@suse.com> Cc: Juergen Gross , Wei Liu , Ian Jackson , Stefano Stabellini Subject: [Xen-devel] [PATCH v3 4/6] 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 --- V3: adjust coding style as requested by Wei Liu --- tools/libxc/xc_cpupool.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/libxc/xc_cpupool.c b/tools/libxc/xc_cpupool.c index c42273e..9626699 100644 --- a/tools/libxc/xc_cpupool.c +++ b/tools/libxc/xc_cpupool.c @@ -20,8 +20,11 @@ */ #include +#include #include "xc_private.h" +#define LIBXC_BUSY_RETRIES 5 + static int do_sysctl_save(xc_interface *xch, struct xen_sysctl *sysctl) { int ret; @@ -141,13 +144,21 @@ 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 < LIBXC_BUSY_RETRIES; retries++ ) { + err = do_sysctl_save(xch, &sysctl); + if ( err >= 0 || errno != EBUSY ) + break; + sleep(1); + } + return err; } int xc_cpupool_movedomain(xc_interface *xch,