From patchwork Wed Aug 17 17:18:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9286213 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 81A1B60839 for ; Wed, 17 Aug 2016 17:20:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 716C0294AC for ; Wed, 17 Aug 2016 17:20:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6630F294C0; Wed, 17 Aug 2016 17:20: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=-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 E82DD294B8 for ; Wed, 17 Aug 2016 17:20:54 +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 1ba4U6-0008U2-92; Wed, 17 Aug 2016 17:18:34 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ba4U5-0008TG-Ac for xen-devel@lists.xenproject.org; Wed, 17 Aug 2016 17:18:33 +0000 Received: from [85.158.139.211] by server-10.bemta-5.messagelabs.com id 7B/7D-19922-86C94B75; Wed, 17 Aug 2016 17:18:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrEIsWRWlGSWpSXmKPExsXiVRvkrJs+Z0u 4Qc8PQ4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNeN05zW2ghd6FS2PJrI0MD5T7mLk4hASmMko cf/RXWYQh0VgDavEoj2LGEEcCYFLrBLT3sxm6mLkAHJiJNac5upi5AQyaySW3f7ABGILCahI3 Ny+igli0jwmiYcHN7KCJIQF9CSOHP3BDmGHSxxuv8EIYrMJGEi82bEXrEZEQEni3qrJYIOYBa okjp9cClbDIqAq0TlzPlgvr4CPxNy2WWA2J5B9a/VvFojF3hKHJ/ewgdiiAnISKy+3sELUC0q cnPmEBeRmZgFNifW79CHGy0tsfzuHeQKjyCwkVbMQqmYhqVrAyLyKUaM4tagstUjX0EgvqSgz PaMkNzEzR9fQwFQvN7W4ODE9NScxqVgvOT93EyMw/BmAYAdj3yznQ4ySHExKorx3qreEC/El5 adUZiQWZ8QXleakFh9ilOHgUJLgVZsNlBMsSk1PrUjLzAFGIkxagoNHSYSXFSTNW1yQmFucmQ 6ROsWoy7Fl6r21TEIsefl5qVLivM9mARUJgBRllObBjYAlhUuMslLCvIxARwnxFKQW5WaWoMq /YhTnYFQS5tUHWcWTmVcCt+kV0BFMQEfw8oMdUZKIkJJqYOxcNfOT/o/P3KfvVKZ7CJ6Yodc5 tdq4Ya+5Q4uiAe9sgYPn+nRePTWR9tjxu+mSsci/wB+2v1Lvv+xcxfL6Xnmy7OOaaxvqN3NFN 59bdnWjgZBj0XrWmAB1l8/+oZzKzXsWFiR8ML3U5Xbu5f51RravptycNlG36Mm1q//u2jYyz/ Iryvm/uk2JpTgj0VCLuag4EQDqzGs6BQMAAA== X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-8.tower-206.messagelabs.com!1471454311!54823496!1 X-Originating-IP: [74.125.82.67] X-SpamReason: No, hits=0.2 required=7.0 tests=RCVD_ILLEGAL_IP X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21491 invoked from network); 17 Aug 2016 17:18:31 -0000 Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by server-8.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Aug 2016 17:18:31 -0000 Received: by mail-wm0-f67.google.com with SMTP id q128so26272714wma.1 for ; Wed, 17 Aug 2016 10:18:31 -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=VJ/FFyYuSwewSxVe9EmKkzzfVkr6p17v8JxfRJFEUp4=; b=Rz/g1rvty0+8bwvq81sYNIlcI6gWmTqOI9VsmtmBGGLdyijq5fln8pKyl8Ej6EAoUn ajOqbyJ1Gen/sPRCfUiDzCT4IqQlULPeGK8bnT6KpzYULPHSL7y1AnM72/8cqdHqYFFj YhwGzHanJZjT7OK9dq7fGwDx7uDrcRYe0ZD+K0uydSTk76ZllZXrLbi/Rgt/lAgFGFgV cyGT5Y2jPEnx5hYMALSPLbrCmktB3o6gQQSq6GcyexmZoPiiDtA4iU451m+GCkngRcGL nx+ZsSat3/qgIpF9ys2pzv3Jy9zUSe5UMCTVbp8sGq2xMGg7hzt8Ol64QNUGfv0HhpYE PhGg== 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=VJ/FFyYuSwewSxVe9EmKkzzfVkr6p17v8JxfRJFEUp4=; b=DcBcDkQ1jbADXYSawHGCI6O6vkSsbaWZc1vAUomOBugaOfsBP3F1n/IzpfC6uL9ynd zGDcE4c2RSSxOLaqixaorYzHvaTOU9Eg+nburMKIcL9r5mDtcKsZU+JQh60KC2Kid3vu RXCGTFr5Y081zElcNUOsN5tHeU8EqftfzGaZr+L8lTR8KlbaCSdQKnlK2tT1edTioo9M sTz/JrQE1cnIAES3sbhzhhCWNPUaDY+CGkAgjUSkm+hMRQ8KogowqD5RxDHttNgdYTt5 KVYXdbLgYFwuEbcC2fe51bbJ4+HDlMIVf+AequXBU/nzdJeW4GyLBj0xpQ/OeOvWR5K1 jluQ== X-Gm-Message-State: AEkoouvtAcWKiXw0aaB0jDZE6pZFrDHS1NVCxd/+zCcUFckL/lKZb7mwtWqzc9bLdyPvfg== X-Received: by 10.194.185.116 with SMTP id fb20mr49324995wjc.32.1471454311369; Wed, 17 Aug 2016 10:18:31 -0700 (PDT) Received: from Solace.fritz.box (net-2-32-14-104.cust.vodafonedsl.it. [2.32.14.104]) by smtp.gmail.com with ESMTPSA id yz6sm32539848wjb.35.2016.08.17.10.18.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Aug 2016 10:18:30 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Wed, 17 Aug 2016 19:18:29 +0200 Message-ID: <147145430952.25877.10937525630692282780.stgit@Solace.fritz.box> In-Reply-To: <147145358844.25877.7490417583264534196.stgit@Solace.fritz.box> References: <147145358844.25877.7490417583264534196.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 08/24] 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 --- Cc: George Dunlap Cc: Meng Xu Cc: Anshul Makkar --- xen/common/sched_credit.c | 7 +++++++ xen/common/sched_credit2.c | 38 +++++++++++++++++++++++++++++++++++++- xen/common/sched_rt.c | 15 +++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index ca04732..f9d3ac9 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -134,6 +134,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) /* @@ -1743,6 +1745,9 @@ csched_schedule( SCHED_STAT_CRANK(schedule); CSCHED_VCPU_CHECK(current); + TRACE_3D(TRC_CSCHED_SCHEDULE, cpu, tasklet_work_scheduled, + is_idle_vcpu(current)); + runtime = now - current->runstate.state_entry_time; if ( runtime < 0 ) /* Does this ever happen? */ runtime = 0; @@ -1792,6 +1797,8 @@ csched_schedule( snext->start_time += now; perfc_incr(delay_ms); tslice = MICROSECS(prv->ratelimit_us) - runtime; + TRACE_3D(TRC_CSCHED_RATELIMIT, scurr->vcpu->domain->domain_id, + scurr->vcpu->vcpu_id, runtime); ret.migrated = 0; goto out; } diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index c8e0ee7..164296b 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 @@ -2293,7 +2295,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) ) @@ -2383,6 +2400,7 @@ csched2_schedule( struct csched2_vcpu *snext = NULL; unsigned int snext_pos = 0; struct task_slice ret; + bool_t tickled; SCHED_STAT_CRANK(schedule); CSCHED2_VCPU_CHECK(current); @@ -2397,13 +2415,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..903dbd8 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:17, 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);