From patchwork Fri Jun 23 10:55:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9806259 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 B4CA260329 for ; Fri, 23 Jun 2017 10:57:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BDC828616 for ; Fri, 23 Jun 2017 10:57:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2076528662; Fri, 23 Jun 2017 10:57:36 +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 98CA128616 for ; Fri, 23 Jun 2017 10:57:35 +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 1dOMFP-0006Vc-TJ; Fri, 23 Jun 2017 10:55:31 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dOMFO-0006US-C3 for xen-devel@lists.xenproject.org; Fri, 23 Jun 2017 10:55:30 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id D8/C9-19466-1A3FC495; Fri, 23 Jun 2017 10:55:29 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJIsWRWlGSWpSXmKPExsVyMbThkO6Czz6 RBp1tVhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bhi3vYCjbIV2y7vomlgfG6RBcjF4eQwExG iYbVj1lBHBaBNawSx/sa2EEcCYFLrBKX1y5j7mLkBHLiJP6un8MCYVdIdD3tYQexhQRUJG5uX 8UEMeo7o8T/aSeYQBLCAnoSR47+YIew/SX+PLvEBmKzCRhIvNmxlxXEFhFQkri3ajJYPbNAqM Scd2fAalgEVCX6ZqwG6+UVcJDYfHAjI4jNKeAkMWHVTiaIxY4SLf9fgB0nKiAnsfJyCytEvaD EyZlPgA7lAJqpKbF+lz7EeHmJ7W/nME9gFJmFpGoWQtUsJFULGJlXMWoUpxaVpRbpGhnpJRVl pmeU5CZm5ugaGpjq5aYWFyemp+YkJhXrJefnbmIERkA9AwPjDsY97X6HGCU5mJREeWPP+EQK8 SXlp1RmJBZnxBeV5qQWH2KU4eBQkuB9/AkoJ1iUmp5akZaZA4xFmLQEB4+SCO/2D0Bp3uKCxN zizHSI1ClGY44rV9Z9YeKYcmD7FyYhlrz8vFQpcd6TIJMEQEozSvPgBsFSxCVGWSlhXkYGBgY hnoLUotzMElT5V4ziHIxKwrxqwIQjxJOZVwK37xXQKUxAp8xYA3ZKSSJCSqqBsUX5eL31pK4J X24cr3R8fb8ure0Dv0O82vS1//5bxaT1Hp5/R9zv8SKZ9xaCt2t4zvdPUzl509xQ8oPA2jVr9 50xlbe8LCW1K3hznnYr/7Sujjsewo4yH4NjGzIsT0QozhLbpvnKevPa+mU1/m1zQzW+8Fikdh mWp2Q61VirBC6O6OtZav5diaU4I9FQi7moOBEAcM1tgAwDAAA= X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1498215328!84978940!1 X-Originating-IP: [209.85.128.194] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33941 invoked from network); 23 Jun 2017 10:55:28 -0000 Received: from mail-wr0-f194.google.com (HELO mail-wr0-f194.google.com) (209.85.128.194) by server-11.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Jun 2017 10:55:28 -0000 Received: by mail-wr0-f194.google.com with SMTP id z45so11661764wrb.2 for ; Fri, 23 Jun 2017 03:55:28 -0700 (PDT) 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=hNTY6FUGaRB8Cv7y6vFZRtNe7V0Y7O1/9vWQbyR1TQ4=; b=m3dnxYs2ibGcmVqewErrzWp6nPKTIePQTqzIUIKb9fmzlP/6GKfeMgezDxc80ljPO9 xXLo+9Z39tpkZ6rScVdy9YHjKGhWM7TnBRxWUrsTN5cO66SnBenq9QZQ56PzKkB+wITj raOP8kl+MzdJmIE0EFTrsoNiwzLEK7hQIOTvGpZRK65A+vyyntYMkCprfGG87nUihzPR bS8JvZjRcWtBLjIXmUXn8aYwjC6SVyQWnY5EuNYwINd4VKQaKs2atDoViDf4GxfpU/Ug C2WHmmt6TjTAHCGmLHI5Gxbyuu9MkNrlxL7fM+Gojd19LfS0/415gQltTUaGNxW49krK 5g7g== 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=hNTY6FUGaRB8Cv7y6vFZRtNe7V0Y7O1/9vWQbyR1TQ4=; b=COs4ybyD46EC8HdiJWrlcQo6VNa8iLV6t9j3NQhZhhqjuF2bJvqWDfkuLTERMw850/ dVqURwKv+qGLYxTTezFlDra4NO0EQltT79qOxjpwq6x6PhhkVykfHeo/k+kqY3RvgEBT RsxR+i5no6ac4TlpYL+buGtatST4lgSMydkeR0EzeBuqi+iLKEIGe+spFRWCm0e7iBiU AoQa72bMOFNM9n4dfBwT9AHJx5zjqz9Yx5hhGQ3pS/jrpHzlFZl/9JYQGy6nWPY+sQRM jtTLeBjAKTtleZDaq6drm+nyr4M4u8hhObdZNa2sBRSPep/pWLtSxL6jzMubcfO8cDx6 KHuA== X-Gm-Message-State: AKS2vOxl1Y9AJLTZWVj/LUMTtVwWaqoc10+D8oV+BSbvzWeql/WF93hh +Tc7WUeKEDaTf06o X-Received: by 10.28.230.89 with SMTP id d86mr4989924wmh.80.1498215328237; Fri, 23 Jun 2017 03:55:28 -0700 (PDT) Received: from [192.168.0.31] ([80.66.223.81]) by smtp.gmail.com with ESMTPSA id w96sm4065406wrc.33.2017.06.23.03.55.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jun 2017 03:55:27 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Fri, 23 Jun 2017 12:55:26 +0200 Message-ID: <149821532649.5914.2989728748602173556.stgit@Solace> In-Reply-To: <149821475587.5914.12193327340105859241.stgit@Solace> References: <149821475587.5914.12193327340105859241.stgit@Solace> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap , Anshul Makkar Subject: [Xen-devel] [PATCH 6/6] xen: sched: optimize exclusive pinning case (Credit1 & 2) 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 Exclusive pinning of vCPUs is used, sometimes, for achieving the highest level of determinism, and the least possible overhead, for the vCPUs in question. Although static 1:1 pinning is not recommended, for general use cases, optimizing the tickling code (of Credit1 and Credit2) is easy and cheap enough, so go for it. Signed-off-by: Dario Faggioli --- Cc: George Dunlap Cc: Anshul Makkar --- xen/common/sched_credit.c | 19 +++++++++++++++++++ xen/common/sched_credit2.c | 21 ++++++++++++++++++++- xen/include/xen/perfc_defn.h | 1 + 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 4f6330e..85e014d 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -429,6 +429,24 @@ static inline void __runq_tickle(struct csched_vcpu *new) idlers_empty = cpumask_empty(&idle_mask); /* + * Exclusive pinning is when a vcpu has hard-affinity with only one + * cpu, and there is no other vcpu that has hard-affinity with that + * same cpu. This is infrequent, but if it happens, is for achieving + * the most possible determinism, and least possible overhead for + * the vcpus in question. + * + * Try to identify the vast majority of these situations, and deal + * with them quickly. + */ + if ( unlikely(cpumask_cycle(cpu, new->vcpu->cpu_hard_affinity) == cpu && + cpumask_test_cpu(cpu, &idle_mask)) ) + { + SCHED_STAT_CRANK(tickled_idle_cpu_excl); + __cpumask_set_cpu(cpu, &mask); + goto tickle; + } + + /* * If the pcpu is idle, or there are no idlers and the new * vcpu is a higher priority than the old vcpu, run it here. * @@ -524,6 +542,7 @@ static inline void __runq_tickle(struct csched_vcpu *new) } } + tickle: if ( !cpumask_empty(&mask) ) { if ( unlikely(tb_init_done) ) diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 9814072..3a1ecbb 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -1186,7 +1186,26 @@ runq_tickle(const struct scheduler *ops, struct csched2_vcpu *new, s_time_t now) cpupool_domain_cpumask(new->vcpu->domain)); /* - * First of all, consider idle cpus, checking if we can just + * Exclusive pinning is when a vcpu has hard-affinity with only one + * cpu, and there is no other vcpu that has hard-affinity with that + * same cpu. This is infrequent, but if it happens, is for achieving + * the most possible determinism, and least possible overhead for + * the vcpus in question. + * + * Try to identify the vast majority of these situations, and deal + * with them quickly. + */ + if ( unlikely(cpumask_cycle(cpu, cpumask_scratch_cpu(cpu)) == cpu && + cpumask_test_cpu(cpu, &rqd->idle) && + !cpumask_test_cpu(cpu, &rqd->tickled)) ) + { + SCHED_STAT_CRANK(tickled_idle_cpu_excl); + ipid = cpu; + goto tickle; + } + + /* + * Afterwards, let's consider idle cpus, checking if we can just * re-use the pcpu where we were running before. * * If there are cores where all the siblings are idle, consider diff --git a/xen/include/xen/perfc_defn.h b/xen/include/xen/perfc_defn.h index 53849af..ad914dc 100644 --- a/xen/include/xen/perfc_defn.h +++ b/xen/include/xen/perfc_defn.h @@ -30,6 +30,7 @@ PERFCOUNTER(vcpu_wake_runnable, "sched: vcpu_wake_runnable") PERFCOUNTER(vcpu_wake_not_runnable, "sched: vcpu_wake_not_runnable") PERFCOUNTER(tickled_no_cpu, "sched: tickled_no_cpu") PERFCOUNTER(tickled_idle_cpu, "sched: tickled_idle_cpu") +PERFCOUNTER(tickled_idle_cpu_excl, "sched: tickled_idle_cpu_exclusive") PERFCOUNTER(tickled_busy_cpu, "sched: tickled_busy_cpu") PERFCOUNTER(vcpu_check, "sched: vcpu_check")