From patchwork Thu Jun 29 12:56:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9816709 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 E81A2603D7 for ; Thu, 29 Jun 2017 12:58:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BF95286CF for ; Thu, 29 Jun 2017 12:58:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30DC2286F6; Thu, 29 Jun 2017 12:58:46 +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 A0E73286CF for ; Thu, 29 Jun 2017 12:58:45 +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 1dQZ00-0006lh-J9; Thu, 29 Jun 2017 12:56:44 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQYzz-0006lC-1L for xen-devel@lists.xenproject.org; Thu, 29 Jun 2017 12:56:43 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id 2A/08-03582-A09F4595; Thu, 29 Jun 2017 12:56:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCIsWRWlGSWpSXmKPExsXiVRvkrMv5MyT S4EmrmcX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmnFuRXpBs05F79uPbA2MlxW6GLk4hASmM0p8 uf+fFcRhEVjJKvHu/Hp2EEdC4DyrxI11s5m6GDmBnDiJx7P/ANkcQHaFxIRJ6iBhIQEViZvbV zFBTFrCJNF+Yjo7SEJYQE/iyNEfULaZxL59k1lBbDYBA4k3O/aC2SICShL3Vk0Gm88ioCox+/ V0RhCbV8Be4uWl2WwgNqeAo8Smh0sYIZY5SNy58ArMFhWQk1h5uYUVol5Q4uTMJywgtzELaEq s36UPEmYWkJfY/nYO8wRG4VlIqmYhVM1CUrWAkXkVo3pxalFZapGuoV5SUWZ6RkluYmaOrqGB mV5uanFxYnpqTmJSsV5yfu4mRmCIMwDBDsadz50OMUpyMCmJ8ho+D4kU4kvKT6nMSCzOiC8qz UktPsQow8GhJMGb9R0oJ1iUmp5akZaZA4w2mLQEB4+SCO/Dr0Bp3uKCxNzizHSI1ClGXY5JB7 Z/YRJiycvPS5US590IMkMApCijNA9uBCzyLzHKSgnzMgIdJcRTkFqUm1mCKv+KUZyDUUmY9y/ IFJ7MvBK4Ta+AjmACOkJ4BtgRJYkIKakGRqMTB6I9CotUFNa6ej3pC1gpZaJw9G/yTNVPsZ5Z DP6fdVccnHKFqaavJG3xY+26uAYhR8aWueum+anrmm4QbtmjuJr1VjhH6hrlHrubZRkbn0x4U 8FZP3NFXdLF2UtOtilfuvKjmiHqTEna5HW5JSHXrr3bP0P4nHuArJjo9KzdH53f8YkYKrEUZy QaajEXFScCAFr7RJv3AgAA X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1498741001!67421885!1 X-Originating-IP: [74.125.82.67] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 46350 invoked from network); 29 Jun 2017 12:56:41 -0000 Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by server-3.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 29 Jun 2017 12:56:41 -0000 Received: by mail-wm0-f67.google.com with SMTP id u23so2425104wma.2 for ; Thu, 29 Jun 2017 05:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=zg96NtEcbeT0IPumX/ox+ImcHtKeb/XbeR3mesH68bs=; b=cJ+isPHvl5HjhX18ov9DZrsCxWog0LAMW7C3zg0++2Ppco+MmVDF9ZhuPC3WeUUdsV WLu0IKRB//rwCqGbG4eeN+cCvWxnwjQZPI4seIRnuo6ugSF7LgoE0NyiKx2OemujTAJ+ P3bwhnyfDbGVVvehibMHsxx5f/o2t4/fdFFVxLvnsUKLC2UOjCJgt71ukXZcs4Iu5b0y Vag9J1sPBgDssZUR0gomHvJl6sfiykC9ZHLxxOglkS8ukpy/SqiweLRwK9J7XCivRTGo AAvR7EUSc+6ruf5wIMCXiRybctbqTLV5lHz1mPhO7PqWorqPy2Qb1R8mVyU2fGT7cvVE NzTA== 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:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=zg96NtEcbeT0IPumX/ox+ImcHtKeb/XbeR3mesH68bs=; b=gHX8T1xjr4ainGW2NZr5OaECAx3TjTUgrGP2dThVj4jFbHnaxjVYSTVbqoxtguHgan j0vBQwUcG56tqStFWy6XQ4eghv63kEpIlmrloV5S3RSECYiefyMml7r2eqncfkQN+MdC TY4SpCtJXXF8JjvTYXn1+6vYZbr9flgHoifznUPX9ZpuHljpzcbYP2U94KbXaq4qhah/ mm//saiR62i4G78umd7UJVHaOtOm1da0gikR6+6vIb6syOwgmB/ZIjWAcpGZAeapcCAz dRwt/cKGMxvbl08uQqjA7Jd4Zvv9F6HjXij1457cvzpQLhfLgk/U1FIhYKlF7IoJ0bov uvBw== X-Gm-Message-State: AIVw110W0E6aBNBOT5Wqu2b9VV0TtlSy0XVeF8WH5/vrc+JOUENQB2Yy gYaiqIm2INL7kYcv X-Received: by 10.28.132.13 with SMTP id g13mr1956573wmd.58.1498741001180; Thu, 29 Jun 2017 05:56:41 -0700 (PDT) Received: from [192.168.0.31] ([80.66.223.37]) by smtp.gmail.com with ESMTPSA id q30sm4256455wrc.65.2017.06.29.05.56.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 05:56:40 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Thu, 29 Jun 2017 14:56:38 +0200 Message-ID: <149874099850.524.3264131422891814495.stgit@Solace> In-Reply-To: <149874017405.524.14075439009139766753.stgit@Solace> References: <149874017405.524.14075439009139766753.stgit@Solace> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 4/5] xen: sched_null: add some tracing 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 line with what is there in all the other schedulers. Signed-off-by: Dario Faggioli Reviewed-by: George Dunlap --- George Dunlap --- xen/common/sched_null.c | 94 +++++++++++++++++++++++++++++++++++++++++++- xen/include/public/trace.h | 1 2 files changed, 92 insertions(+), 3 deletions(-) diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index 19c7f0f..b4a24ba 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -32,7 +32,17 @@ #include #include #include +#include +/* + * null tracing events. Check include/public/trace.h for more details. + */ +#define TRC_SNULL_PICKED_CPU TRC_SCHED_CLASS_EVT(SNULL, 1) +#define TRC_SNULL_VCPU_ASSIGN TRC_SCHED_CLASS_EVT(SNULL, 2) +#define TRC_SNULL_VCPU_DEASSIGN TRC_SCHED_CLASS_EVT(SNULL, 3) +#define TRC_SNULL_MIGRATE TRC_SCHED_CLASS_EVT(SNULL, 4) +#define TRC_SNULL_SCHEDULE TRC_SCHED_CLASS_EVT(SNULL, 5) +#define TRC_SNULL_TASKLET TRC_SCHED_CLASS_EVT(SNULL, 6) /* * Locking: @@ -305,7 +315,10 @@ static unsigned int pick_cpu(struct null_private *prv, struct vcpu *v) */ if ( likely((per_cpu(npc, cpu).vcpu == NULL || per_cpu(npc, cpu).vcpu == v) && cpumask_test_cpu(cpu, cpumask_scratch_cpu(cpu))) ) - return cpu; + { + new_cpu = cpu; + goto out; + } /* If not, just go for a free pCPU, within our affinity, if any */ cpumask_and(cpumask_scratch_cpu(cpu), cpumask_scratch_cpu(cpu), @@ -313,7 +326,7 @@ static unsigned int pick_cpu(struct null_private *prv, struct vcpu *v) new_cpu = cpumask_first(cpumask_scratch_cpu(cpu)); if ( likely(new_cpu != nr_cpu_ids) ) - return new_cpu; + goto out; } /* @@ -328,7 +341,22 @@ static unsigned int pick_cpu(struct null_private *prv, struct vcpu *v) * only if the pCPU is free. */ cpumask_and(cpumask_scratch_cpu(cpu), cpus, v->cpu_hard_affinity); - return cpumask_any(cpumask_scratch_cpu(cpu)); + new_cpu = cpumask_any(cpumask_scratch_cpu(cpu)); + + out: + if ( unlikely(tb_init_done) ) + { + struct { + uint16_t vcpu, dom; + uint32_t new_cpu; + } d; + d.dom = v->domain->domain_id; + d.vcpu = v->vcpu_id; + d.new_cpu = new_cpu; + __trace_var(TRC_SNULL_PICKED_CPU, 1, sizeof(d), &d); + } + + return new_cpu; } static void vcpu_assign(struct null_private *prv, struct vcpu *v, @@ -339,6 +367,18 @@ static void vcpu_assign(struct null_private *prv, struct vcpu *v, cpumask_clear_cpu(cpu, &prv->cpus_free); dprintk(XENLOG_G_INFO, "%d <-- d%dv%d\n", cpu, v->domain->domain_id, v->vcpu_id); + + if ( unlikely(tb_init_done) ) + { + struct { + uint16_t vcpu, dom; + uint32_t cpu; + } d; + d.dom = v->domain->domain_id; + d.vcpu = v->vcpu_id; + d.cpu = cpu; + __trace_var(TRC_SNULL_VCPU_ASSIGN, 1, sizeof(d), &d); + } } static void vcpu_deassign(struct null_private *prv, struct vcpu *v, @@ -348,6 +388,18 @@ static void vcpu_deassign(struct null_private *prv, struct vcpu *v, cpumask_set_cpu(cpu, &prv->cpus_free); dprintk(XENLOG_G_INFO, "%d <-- NULL (d%dv%d)\n", cpu, v->domain->domain_id, v->vcpu_id); + + if ( unlikely(tb_init_done) ) + { + struct { + uint16_t vcpu, dom; + uint32_t cpu; + } d; + d.dom = v->domain->domain_id; + d.vcpu = v->vcpu_id; + d.cpu = cpu; + __trace_var(TRC_SNULL_VCPU_DEASSIGN, 1, sizeof(d), &d); + } } /* Change the scheduler of cpu to us (null). */ @@ -562,6 +614,19 @@ static void null_vcpu_migrate(const struct scheduler *ops, struct vcpu *v, if ( v->processor == new_cpu ) return; + if ( unlikely(tb_init_done) ) + { + struct { + uint16_t vcpu, dom; + uint16_t cpu, new_cpu; + } d; + d.dom = v->domain->domain_id; + d.vcpu = v->vcpu_id; + d.cpu = v->processor; + d.new_cpu = new_cpu; + __trace_var(TRC_SNULL_MIGRATE, 1, sizeof(d), &d); + } + /* * v is either assigned to a pCPU, or in the waitqueue. * @@ -663,8 +728,31 @@ static struct task_slice null_schedule(const struct scheduler *ops, SCHED_STAT_CRANK(schedule); NULL_VCPU_CHECK(current); + if ( unlikely(tb_init_done) ) + { + struct { + uint16_t tasklet, cpu; + int16_t vcpu, dom; + } d; + d.cpu = cpu; + d.tasklet = tasklet_work_scheduled; + if ( per_cpu(npc, cpu).vcpu == NULL ) + { + d.vcpu = d.dom = -1; + } + else + { + d.vcpu = per_cpu(npc, cpu).vcpu->vcpu_id; + d.dom = per_cpu(npc, cpu).vcpu->domain->domain_id; + } + __trace_var(TRC_SNULL_SCHEDULE, 1, sizeof(d), &d); + } + if ( tasklet_work_scheduled ) + { + trace_var(TRC_SNULL_TASKLET, 1, 0, NULL); ret.task = idle_vcpu[cpu]; + } else ret.task = per_cpu(npc, cpu).vcpu; ret.migrated = 0; diff --git a/xen/include/public/trace.h b/xen/include/public/trace.h index 7f2e891..3746bff 100644 --- a/xen/include/public/trace.h +++ b/xen/include/public/trace.h @@ -78,6 +78,7 @@ /* #define XEN_SCHEDULER_SEDF 2 (Removed) */ #define TRC_SCHED_ARINC653 3 #define TRC_SCHED_RTDS 4 +#define TRC_SCHED_SNULL 5 /* Per-scheduler tracing */ #define TRC_SCHED_CLASS_EVT(_c, _e) \