From patchwork Fri Mar 18 19:04:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 8623231 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 57992C0553 for ; Fri, 18 Mar 2016 19:06:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C28E2034F for ; Fri, 18 Mar 2016 19:06:41 +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 85F582022A for ; Fri, 18 Mar 2016 19:06:40 +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 1agzgs-0008NN-Fv; Fri, 18 Mar 2016 19:04:06 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agzgq-0008ND-U1 for xen-devel@lists.xenproject.org; Fri, 18 Mar 2016 19:04:05 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id AB/C9-25417-4215CE65; Fri, 18 Mar 2016 19:04:04 +0000 X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1458327843!29793926!1 X-Originating-IP: [74.125.82.68] X-SpamReason: No, hits=0.2 required=7.0 tests=RCVD_ILLEGAL_IP X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43690 invoked from network); 18 Mar 2016 19:04:03 -0000 Received: from mail-wm0-f68.google.com (HELO mail-wm0-f68.google.com) (74.125.82.68) by server-6.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 18 Mar 2016 19:04:03 -0000 Received: by mail-wm0-f68.google.com with SMTP id l68so8149733wml.3 for ; Fri, 18 Mar 2016 12:04:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=/nkujyFOnNnTGNWzOgBz6XNyUaemdcG/LcS46fcHqi0=; b=jOxfi+dmpRuJ5eBXGFejPaRcfdgmbh64Wa0Ghf/wZNRieqNHj06SmFtmgPDj+H8e1l wLGDxHXYJACfvKPvJ26czdh4XMH5ST6wBXQU5GRzVkLttr0fFneVZhOrWaFHIOMxJdX/ dkIaZzPwf5iMuL0ifSqAVhNQxGceR1pX9ZOo8U5RnWC3SQD3qkHWZSUDtowIDXlVZeuD Mz4HI52rcZbdH46tQrU0utBQaLTl2087+WJ4idAEY2EhtnP2i7biotE8E8pUYbKOcHdH OjlU/Lz4aoaiC9EhHCQpSfqhB3J0Y4zODCWXJuOgPEse57enyi2C0kW2ROPKc9i5eY47 UAFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:from:to:cc:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=/nkujyFOnNnTGNWzOgBz6XNyUaemdcG/LcS46fcHqi0=; b=Q+4YhXqi/Kr+KV7le28jpK4Mfa3acYniRDR0rIU0P9qTeqDKj6mSsLPERPBt5rUtXg PfS+beVHyrKLYGzDp14b9E4dkepDYk2aIUeJq1xg9DKbLOsm6ueDCKcYuivjOxYKFQGt umeOsWIev9YRFzUNWYh6EoUAFEXQM8w/Z25B8BSfQjsBUWZDBf1UnEgiUVBhM/f+K1cU YmT1ssNBvlkoYyNm9hOc0oeVjjdsT4VVZYT9RUjQCXaMm7sAgekzxFPmC+2CjALie+Th 5PkuubT4WiEABbq8hlQyMIqpg9g5Lsy6Fxfjy74OfC4X1yYevDt3qxj3n7Ijb+AJKgM+ FTkA== X-Gm-Message-State: AD7BkJIKwseomGu+nnaHdWPgmI9w4gugicSQazSZZ7Qiiv69OQIoO+7uhh4iTVEY9g3iiw== X-Received: by 10.194.122.138 with SMTP id ls10mr17535717wjb.51.1458327843554; Fri, 18 Mar 2016 12:04:03 -0700 (PDT) Received: from Solace.station (net-2-35-170-8.cust.vodafonedsl.it. [2.35.170.8]) by smtp.gmail.com with ESMTPSA id g203sm523180wmf.23.2016.03.18.12.04.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Mar 2016 12:04:02 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Fri, 18 Mar 2016 20:04:01 +0100 Message-ID: <20160318190401.8117.69985.stgit@Solace.station> In-Reply-To: <20160318185524.8117.74837.stgit@Solace.station> References: <20160318185524.8117.74837.stgit@Solace.station> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap , Tianyang Chen , Meng Xu Subject: [Xen-devel] [PATCH 01/16] xen: sched: fix locking when allocating an RTDS pCPU 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, 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 as doing that include changing the scheduler lock mapping for the pCPU itself, and the correct way of doing that is: - take the lock that the pCPU is using right now (which may be the lock of another scheduler); - change the mapping of the lock to the RTDS one; - release the lock (the one that has actually been taken!) Signed-off-by: Dario Faggioli Reviewed-by: Meng Xu Reviewed-by: George Dunlap --- Cc: Meng Xu Cc: George Dunlap Cc: Tianyang Chen --- xen/common/sched_rt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index c896a6f..d98bfb6 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -653,11 +653,16 @@ static void * rt_alloc_pdata(const struct scheduler *ops, int cpu) { struct rt_private *prv = rt_priv(ops); + spinlock_t *old_lock; unsigned long flags; - spin_lock_irqsave(&prv->lock, flags); + /* Move the scheduler lock to our global runqueue lock. */ + old_lock = pcpu_schedule_lock_irqsave(cpu, &flags); + per_cpu(schedule_data, cpu).schedule_lock = &prv->lock; - spin_unlock_irqrestore(&prv->lock, flags); + + /* _Not_ pcpu_schedule_unlock(): per_cpu().schedule_lock changed! */ + spin_unlock_irqrestore(old_lock, flags); if ( !alloc_cpumask_var(&_cpumask_scratch[cpu]) ) return NULL;