Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3243117pxa; Tue, 25 Aug 2020 15:54:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzE0tM7WXzNdlYHYMk009Cj4yuXGK57Sp8OppPQl1tHjZK0dKU4Lz87uSBdlU9d8wInhzU9 X-Received: by 2002:a17:906:a206:: with SMTP id r6mr12604123ejy.70.1598396072887; Tue, 25 Aug 2020 15:54:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598396072; cv=none; d=google.com; s=arc-20160816; b=qQDQQ+MlSPejztyGNpqiAgsRRqri2kCtjGOiGbYhYT8xAFmHhcm6XcossB7JxU20ci jSNraM70dRzFCcmE8zlLWlIzGgpUoGaRZHD4LHADsvb/DVY+Dk/XZIH0D5h8RXCXKlHA RIdg3q91sLEJO4a4t8kcFKn4nkiHJf418+VQfLhTJP+UsIg0w/nUSmQXeOYPN0zrpdpc rEMsZCD5k2HTq8dEU0nQ3pFA9G54f8GA6EG5rTCPjQr10kE64xRMk00GTSmH91ACbrhP /bytgdOiB9go7d5rdLeLpF4SmX8APN9A/r6bJM0CaQOjLOJ4H/7DQ5BbY9GwljKKLe6g Na/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=WEE3G9povgJWPCtYpPqFiQBf651eDMpa+71/slW/h98=; b=K0InWzFYtHKbRHHO9kzNkFhYTu+J+bWtGsKAfKyhpWMvXWT2LbDJyaQ4pYG12iPqTN t1kGwJ/9qQvTgUOjysRCdP6fwH1e0bs5C1lQ67X8udAzahxPIJ2oDTeX2xecr2FIh9i5 25H+ptQgCpx35+glEQBCRAK5IK0mgNET4sknoGrkf8vTUQpiYLOLRu/Tu7RzDxcpqwmY 04blsNaa6jAbYvgwPdA6zKrEDEniJATuFW/JISZSVfSRlTRQ2yfJi91FTVtHeLnDt+rn GbhdSe3hgBKfxhAtXM4FtxhFGqXqOW0Gt6e9NNZylAcO52+HfuKUoiyPAU2cJIRi8cgH I0ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=BEu8CJSV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b1si310312ejb.647.2020.08.25.15.54.10; Tue, 25 Aug 2020 15:54:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=BEu8CJSV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726798AbgHYWxP (ORCPT + 99 others); Tue, 25 Aug 2020 18:53:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726466AbgHYWxM (ORCPT ); Tue, 25 Aug 2020 18:53:12 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79A0BC061755 for ; Tue, 25 Aug 2020 15:53:12 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id n18so27543qtw.0 for ; Tue, 25 Aug 2020 15:53:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=WEE3G9povgJWPCtYpPqFiQBf651eDMpa+71/slW/h98=; b=BEu8CJSVBli/z0qbfaqpochzBmN0GZzDkrHjJSWt89ZURiB0L2nUlQbj+fuo8tW1TT 5/BBKHljCrW0hTKQK5nU0M59+rb/NPI1E+Elvt5t5HcF6lkkv/Bqrqm+0DrrAs4rCjXX XbGLNvOqk5K8KNTCFJ4zAlT1VVk5lGBMBfDKo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WEE3G9povgJWPCtYpPqFiQBf651eDMpa+71/slW/h98=; b=GupB5Vhq1Wn/rrAN168L606ZGJ5VL0T7IoN6d6gq/rZW9Aek1soNtIkN4oMJQbb8Je WJi+kS4ILBka9WkTbMZbw2RjmXMCJ0OeQ6Kx/BAR/8pOqezXKKYtcOn+bjLwFZroTHU0 DYXUdkBO+nEfXzyYgzHCG9k6jfb8vNqr+JhlinQ2Y0nNZPuiQ3nzTEfWaxQ35qJuJ5eV 2NJDj+SmR+4QxYOiiiMqtIjaQn0LYGffpJUQGw0f0eV+zXtliFq3MNIMUXMp46m8COKp FTpH7x6dcx/IM/5jZ5TJhosE4DtXxmIaiJEUu6siY/JKQUpm06WCeG14fwMUqqIpo2Xz 3gBw== X-Gm-Message-State: AOAM5317Dbc00DK827RCx1zDOaa4Py/gNlvK4ocg0HprukzMqLL1lTsd 4aX4B7WdRPzEu1WjTh9Ger4Q5Q== X-Received: by 2002:ac8:6bc2:: with SMTP id b2mr11687288qtt.115.1598395991672; Tue, 25 Aug 2020 15:53:11 -0700 (PDT) Received: from localhost ([2620:15c:6:12:cad3:ffff:feb3:bd59]) by smtp.gmail.com with ESMTPSA id i14sm424928qtq.33.2020.08.25.15.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2020 15:53:11 -0700 (PDT) Date: Tue, 25 Aug 2020 18:53:10 -0400 From: Joel Fernandes To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, boqun.feng@gmail.com, dave@stgolabs.net, Ingo Molnar , Josh Triplett , Lai Jiangshan , Madhuparna Bhowmik , Mathieu Desnoyers , neeraj.iitr10@gmail.com, rcu@vger.kernel.org, Steven Rostedt , "Uladzislau Rezki (Sony)" , vineethrp@gmail.com Subject: Re: [PATCH v4 -rcu 4/4] rcu/trace: Add tracing for how segcb list changes Message-ID: <20200825225310.GD579506@google.com> References: <20200825024842.3408659-1-joel@joelfernandes.org> <20200825024842.3408659-5-joel@joelfernandes.org> <20200825215553.GB16846@paulmck-ThinkPad-P72> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200825215553.GB16846@paulmck-ThinkPad-P72> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 25, 2020 at 02:55:53PM -0700, Paul E. McKenney wrote: > On Mon, Aug 24, 2020 at 10:48:42PM -0400, Joel Fernandes (Google) wrote: > > Track how the segcb list changes before/after acceleration, during > > queuing and during dequeuing. > > > > This has proved useful to discover an optimization to avoid unwanted GP > > requests when there are no callbacks accelerated. The overhead is minimal as > > each segment's length is now stored in the respective segment. > > > > Signed-off-by: Joel Fernandes (Google) > > Speaking of tracing, diagnostics, and debugging, a few instances of > ASSERT_EXCLUSIVE_WRITER() in the previous patch might save a lot > of debugging. Help KCSAN help us. Ok, I will look into it, thanks. > > include/trace/events/rcu.h | 25 +++++++++++++++++++++++++ > > kernel/rcu/rcu_segcblist.c | 27 +++++++++++++++++++++++++++ > > kernel/rcu/rcu_segcblist.h | 7 +++++++ > > kernel/rcu/tree.c | 23 +++++++++++++++++++++++ > > 4 files changed, 82 insertions(+) > > > > diff --git a/include/trace/events/rcu.h b/include/trace/events/rcu.h > > index 155b5cb43cfd..7b84df3c95df 100644 > > --- a/include/trace/events/rcu.h > > +++ b/include/trace/events/rcu.h > > @@ -505,6 +505,31 @@ TRACE_EVENT_RCU(rcu_callback, > > __entry->qlen) > > ); > > > > +TRACE_EVENT_RCU(rcu_segcb, > > + > > + TP_PROTO(const char *ctx, int *cb_count, unsigned long *gp_seq), > > + > > + TP_ARGS(ctx, cb_count, gp_seq), > > + > > + TP_STRUCT__entry( > > + __field(const char *, ctx) > > + __array(int, cb_count, 4) > > + __array(unsigned long, gp_seq, 4) > > + ), > > + > > + TP_fast_assign( > > + __entry->ctx = ctx; > > + memcpy(__entry->cb_count, cb_count, 4 * sizeof(int)); > > + memcpy(__entry->gp_seq, gp_seq, 4 * sizeof(unsigned long)); > > + ), > > + > > + TP_printk("%s cb_count: (DONE=%d, WAIT=%d, NEXT_READY=%d, NEXT=%d) " > > + "gp_seq: (DONE=%lu, WAIT=%lu, NEXT_READY=%lu, NEXT=%lu)", __entry->ctx, > > + __entry->cb_count[0], __entry->cb_count[1], __entry->cb_count[2], __entry->cb_count[3], > > + __entry->gp_seq[0], __entry->gp_seq[1], __entry->gp_seq[2], __entry->gp_seq[3]) > > + > > +); > > + > > /* > > * Tracepoint for the registration of a single RCU callback of the special > > * kvfree() form. The first argument is the RCU type, the second argument > > diff --git a/kernel/rcu/rcu_segcblist.c b/kernel/rcu/rcu_segcblist.c > > index 73a103464ea4..6419dbbaecde 100644 > > --- a/kernel/rcu/rcu_segcblist.c > > +++ b/kernel/rcu/rcu_segcblist.c > > @@ -378,6 +378,33 @@ void rcu_segcblist_extract_done_cbs(struct rcu_segcblist *rsclp, > > rcu_segcblist_set_seglen(rsclp, RCU_DONE_TAIL, 0); > > } > > > > +/* > > + * Return how many CBs each segment along with their gp_seq values. > > + * > > + * This function is O(N) where N is the number of callbacks. Only used from > > + * tracing code which is usually disabled in production. > > + */ > > +#ifdef CONFIG_RCU_TRACE > > +void rcu_segcblist_countseq(struct rcu_segcblist *rsclp, > > + int cbcount[RCU_CBLIST_NSEGS], > > + unsigned long gpseq[RCU_CBLIST_NSEGS]) > > +{ > > Why not declare the arrays here and invoke the new trace event from > here also? That would simplify the usage and save a few lines of code. True! I will do it that way. thanks, - Joel