From patchwork Tue Jul 19 12:07:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9236897 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 68C8E6075D for ; Tue, 19 Jul 2016 12:09:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A422205A4 for ; Tue, 19 Jul 2016 12:09:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EE4526929; Tue, 19 Jul 2016 12:09:41 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 2AF11205A4 for ; Tue, 19 Jul 2016 12:09: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 1bPTnv-0002Fa-W8; Tue, 19 Jul 2016 12:07:15 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPTnu-0002EJ-Jm for xen-devel@lists.xenproject.org; Tue, 19 Jul 2016 12:07:14 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id 7D/19-03271-1F71E875; Tue, 19 Jul 2016 12:07:13 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDIsWRWlGSWpSXmKPExsXiVRvkpPtRvC/ c4PZhOYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPVr83sBVMEKz7M38DUwPiap4uRi0NIYBqj xLrjv5i7GDk5WATWsErMWSoEkpAQuMQqcarvIFhCQiBGYsHN+ewQdrnE6z8djCC2kICKxM3tq 5ggJi1mkpg0awMbSEJYQE/iyNEf7BB2osTTl3eYQGw2AQOJNzv2soLYIgJKEvdWTQZrZhZoZp RYfnMu1BmqEiunvWDpYuTg4BXwkfjwwBnE5AQy/+3wg9jrLbH17QywMaICchIrL7eA2bwCghI nZz4B62QW0JRYv0sfJMwsIC+x/e0c5gmMIrOQVM1CqJqFpGoBI/MqRvXi1KKy1CJdC72kosz0 jJLcxMwcXUMDY73c1OLixPTUnMSkYr3k/NxNjMDQZwCCHYwX2p0PMUpyMCmJ8qqK9oYL8SXlp 1RmJBZnxBeV5qQWH2LU4OAQmHB27nQmKZa8/LxUJQleH7G+cCHBotT01Iq0zBxgdMKUSnDwKI nwRoKkeYsLEnOLM9MhUqcYdTm2TL23lkkIbIaUOO9qkCIBkKKM0jy4EbBEcYlRVkqYlxHoQCG egtSi3MwSVPlXjOIcjErCvHtApvBk5pXAbXoFdAQT0BEGqt0gR5QkIqSkGhjXTNI+qXn5287l sokvdGfnNLY1MWjwLvf7/77jnJhXVVF8Q92XX0d09fJufHs3YZGO1eoFm6QZnuRGTeVuEWj/9 uf45cI9FW9N9yW8zZza+uO5BtsMt9jz86/Ylb32+h9UxXvySae878JgP6OHjvHLbU9nHV71qm Bh+rOX3ttbN70SLdQ88ytRiaU4I9FQi7moOBEAiIhNYg8DAAA= X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-15.tower-31.messagelabs.com!1468930033!47390429!1 X-Originating-IP: [74.125.82.66] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 61230 invoked from network); 19 Jul 2016 12:07:13 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-15.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 19 Jul 2016 12:07:13 -0000 Received: by mail-wm0-f66.google.com with SMTP id i5so2606612wmg.2 for ; Tue, 19 Jul 2016 05:07:13 -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=B2vrvQP7ViAUpigDfp2xEqfEaLrV+yF9ILkud+avZvU=; b=exVkoASgdv/cU3FWpxhbZuEcZqmovrILed9zfeG5Iybrrz0Ge3nX4a3eT/BT59Xx7/ GL2+st6qBZ8zPSUs9V+u85HgZKorFatzZDK7KwX8Mt8VcCMiOFpwknRx3TI/ET0Uirlf ROem5hsOnSmpm/fSM70dJIBV1AOgOSsdjOoCfcGvm7OTOdt+ndC0V30TzfLb4TRIlrOi r6RnUKUyPOsxqshjorTSmVGGUqOkzi9EVcUw6t0FmZI1e7dBvCKadhCTgz7Kutofe6uS YSpqiNuLJ8EbJUbMVtBO4AvzHAD7xZCxhF73O82t9TbEBdE6p2BArCsmqLw19pKh5Uus AERQ== 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=B2vrvQP7ViAUpigDfp2xEqfEaLrV+yF9ILkud+avZvU=; b=Fog577x+p8SW21OwHyRC74spzrkoqzxkrbXq62ZmDUEy9wYGPrR61vwcpIkgcR8l6s U4kGwiQJFom77ambKBfHx29GxCJ3oeg7zhbSfHzVerONzNfiYptlwFQUDWoYDpbCRW3B mSBnifYF8RLVnYNswZqpPdDE7x303t0FY2V7zlRjYjtyw7k1INZEO4lbnCTlpXlc6XSf d52+xCTMS0ioH3AuSrocyHU11Bpo5cp6B3h5hsGh3IF6CT/hQkZyXO78YEHaywiURlqJ RABz8ePYkwQ94qbeFPK/oMOBxdU3YBcQ629Px9ExFJXWg2vCJLgsvYLomBz1VPtpKmrF DRng== X-Gm-Message-State: ALyK8tKkBlHIHmGmHZO8RniOiAu/uvpJqqYKJBr8hAAga9P551/5kE/aFDBgbp8Ok5xrCA== X-Received: by 10.28.95.67 with SMTP id t64mr3677843wmb.99.1468930032166; Tue, 19 Jul 2016 05:07:12 -0700 (PDT) Received: from Solace.fritz.box (net-188-217-84-158.cust.vodafonedsl.it. [188.217.84.158]) by smtp.gmail.com with ESMTPSA id p23sm19544883wme.8.2016.07.19.05.07.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Jul 2016 05:07:11 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Tue, 19 Jul 2016 14:07:10 +0200 Message-ID: <146893003029.30642.12963188611518110169.stgit@Solace.fritz.box> In-Reply-To: <146892985892.30642.2392453881110942183.stgit@Solace.fritz.box> References: <146892985892.30642.2392453881110942183.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: Andrew Cooper , Anshul Makkar , George Dunlap Subject: [Xen-devel] [PATCH 2/2] xen: credit2: fix potential issues in csched2_cpu_pick with tracing enabled 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-Virus-Scanned: ClamAV using ClamSMTP In fact, when not finding a suitable runqueue where to place a vCPU, and hence using a fallback, we either: - don't issue any trace record (while we should), - risk underruning when accessing the runqueues array, while preparing the trace record. Fix both issues and, while there, also a couple of style problems found nearby. Signed-off-by: Dario Faggioli Reported-by: Andrew Cooper --- Cc: George Dunlap Cc: Anshul Makkar --- xen/common/sched_credit2.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 3d3e4ae..7bfb24a 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -1443,7 +1443,8 @@ csched2_cpu_pick(const struct scheduler *ops, struct vcpu *vc) { /* We may be here because someone requested us to migrate. */ __clear_bit(__CSFLAG_runq_migrate_request, &svc->flags); - return get_fallback_cpu(svc); + new_cpu = get_fallback_cpu(svc); + goto out; } /* First check to see if we're here because someone else suggested a place @@ -1505,7 +1506,7 @@ csched2_cpu_pick(const struct scheduler *ops, struct vcpu *vc) if ( rqd_avgload < min_avgload ) { min_avgload = rqd_avgload; - min_rqi=i; + min_rqi = i; } } @@ -1520,20 +1521,20 @@ csched2_cpu_pick(const struct scheduler *ops, struct vcpu *vc) BUG_ON(new_cpu >= nr_cpu_ids); } -out_up: + out_up: read_unlock(&prv->lock); - + out: if ( unlikely(tb_init_done) ) { struct { uint64_t b_avgload; unsigned vcpu:16, dom:16; unsigned rq_id:16, new_cpu:16; - } d; - d.b_avgload = prv->rqd[min_rqi].b_avgload; + } d; d.dom = vc->domain->domain_id; d.vcpu = vc->vcpu_id; d.rq_id = c2r(ops, new_cpu); + d.b_avgload = prv->rqd[d.rq_id].b_avgload; d.new_cpu = new_cpu; __trace_var(TRC_CSCHED2_PICKED_CPU, 1, sizeof(d),