From patchwork Fri Sep 30 14:21:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9358347 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 79D146077B for ; Fri, 30 Sep 2016 14:23:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A6152A05F for ; Fri, 30 Sep 2016 14:23:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EC822A062; Fri, 30 Sep 2016 14:23:56 +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 C00CC2A05F for ; Fri, 30 Sep 2016 14:23:55 +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 1bpyh2-00039e-N8; Fri, 30 Sep 2016 14:21:40 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpyh1-00039I-WE for xen-devel@lists.xenproject.org; Fri, 30 Sep 2016 14:21:40 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id 8C/12-24266-2F47EE75; Fri, 30 Sep 2016 14:21:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrAIsWRWlGSWpSXmKPExsXiVRvkpPux5F2 4wa9vRhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bD+QuZCo6YVfyaOYGpgfGpRhcjF4eQwAxG ib5Tp9hAHBaBNawSV54+AXMkBC6xStxauI25i5ETyImReHeuhQXCrpY4OnciI4gtJKAicXP7K iaIUT8ZJW4u/c8GkhAW0JM4cvQHO4QdIdE2vRWsmU3AQOLNjr2sILaIgJLEvVWTmUBsZoEqie MnlwIN5QA6Q1Xi53kDEJNXwEfi2EdxkApOIPPFZpBODqBV3hJn9pmBhEUF5CRWXm4BG8grICh xcuYTFpASZgFNifW79CFmy0tsfzuHeQKjyCwkVbMQqmYhqVrAyLyKUaM4tagstUjXyEQvqSgz PaMkNzEzR9fQwFQvN7W4ODE9NScxqVgvOT93EyMw9OsZGBh3MN6c7HeIUZKDSUmUV/bo23Ahv qT8lMqMxOKM+KLSnNTiQ4wyHBxKErzuwFgSEixKTU+tSMvMAUYhTFqCg0dJhNcJJM1bXJCYW5 yZDpE6xajLsWXqvbVMQix5+XmpUuK8fCBFAiBFGaV5cCNgCeESo6yUMC8jAwODEE9BalFuZgm q/CtGcQ5GJWHeC8VAU3gy80rgNr0COoIJ6Ij8o29AjihJREhJNTA68Di85NnOLLXSe6eSvGjr yWzVxHrtvRXeak1Lt3TIOchMLMxv38/xZGMT+78ZOjYc8VEPlyf8+d7J5nuU08+8oL5eWCHyR 2F0slO/4v3pGpXmYkuKfu51igoOCDVNfvB5VYPJX9ZFjx9N+raZYV9jg/jdBXuFC6Nunp772u nIgr971346sU2JpTgj0VCLuag4EQDzIOhMAwMAAA== X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-10.tower-206.messagelabs.com!1475245297!45382543!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.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 39691 invoked from network); 30 Sep 2016 14:21:37 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-10.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 30 Sep 2016 14:21:37 -0000 Received: by mail-wm0-f66.google.com with SMTP id p138so3691754wmb.0 for ; Fri, 30 Sep 2016 07:21:37 -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=j/tfG6C+ZCMWFGIh1PTlqoBIdLCtrg4BKuGcF3ATarA=; b=reWqoWhWNz5sz5tNUHGMYxeTqZ1QE59EOyCSP5rX/ex1aXPkIJotRmPyd42/+kD0m4 EuA//CO4o5UydL6Od/+D9Q0JlNXEgWEDnWq3SsJgxWl0rRCm+8GcFZQiEFGK03wo7rOF u/kV124cNmliS8vA1NMVGNX+wriSBPZf57EUwg78nusrMcVNhEpDFRxHCpgFiMNRec84 kM/QMWraRqBM4n+/uVpzHcFwYq2PuHGLdAwTbXO9Tlw451gE4DKtdJvn+ZSa1wQpaWbH yVSISMavRTyPDIZuuC4cm21orI0EUPJ9GmcuWNhQQEMepIywo+zXnj3vCmFkVzLvZIQ7 HvEA== 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=j/tfG6C+ZCMWFGIh1PTlqoBIdLCtrg4BKuGcF3ATarA=; b=im6NrSwOCwHgTMTiuylSvkMFSSxk0nK1aiXxNQh+kx5uzOIU6ZKrjEDnTKfvtdHbzQ j+vJf/S9ZHWzwMP4AxR2+VBj4eMqtVMTWsNviM2vaWqB8b0Dq4lSkGMHgP5arBKV34cF TUaWWhX89nLbnSTiMlxRrJI/P/2VynocuvwoX1V6Y9182qSXzdfLRVYA/5sEBzBoO9t/ Y1UFvIuOcqUWox/N8gq3c9eF7koghrI+Qh4YC5382FWJbJKnUVfBvfZA55Jolw3HBPNp aR31FIwe0XtCrtmzllaD8XfosLkii+6l4Oi6AOQkJftDj9+a3RnoN/tXoHmU0mC2DObe v02Q== X-Gm-Message-State: AA6/9RkP0vv4R+lK+sZAZdG11h0dCM/Ovu+UrR6GqHOBVshATfRXGBHGvqAveWmprqxJKQ== X-Received: by 10.28.125.209 with SMTP id y200mr4516085wmc.112.1475245296302; Fri, 30 Sep 2016 07:21:36 -0700 (PDT) Received: from Solace.fritz.box ([80.66.223.126]) by smtp.gmail.com with ESMTPSA id k2sm4364324wmg.23.2016.09.30.07.21.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Sep 2016 07:21:35 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Fri, 30 Sep 2016 16:21:34 +0200 Message-ID: <147524529437.32325.16344803815412787175.stgit@Solace.fritz.box> In-Reply-To: <147524508103.32325.8143976887041193350.stgit@Solace.fritz.box> References: <147524508103.32325.8143976887041193350.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: George Dunlap , Anshul Makkar , Meng Xu Subject: [Xen-devel] [PATCH v3 2/2] xen: tracing: add trace records for schedule and rate-limiting. 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 As far as {csched, csched2, rt}_schedule() are concerned, an "empty" event, would already make it easier to read and understand a trace. But while there, add a few useful information, like if the cpu that is going through the scheduler has been tickled or not, if it is currently idle, etc (they vary, on a per-scheduler basis). For Credit1 and Credit2, add a record about when rate-limiting kicks in too. Signed-off-by: Dario Faggioli Reviewed-by: Meng Xu --- Cc: George Dunlap Cc: Meng Xu Cc: Anshul Makkar --- Changes from v1: * corrected the schedule record for sched_rt.c, as pointed out during review; * pack the Credit1 records as well, as requested during review. --- xen/common/sched_credit.c | 32 ++++++++++++++++++++++++++++++++ xen/common/sched_credit2.c | 38 +++++++++++++++++++++++++++++++++++++- xen/common/sched_rt.c | 15 +++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 5700763..fc3a321 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -133,6 +133,8 @@ #define TRC_CSCHED_TICKLE TRC_SCHED_CLASS_EVT(CSCHED, 6) #define TRC_CSCHED_BOOST_START TRC_SCHED_CLASS_EVT(CSCHED, 7) #define TRC_CSCHED_BOOST_END TRC_SCHED_CLASS_EVT(CSCHED, 8) +#define TRC_CSCHED_SCHEDULE TRC_SCHED_CLASS_EVT(CSCHED, 9) +#define TRC_CSCHED_RATELIMIT TRC_SCHED_CLASS_EVT(CSCHED, 10) /* @@ -1774,6 +1776,23 @@ csched_schedule( SCHED_STAT_CRANK(schedule); CSCHED_VCPU_CHECK(current); + /* + * Here in Credit1 code, we usually just call TRACE_nD() helpers, and + * don't care about packing. But scheduling happens very often, so it + * actually is important that the record is as small as possible. + */ + if ( unlikely(tb_init_done) ) + { + struct { + unsigned cpu:16, tasklet:8, idle:8; + } d; + d.cpu = cpu; + d.tasklet = tasklet_work_scheduled; + d.idle = is_idle_vcpu(current); + __trace_var(TRC_CSCHED_SCHEDULE, 1, sizeof(d), + (unsigned char *)&d); + } + runtime = now - current->runstate.state_entry_time; if ( runtime < 0 ) /* Does this ever happen? */ runtime = 0; @@ -1829,6 +1848,19 @@ csched_schedule( tslice = MICROSECS(prv->ratelimit_us) - runtime; if ( unlikely(runtime < CSCHED_MIN_TIMER) ) tslice = CSCHED_MIN_TIMER; + if ( unlikely(tb_init_done) ) + { + struct { + unsigned vcpu:16, dom:16; + unsigned runtime; + } d; + d.dom = scurr->vcpu->domain->domain_id; + d.vcpu = scurr->vcpu->vcpu_id; + d.runtime = runtime; + __trace_var(TRC_CSCHED_RATELIMIT, 1, sizeof(d), + (unsigned char *)&d); + } + ret.migrated = 0; goto out; } diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index c0646e9..6b98319 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -55,6 +55,8 @@ #define TRC_CSCHED2_LOAD_BALANCE TRC_SCHED_CLASS_EVT(CSCHED2, 17) #define TRC_CSCHED2_PICKED_CPU TRC_SCHED_CLASS_EVT(CSCHED2, 19) #define TRC_CSCHED2_RUNQ_CANDIDATE TRC_SCHED_CLASS_EVT(CSCHED2, 20) +#define TRC_CSCHED2_SCHEDULE TRC_SCHED_CLASS_EVT(CSCHED2, 21) +#define TRC_CSCHED2_RATELIMIT TRC_SCHED_CLASS_EVT(CSCHED2, 22) /* * WARNING: This is still in an experimental phase. Status and work can be found at the @@ -2281,7 +2283,22 @@ runq_candidate(struct csched2_runqueue_data *rqd, vcpu_runnable(scurr->vcpu) && (now - scurr->vcpu->runstate.state_entry_time) < MICROSECS(prv->ratelimit_us) ) + { + if ( unlikely(tb_init_done) ) + { + struct { + unsigned vcpu:16, dom:16; + unsigned runtime; + } d; + d.dom = scurr->vcpu->domain->domain_id; + d.vcpu = scurr->vcpu->vcpu_id; + d.runtime = now - scurr->vcpu->runstate.state_entry_time; + __trace_var(TRC_CSCHED2_RATELIMIT, 1, + sizeof(d), + (unsigned char *)&d); + } return scurr; + } /* Default to current if runnable, idle otherwise */ if ( vcpu_runnable(scurr->vcpu) ) @@ -2371,6 +2388,7 @@ csched2_schedule( struct csched2_vcpu *snext = NULL; unsigned int skipped_vcpus = 0; struct task_slice ret; + bool_t tickled; SCHED_STAT_CRANK(schedule); CSCHED2_VCPU_CHECK(current); @@ -2385,13 +2403,31 @@ csched2_schedule( BUG_ON(!is_idle_vcpu(scurr->vcpu) && scurr->rqd != rqd); /* Clear "tickled" bit now that we've been scheduled */ - if ( cpumask_test_cpu(cpu, &rqd->tickled) ) + tickled = cpumask_test_cpu(cpu, &rqd->tickled); + if ( tickled ) { __cpumask_clear_cpu(cpu, &rqd->tickled); cpumask_andnot(cpumask_scratch, &rqd->idle, &rqd->tickled); smt_idle_mask_set(cpu, cpumask_scratch, &rqd->smt_idle); } + if ( unlikely(tb_init_done) ) + { + struct { + unsigned cpu:16, rq_id:16; + unsigned tasklet:8, idle:8, smt_idle:8, tickled:8; + } d; + d.cpu = cpu; + d.rq_id = c2r(ops, cpu); + d.tasklet = tasklet_work_scheduled; + d.idle = is_idle_vcpu(current); + d.smt_idle = cpumask_test_cpu(cpu, &rqd->smt_idle); + d.tickled = tickled; + __trace_var(TRC_CSCHED2_SCHEDULE, 1, + sizeof(d), + (unsigned char *)&d); + } + /* Update credits */ burn_credits(rqd, scurr, now); diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 41c61a7..d95f798 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -160,6 +160,7 @@ #define TRC_RTDS_BUDGET_BURN TRC_SCHED_CLASS_EVT(RTDS, 3) #define TRC_RTDS_BUDGET_REPLENISH TRC_SCHED_CLASS_EVT(RTDS, 4) #define TRC_RTDS_SCHED_TASKLET TRC_SCHED_CLASS_EVT(RTDS, 5) +#define TRC_RTDS_SCHEDULE TRC_SCHED_CLASS_EVT(RTDS, 6) static void repl_timer_handler(void *data); @@ -1035,6 +1036,20 @@ rt_schedule(const struct scheduler *ops, s_time_t now, bool_t tasklet_work_sched struct rt_vcpu *snext = NULL; struct task_slice ret = { .migrated = 0 }; + /* TRACE */ + { + struct __packed { + unsigned cpu:16, tasklet:8, tickled:4, idle:4; + } d; + d.cpu = cpu; + d.tasklet = tasklet_work_scheduled; + d.tickled = cpumask_test_cpu(cpu, &prv->tickled); + d.idle = is_idle_vcpu(current); + trace_var(TRC_RTDS_SCHEDULE, 1, + sizeof(d), + (unsigned char *)&d); + } + /* clear ticked bit now that we've been scheduled */ cpumask_clear_cpu(cpu, &prv->tickled);