From patchwork Tue Jan 17 17:27:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9521595 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 A56BB601C3 for ; Tue, 17 Jan 2017 17:29:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96D26285F4 for ; Tue, 17 Jan 2017 17:29:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B55D285F8; Tue, 17 Jan 2017 17:29:12 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,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 2530F285F4 for ; Tue, 17 Jan 2017 17:29:12 +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 1cTXXI-0008G5-MW; Tue, 17 Jan 2017 17:27:08 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cTXXH-0008FT-A3 for xen-devel@lists.xenproject.org; Tue, 17 Jan 2017 17:27:07 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id AE/A5-27165-AE35E785; Tue, 17 Jan 2017 17:27:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDIsWRWlGSWpSXmKPExsXiVRvkqPsquC7 CYDmPxfctk5kcGD0Of7jCEsAYxZqZl5RfkcCa8fDzEaaCKxIV+w5dY2xgnCXSxcjFISQwk1Hi 6ZNLTCAOi8AaVomra74COZwcEgKXWCVOXUiCsGMktvZ0skHYVRIrv51kB7GFBFQkbm5fxQQxa QaTxKn+PWAJYQE9iSNHf0DZgRKrjxwDG8omYCDxZsdeVhBbREBJ4t6qyWBxZqCaWXPmgdksAq oSLV8ms4DYvAI+Et+fXgZazMHBCWS/OisJsddbYm/TBbByUQE5iZWXW1ghygUlTs58wgJSziy gKbF+lz7EdHmJ7W/nME9gFJmFpGoWQtUsJFULGJlXMWoUpxaVpRbpGprrJRVlpmeU5CZm5uga Gpjp5aYWFyemp+YkJhXrJefnbmIEhj4DEOxgvL0x4BCjJAeTkihvx+PaCCG+pPyUyozE4oz4o tKc1OJDjBocHAITzs6dziTFkpefl6okwdsdVBchJFiUmp5akZaZA4xOmFIJDh4lEd6fIGne4o LE3OLMdIjUKUZdjl27Lr9kEgKbISXOmw5SJABSlFGaBzcCliguMcpKCfMyAh0oxFOQWpSbWYI q/4pRnINRSZj3DMgUnsy8ErhNr4COYAI64rpONcgRJYkIKakGxqqHHtxvLpVZFdTwaqjld4v9 fmqREhcXmrSlx+Kvx+xJakoMGk3JP67+dyoW3Tzl1/rLKp7vZHb6bGGSuVIrOtno2sSzbDtmf 5KU6j10Q0QhLYWnje1X966zSoFNvPGSenfXSvz6/+aJi5793R2BP01vvGpY0/V36RlOC97pCi p6Obfz5rVGKbEUZyQaajEXFScCAPjmhAoPAwAA X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-5.tower-27.messagelabs.com!1484674025!76869879!1 X-Originating-IP: [74.125.82.65] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 39461 invoked from network); 17 Jan 2017 17:27:05 -0000 Received: from mail-wm0-f65.google.com (HELO mail-wm0-f65.google.com) (74.125.82.65) by server-5.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jan 2017 17:27:05 -0000 Received: by mail-wm0-f65.google.com with SMTP id d140so23650038wmd.2 for ; Tue, 17 Jan 2017 09:27:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=o1zh6uP3NTD8tuwbKozz/7dCH5w+5BL7srEBi4HpqpQ=; b=BxPUsyoSprr8HAUK8jly5wSjLmUIvXjsDIUjUJ5ACYKBq9B/GokxCcHhJclSW+6buM kODzUl+9+ikC+qV5+q7tMbT2N+W4At0myd4SeGZt+RaNr1ubmNxgnnvjXE1XNYO3Il6F otb5ly+ysLi70+qkEHFej6VFQRqTWLnHBIT6d53fLpf5UIyh6ic8KaK93c8FyAhHfO2z a+va5egqxF50FOOj6bEakKGm1708VHHoPkEWAG7m3UZxuqdFIRTvMtZvENUSBgAjJpk9 kXZExwlH072g2LOOXJyDo9kzRGnQX+sdkSbSaosRcTrwB/EtNQr/2DDe4lu3xKxL8e97 HE0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; 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=o1zh6uP3NTD8tuwbKozz/7dCH5w+5BL7srEBi4HpqpQ=; b=qkAc4wbmAduiq01aFyXKxm/Qw88KxXRvYO3DknZvo/zWAsP+ChLC7MsZQ0t0Hazctq xNp7lYz99aiUzy8vhKvJ2bAqmGIxbbZ+tR5ly9bdxWsS0WrIJ96WMDdV7xMV3f24I40H CeRU5u7iUdtCigvHw/FrRCKu1M8L0zIrFoUcFqz+sY4zJZctIN8HVbT3QfcpiFUrEIzJ uSH4x0xqn5AGTH+MywR8aDEAIGLNRKEER9kgfSnxQHEnGcPJdw07G075+l6SpDod47rb d4SHBikV9AGdUhNDm257rCnhnLWztV/dWRVefQAD8jQz/xmcHthBk1Puo3hbfGBlp5Hb urEg== X-Gm-Message-State: AIkVDXKAyCoJNk265pXjvyvzHQYe0MpeWOGCqdxHPyE6N9r0Qb1I0t4X0chJ0MAg0oSIoQ== X-Received: by 10.28.139.74 with SMTP id n71mr18410151wmd.139.1484674025596; Tue, 17 Jan 2017 09:27:05 -0800 (PST) Received: from Solace.fritz.box (58-209-66-80.hosts.abilene.it. [80.66.209.58]) by smtp.gmail.com with ESMTPSA id w18sm38425138wme.9.2017.01.17.09.27.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jan 2017 09:27:04 -0800 (PST) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Tue, 17 Jan 2017 18:27:03 +0100 Message-ID: <148467402295.27920.12760704062556867752.stgit@Solace.fritz.box> In-Reply-To: <148467379229.27920.2367500429219327194.stgit@Solace.fritz.box> References: <148467379229.27920.2367500429219327194.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap , Jan Beulich Subject: [Xen-devel] [PATCH 4/5] xen: sched: impove use of cpumask scratch space in Credit1. 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 It is ok to use just cpumask_scratch in csched_runq_steal(). In fact, the cpu parameter comes from the cpu local variable in csched_load_balance(), which in turn comes from cpu in csched_schedule(), which is smp_processor_id(). While there, also: - move the comment about cpumask_scratch in the header where the scratch space is declared; - spell more clearly (in that same comment) what are the serialization rules. No functional change intended. Signed-off-by: Dario Faggioli Acked-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich --- xen/common/sched_credit.c | 5 ++--- xen/common/schedule.c | 7 +------ xen/include/xen/sched-if.h | 7 +++++++ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index dfe8545..ad20819 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -1636,9 +1636,8 @@ csched_runq_steal(int peer_cpu, int cpu, int pri, int balance_step) && !__vcpu_has_soft_affinity(vc, vc->cpu_hard_affinity) ) continue; - csched_balance_cpumask(vc, balance_step, cpumask_scratch_cpu(cpu)); - if ( __csched_vcpu_is_migrateable(vc, cpu, - cpumask_scratch_cpu(cpu)) ) + csched_balance_cpumask(vc, balance_step, cpumask_scratch); + if ( __csched_vcpu_is_migrateable(vc, cpu, cpumask_scratch) ) { /* We got a candidate. Grab it! */ TRACE_3D(TRC_CSCHED_STOLEN_VCPU, peer_cpu, diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 36ff2e9..bee5d1f 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -65,12 +65,7 @@ static void poll_timer_fn(void *data); DEFINE_PER_CPU(struct schedule_data, schedule_data); DEFINE_PER_CPU(struct scheduler *, scheduler); -/* - * Scratch space, for avoiding having too many cpumask_var_t on the stack. - * Properly serializing access, if necessary, is responsibility of each - * scheduler (typically, one can expect this to be protected by the per pCPU - * or per runqueue lock). - */ +/* Scratch space for cpumasks. */ DEFINE_PER_CPU(cpumask_t, cpumask_scratch); extern const struct scheduler *__start_schedulers_array[], *__end_schedulers_array[]; diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index bc0e794..c25cda6 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -47,6 +47,13 @@ DECLARE_PER_CPU(struct schedule_data, schedule_data); DECLARE_PER_CPU(struct scheduler *, scheduler); DECLARE_PER_CPU(struct cpupool *, cpupool); +/* + * Scratch space, for avoiding having too many cpumask_var_t on the stack. + * Within each scheduler, when using the scratch mask of one pCPU: + * - the pCPU must belong to the scheduler, + * - the caller must own the per-pCPU scheduler lock (a.k.a. runqueue + * lock). + */ DECLARE_PER_CPU(cpumask_t, cpumask_scratch); #define cpumask_scratch (&this_cpu(cpumask_scratch)) #define cpumask_scratch_cpu(c) (&per_cpu(cpumask_scratch, c))