From patchwork Tue Feb 2 11:29:41 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: 8189101 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 53F409F1C1 for ; Tue, 2 Feb 2016 11:32:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DB61120268 for ; Tue, 2 Feb 2016 11:32:11 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0161520263 for ; Tue, 2 Feb 2016 11:32:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aQZ9Z-0003xI-7F; Tue, 02 Feb 2016 11:29:49 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aQZ9X-0003wv-Tk for xen-devel@lists.xen.org; Tue, 02 Feb 2016 11:29:48 +0000 Received: from [193.109.254.147] by server-8.bemta-14.messagelabs.com id C5/51-24450-B2390B65; Tue, 02 Feb 2016 11:29:47 +0000 X-Env-Sender: jgross@suse.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1454412586!20813148!1 X-Originating-IP: [195.135.220.15] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43850 invoked from network); 2 Feb 2016 11:29:46 -0000 Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by server-14.tower-27.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 2 Feb 2016 11:29:46 -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 0A503AC86; Tue, 2 Feb 2016 11:29:46 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xen.org, jbeulich@suse.com, alan.robinson@ts.fujitsu.com, george.dunlap@eu.citrix.com, dario.faggioli@citrix.com Date: Tue, 2 Feb 2016 12:29:41 +0100 Message-Id: <1454412582-3263-2-git-send-email-jgross@suse.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1454412582-3263-1-git-send-email-jgross@suse.com> References: <1454412582-3263-1-git-send-email-jgross@suse.com> Cc: Juergen Gross Subject: [Xen-devel] [PATCH v2 1/2] xen: update timeslice under lock X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 When updating the timeslice of the credit scheduler protect the scheduler's private data by it's lock. Today a possible race could result only in some weird scheduling decisions during one timeslice, but further adjustments will need the lock anyway. Signed-off-by: Juergen Gross --- xen/common/sched_credit.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 03fb2c2..8fbbd54 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -1101,6 +1101,7 @@ csched_sys_cntl(const struct scheduler *ops, int rc = -EINVAL; xen_sysctl_credit_schedule_t *params = &sc->u.sched_credit; struct csched_private *prv = CSCHED_PRIV(ops); + unsigned long flags; switch ( sc->cmd ) { @@ -1112,8 +1113,12 @@ csched_sys_cntl(const struct scheduler *ops, || params->ratelimit_us < XEN_SYSCTL_SCHED_RATELIMIT_MIN)) || MICROSECS(params->ratelimit_us) > MILLISECS(params->tslice_ms) ) goto out; + + spin_lock_irqsave(&prv->lock, flags); __csched_set_tslice(prv, params->tslice_ms); prv->ratelimit_us = params->ratelimit_us; + spin_unlock_irqrestore(&prv->lock, flags); + /* FALLTHRU */ case XEN_SYSCTL_SCHEDOP_getinfo: params->tslice_ms = prv->tslice_ms;