From patchwork Thu Jun 1 17:34:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9760723 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 1685260363 for ; Thu, 1 Jun 2017 17:36:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0177527569 for ; Thu, 1 Jun 2017 17:36:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA76428518; Thu, 1 Jun 2017 17:36:55 +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 6D35027569 for ; Thu, 1 Jun 2017 17:36: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 1dGTzf-0000K2-4a; Thu, 01 Jun 2017 17:34:43 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGTzd-0000J0-Av for xen-devel@lists.xenproject.org; Thu, 01 Jun 2017 17:34:41 +0000 Received: from [85.158.139.211] by server-11.bemta-5.messagelabs.com id 8E/CC-01733-F2050395; Thu, 01 Jun 2017 17:34:39 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrIIsWRWlGSWpSXmKPExsXiVRvkpKsdYBB p8OqEocX3LZOZHBg9Dn+4whLAGMWamZeUX5HAmvHl4AbWgkNOFf/vJjQwfjDqYuTiEBKYwSjx 8+oidhCHRWANq8SEJzuZQBwJgUusEvtajjF3MXICOXESPw7MY4WwyyV6d54BiwsJqEjc3L6KC WLUL0aJxdcmMYIkhAX0JI4c/QE0lgPCfmoLEmYTMJB4s2Mv2BwRASWJe6smM4HYzALfGCU2Li kGsVkEVCVOPtjPDmLzCvhIzJm+DczmFPCVmHTqDCPEXh+Jb78mgPWKCshJrLzcwgpRLyhxcuY TFpC1zAKaEut36UOMl5fY/nYO8wRGkVlIqmYhVM1CUrWAkXkVo0ZxalFZapGukZFeUlFmekZJ bmJmjq6hgalebmpxcWJ6ak5iUrFecn7uJkZg8NczMDDuYNzT7neIUZKDSUmUd4G8QaQQX1J+S mVGYnFGfFFpTmrxIUYZDg4lCd4LfkA5waLU9NSKtMwcYBzCpCU4eJREeFNA0rzFBYm5xZnpEK lTjLockw5s/8IkxJKXn5cqJc7L7g9UJABSlFGaBzcClhIuMcpKCfMyMjAwCPEUpBblZpagyr9 iFOdgVBLmzQVZxZOZVwK36RXQEUxAR7zYpg9yREkiQkqqgbFr3zLPiaeqFLo078utvTsh/EnN 1Y/FJdfuHym0WPdg1sQpM1sbeux+Rgm/YlD4zbswzPH2T1Nxv6AgMb/tRWX3ApyzrgilMOj69 wtOa52e03bygk3urCvWdQyHxXVd5jxvvfedOb/7SKSC/gKBAJWApIrnbQUbXVgkl6pw7Ypddk /D6fd1LyWW4oxEQy3mouJEANhcwAQEAwAA X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-13.tower-206.messagelabs.com!1496338474!85934051!1 X-Originating-IP: [74.125.82.66] 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 64076 invoked from network); 1 Jun 2017 17:34:34 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-13.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Jun 2017 17:34:34 -0000 Received: by mail-wm0-f66.google.com with SMTP id g15so13031906wmc.2 for ; Thu, 01 Jun 2017 10:34:34 -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=8NRfcsu9scUWXeigrrDYHsDr/j0wZO6atMw4MpOjS7I=; b=sD5rku4vozx8jan+VipNVBwNHpK1gVpbDwNwMCKpw+pp16z7JZA9tIA0WB5WpppTqF su8IsEMJMhYa6KFQvmv+XuqptWcVi4HSorZKx//JSdDDIQQHgALtJKxOLb3zj98v9vh2 sVXpjK6bQ1eC2WiKV5SgFzA4RrGtjk63hOC6BOB9WBsLvUumghyGxupAZnsbi+C9Mj8J RbJKJ7dNRbYHolPgE7QVVouniUu8PAq3ip2UymIJMFVyPFQuWn0/Px3lFl/wtHgNxfSb GG82LK3d7Q1IfJqBINzz8NRPn1vhdPqGwBFyNCHLbHue/rHWv+08L3h1R6L0A819gxh1 LIFQ== 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=8NRfcsu9scUWXeigrrDYHsDr/j0wZO6atMw4MpOjS7I=; b=oqVp1Zg9f/zF3+J37l2VJgfgMXV8x8Y6Bu9dRTI494AUP1tS8VkyYwYdsGMpB22Nk2 /r/FVJ927ZMm2AKYmjoT4i5AXvwTCmXZkJiqOaNadjrGdyMwaxq/voPzuCUO2oAfDgHN bAxP7TstYl/aeKHERJwU2+HWzj50OGIO2nusyeUR+W2TsnHmWAckFDLX7zywm/cGGuQW qoJGK6cJWgX/aVfg2ZaeRemxUpUtkmxTAHovQTWDh3f6qAr9Nd2HXGJ5E7kUElgBJxgU 1Zum6bavp5genvimx0ffU/+U1+L+I+UWaN+po/iLOrAsrjyguPKCCSUU0xANRptibxN1 LTIw== X-Gm-Message-State: AODbwcBX1kWHYvgWShGCb8iufOlwrPQsgsVy13q0Z9o33S0YJEcb7h1g 0AuPaXIWFCA67Q== X-Received: by 10.28.199.65 with SMTP id x62mr200907wmf.49.1496338474406; Thu, 01 Jun 2017 10:34:34 -0700 (PDT) Received: from Solace.fritz.box ([80.66.223.25]) by smtp.gmail.com with ESMTPSA id o49sm18458095wrb.47.2017.06.01.10.34.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 10:34:33 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Thu, 01 Jun 2017 19:34:31 +0200 Message-ID: <149633847165.12814.17021925979608518857.stgit@Solace.fritz.box> In-Reply-To: <149633614204.12814.14390287626133023934.stgit@Solace.fritz.box> References: <149633614204.12814.14390287626133023934.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: Stefano Stabellini , George Dunlap , Andrew Cooper , Tim Deegan , Jan Beulich Subject: [Xen-devel] [PATCH 08/15] xen: trace RCU behavior 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 Making it possible generate events showing the activity and the behavior of the RCU subsystem. Gate this with its specific Kconfig option (under CONFIG_TRACING), and keep it in disabled state by default. --- Cc: George Dunlap Cc: Andrew Cooper Cc: Jan Beulich Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan --- xen/Kconfig.debug | 8 ++++ xen/common/rcupdate.c | 82 ++++++++++++++++++++++++++++++++++++++++---- xen/include/public/trace.h | 14 ++++++++ 3 files changed, 97 insertions(+), 7 deletions(-) diff --git a/xen/Kconfig.debug b/xen/Kconfig.debug index 81910c9..fd5cccc 100644 --- a/xen/Kconfig.debug +++ b/xen/Kconfig.debug @@ -116,6 +116,14 @@ config TRACE_IRQSOFF Note that this comes with high overead and produces huge amount of tracing data. +config TRACE_RCU + bool "Trace RCU behavior" if EXPERT = "y" + default n + depends on TRACING + ---help--- + Makes it possible generate events showing the activity and the + behavior of the RCU subsystem. + config VERBOSE_DEBUG bool "Verbose debug messages" default DEBUG diff --git a/xen/common/rcupdate.c b/xen/common/rcupdate.c index 8cc5a82..f160582 100644 --- a/xen/common/rcupdate.c +++ b/xen/common/rcupdate.c @@ -92,6 +92,57 @@ static int qhimark = 10000; static int qlowmark = 100; static int rsinterval = 1000; +#ifdef CONFIG_TRACE_RCU +static inline void trace_call_rcu(void *func) +{ + uint64_t addr = (uint64_t)func; + + if ( likely(!tb_init_done) ) + return; + + __trace_var(TRC_XEN_RCU_CALL_RCU, 0, sizeof(addr), &addr); +} +static inline void trace_start_batch(const cpumask_t *m) +{ + uint32_t mask[6]; + + if ( likely(!tb_init_done) ) + return; + + memset(mask, 0, sizeof(mask)); + memcpy(mask, m, min(sizeof(mask), sizeof(cpumask_t))); + __trace_var(TRC_XEN_RCU_START_BATCH, 0, sizeof(mask), &mask); +} +static inline void trace_do_batch(void *func, long int qlen) +{ + struct { + uint64_t addr; + int64_t qlen; + } d; + + if ( likely(!tb_init_done) ) + return; + + d.addr = (uint64_t)func; + d.qlen = qlen; + __trace_var(TRC_XEN_RCU_DO_BATCH, 0, sizeof(d), &d); +} +#define trace_force_qstate() TRACE_0D(TRC_XEN_RCU_FORCE_QSTATE) +#define trace_cpu_quiet() TRACE_0D(TRC_XEN_RCU_CPU_QUIET) +#define trace_check_qstate(p) TRACE_1D(TRC_XEN_RCU_CHECK_QSTATE, p) +#define trace_do_callbacks() TRACE_0D(TRC_XEN_RCU_DO_CALLBKS) +#define trace_pending(p) TRACE_1D(TRC_XEN_RCU_PENDING, p) +#else /* !TRACE_RCU */ +#define trace_call_rcu(f) do {} while ( 0 ) +#define trace_start_batch(m) do {} while ( 0 ) +#define trace_do_batch(f, q) do {} while ( 0 ) +#define trace_force_qstate() do {} while ( 0 ) +#define trace_cpu_quiet() do {} while ( 0 ) +#define trace_check_qstate(p) do {} while ( 0 ) +#define trace_do_callbacks() do {} while ( 0 ) +#define trace_pending(p) do {} while ( 0 ) +#endif /* TRACE_RCU */ + struct rcu_barrier_data { struct rcu_head head; atomic_t *cpu_count; @@ -145,6 +196,9 @@ static void force_quiescent_state(struct rcu_data *rdp, struct rcu_ctrlblk *rcp) { cpumask_t cpumask; + + trace_force_qstate(); + raise_softirq(SCHEDULE_SOFTIRQ); if (unlikely(rdp->qlen - rdp->last_rs_qlen > rsinterval)) { rdp->last_rs_qlen = rdp->qlen; @@ -177,6 +231,7 @@ void call_rcu(struct rcu_head *head, head->func = func; head->next = NULL; local_irq_save(flags); + trace_call_rcu(func); rdp = &__get_cpu_var(rcu_data); *rdp->nxttail = head; rdp->nxttail = &head->next; @@ -199,12 +254,14 @@ static void rcu_do_batch(struct rcu_data *rdp) list = rdp->donelist; while (list) { next = rdp->donelist = list->next; + trace_do_batch(list->func, rdp->qlen); list->func(list); list = next; rdp->qlen--; if (++count >= rdp->blimit) break; } + if (rdp->blimit == INT_MAX && rdp->qlen <= qlowmark) rdp->blimit = blimit; if (!rdp->donelist) @@ -249,6 +306,7 @@ static void rcu_start_batch(struct rcu_ctrlblk *rcp) rcp->cur++; cpumask_copy(&rcp->cpumask, &cpu_online_map); + trace_start_batch(&rcp->cpumask); } } @@ -259,6 +317,7 @@ static void rcu_start_batch(struct rcu_ctrlblk *rcp) */ static void cpu_quiet(int cpu, struct rcu_ctrlblk *rcp) { + trace_cpu_quiet(); cpumask_clear_cpu(cpu, &rcp->cpumask); if (cpumask_empty(&rcp->cpumask)) { /* batch completed ! */ @@ -279,7 +338,7 @@ static void rcu_check_quiescent_state(struct rcu_ctrlblk *rcp, /* start new grace period: */ rdp->qs_pending = 1; rdp->quiescbatch = rcp->cur; - return; + goto out; } /* Grace period already completed for this cpu? @@ -287,7 +346,7 @@ static void rcu_check_quiescent_state(struct rcu_ctrlblk *rcp, * cacheline trashing. */ if (!rdp->qs_pending) - return; + goto out; rdp->qs_pending = 0; @@ -300,6 +359,8 @@ static void rcu_check_quiescent_state(struct rcu_ctrlblk *rcp, cpu_quiet(rdp->cpu, rcp); spin_unlock(&rcp->lock); + out: + trace_check_qstate(rdp->qs_pending); } @@ -309,6 +370,8 @@ static void rcu_check_quiescent_state(struct rcu_ctrlblk *rcp, static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp, struct rcu_data *rdp) { + trace_do_callbacks(); + if (rdp->curlist && !rcu_batch_before(rcp->completed, rdp->batch)) { *rdp->donetail = rdp->curlist; rdp->donetail = rdp->curtail; @@ -357,26 +420,31 @@ static void rcu_process_callbacks(void) static int __rcu_pending(struct rcu_ctrlblk *rcp, struct rcu_data *rdp) { + bool ret = true; + /* This cpu has pending rcu entries and the grace period * for them has completed. */ if (rdp->curlist && !rcu_batch_before(rcp->completed, rdp->batch)) - return 1; + goto out; /* This cpu has no pending entries, but there are new entries */ if (!rdp->curlist && rdp->nxtlist) - return 1; + goto out; /* This cpu has finished callbacks to invoke */ if (rdp->donelist) - return 1; + goto out; /* The rcu core waits for a quiescent state from the cpu */ if (rdp->quiescbatch != rcp->cur || rdp->qs_pending) - return 1; + goto out; /* nothing to do */ - return 0; + ret = false; + out: + trace_pending(ret); + return ret; } int rcu_pending(int cpu) diff --git a/xen/include/public/trace.h b/xen/include/public/trace.h index 1692a79..50b4fcc 100644 --- a/xen/include/public/trace.h +++ b/xen/include/public/trace.h @@ -39,6 +39,7 @@ #define TRC_PV 0x0020f000 /* Xen PV traces */ #define TRC_SHADOW 0x0040f000 /* Xen shadow tracing */ #define TRC_HW 0x0080f000 /* Xen hardware-related traces */ +#define TRC_XEN 0x0100f000 /* Xen misc traces (RCU, softirq, etc) */ #define TRC_GUEST 0x0800f000 /* Guest-generated traces */ #define TRC_ALL 0x0ffff000 #define TRC_HD_TO_EVENT(x) ((x)&0x0fffffff) @@ -92,6 +93,9 @@ #define TRC_HW_PM 0x00801000 /* Power management traces */ #define TRC_HW_IRQ 0x00802000 /* Traces relating to the handling of IRQs */ +/* Trace subclasses for Xen internals */ +#define TRC_XEN_RCU 0x01001000 /* RCU traces */ + /* Trace events per class */ #define TRC_LOST_RECORDS (TRC_GEN + 1) #define TRC_TRACE_WRAP_BUFFER (TRC_GEN + 2) @@ -278,6 +282,16 @@ #define TRC_HW_IRQ_DISABLE (TRC_HW_IRQ + 0xD) #define TRC_HW_IRQ_ENABLE (TRC_HW_IRQ + 0xE) +/* Trace events for RCU */ +#define TRC_XEN_RCU_FORCE_QSTATE (TRC_XEN_RCU + 0x1) +#define TRC_XEN_RCU_CALL_RCU (TRC_XEN_RCU + 0x2) +#define TRC_XEN_RCU_START_BATCH (TRC_XEN_RCU + 0x3) +#define TRC_XEN_RCU_DO_BATCH (TRC_XEN_RCU + 0x4) +#define TRC_XEN_RCU_CPU_QUIET (TRC_XEN_RCU + 0x5) +#define TRC_XEN_RCU_CHECK_QSTATE (TRC_XEN_RCU + 0x6) +#define TRC_XEN_RCU_DO_CALLBKS (TRC_XEN_RCU + 0x7) +#define TRC_XEN_RCU_PENDING (TRC_XEN_RCU + 0x8) + /* * Event Flags *