Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2050355imm; Thu, 12 Jul 2018 12:19:32 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfCsFGglSHS2Dnh1un6cO46nk/95vqFacN5e0Tfwq4UvTdcCndv8zkYWLyclWK9WJwW92ah X-Received: by 2002:a17:902:9345:: with SMTP id g5-v6mr3380189plp.10.1531423172808; Thu, 12 Jul 2018 12:19:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531423172; cv=none; d=google.com; s=arc-20160816; b=REumO/DUEK2PfRSBLpCB8iXYfwgiG/besiJKpjlO1yUv1+tDNuQkaFLIJLqECtNWKr UmBtdaOnU3taahU/xrV0mfkF+FY1avv/CEbQ3xUXwH5GCpXaS2CFvksjwIDmJS+X4pAe 0TieCiqBuJ4h8XsQJACz78ENuMO/GaYRAe4HZ/3S+obX2lx5hoTqIpbC0E+P++/qYytg HQ5FTG4Bxo9q4tzMBl2pmgIxYcp0Wdrb1oBHR55SljNDzJ7/fgC7GRQaRRXUkej4LyMv nkGC2gbtrBRz4gbDXVK8j5oGK6G7VHBajxTkN1nq8/k97kcZpiIhhe6BGro+5rZXPSmO vjWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=eb9dZSKMoZpOZp4Ps1JeXoJyoHR6QDQL1zZK4YZQWBQ=; b=ZulmpFBVeoe1oA1lh1L3Q1OAuqDfGRKoWAPv4/Qg4bYKU8K+S728tShTSo4xW7u93m RphSsqNx6ptfNpaZQY/8DxuDx7BX+t9HHjw2NXomrDrwskeUg+Q3wKLu38gI1Ly33Log ZJgDSqWb66zk7eJpLWgvujarFPBqIgSF3ntKPHRExUIatukkVgCSwDY8F+LB6Ei4wnGr i/DdbEmbov++BU4KVAi0WK7PVSmVUt3U5TOswiKApKEkY6iqm76EL/BCEKTY7b9omd2n s0iKXfE5EtM4gXAOWu2r9k5QIQp2/NXrI/8DMz6NAg+HPgfylJ+313ZrhD3swlxXIDQB ryLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=VHG9zDIc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cf13-v6si22493047plb.175.2018.07.12.12.18.51; Thu, 12 Jul 2018 12:19:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=VHG9zDIc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727037AbeGLT15 (ORCPT + 99 others); Thu, 12 Jul 2018 15:27:57 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:36707 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726583AbeGLT14 (ORCPT ); Thu, 12 Jul 2018 15:27:56 -0400 Received: by mail-pg1-f194.google.com with SMTP id m19-v6so4185607pgv.3 for ; Thu, 12 Jul 2018 12:17:03 -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:user-agent; bh=eb9dZSKMoZpOZp4Ps1JeXoJyoHR6QDQL1zZK4YZQWBQ=; b=VHG9zDIcGlNdu0ZzAZWLiMm9zswuYdbJlzhq4BrWWbHZ5oO9rAtTkaTbXDOK6TO6zZ TrC/ebPsxXeafvmwj1mZQhs8XB/xqjHAYYk05S/msIBjLYCNj3HUgiY9eqrjX/uzoBAa rYZpNonYjMmkS1Ykl8vHI4guPeF1Vx0AoFW0E= 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:user-agent; bh=eb9dZSKMoZpOZp4Ps1JeXoJyoHR6QDQL1zZK4YZQWBQ=; b=Dt/8kTq0EpV+3m6QvH+l9L0gj5S3BqTdKnfkGg9E2eGMS3pM3lf0wnpJQWviVrDTSN MqoLVVU8I7CjxdljIQ3p2TVQaDPmr5SkK011x+B2+sNQg6y/+NdVaA9GwItI9PN6pxIp y4smfB2OuNEL0jEcbxJbRVp/W5WTUnKoSCrwYTxFTimhFZE6f0d/RjzFmVovtnqxj/B3 B+hzTAytZn/kp7H4ZHAwWsYJIsAtS8I0h/prhJASvatxudzl67ydNoqnVJXkYAwV505z /ED+NcGn3nTxvexnPcH0FtU71ncTuv1lN/AENShns6PaNnrZMvL9XTflcR5j6qHrO0AP R+lg== X-Gm-Message-State: AOUpUlFf5ajbENCSCZOQSqAmuRnw1MNKc09sADMOFW2vvcXmtgj4GUFo GbaphlnEP3t62HSisKpvGFVJ2A== X-Received: by 2002:a63:66c7:: with SMTP id a190-v6mr3160570pgc.411.1531423022936; Thu, 12 Jul 2018 12:17:02 -0700 (PDT) Received: from localhost ([2620:0:1000:1600:3122:ea9c:d178:eb]) by smtp.gmail.com with ESMTPSA id f6-v6sm32545839pgp.13.2018.07.12.12.17.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 12:17:02 -0700 (PDT) Date: Thu, 12 Jul 2018 12:17:01 -0700 From: Joel Fernandes To: Steven Rostedt Cc: "Paul E. McKenney" , Peter Zijlstra , linux-kernel@vger.kernel.org, Boqun Feng , Byungchul Park , Ingo Molnar , Julia Cartwright , linux-kselftest@vger.kernel.org, Masami Hiramatsu , Mathieu Desnoyers , Namhyung Kim , Thomas Glexiner , Tom Zanussi Subject: Re: [PATCH v9 4/7] tracepoint: Make rcuidle tracepoint callers use SRCU Message-ID: <20180712191701.GA107829@joelaf.mtv.corp.google.com> References: <20180628182149.226164-1-joel@joelfernandes.org> <20180628182149.226164-5-joel@joelfernandes.org> <20180711124954.GE2476@hirez.programming.kicks-ass.net> <20180711090003.42596c2b@gandalf.local.home> <20180711142744.GN3593@linux.vnet.ibm.com> <20180711104618.05dc4b46@gandalf.local.home> <20180711205249.GA32091@joelaf.mtv.corp.google.com> <20180711232120.5dbfa1c7@vmware.local.home> <20180712042825.GA154647@joelaf.mtv.corp.google.com> <20180712093512.1f612a24@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180712093512.1f612a24@gandalf.local.home> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 12, 2018 at 09:35:12AM -0400, Steven Rostedt wrote: > On Wed, 11 Jul 2018 21:28:25 -0700 > Joel Fernandes wrote: > > > On Wed, Jul 11, 2018 at 11:21:20PM -0400, Steven Rostedt wrote: > > > On Wed, 11 Jul 2018 13:52:49 -0700 > > > Joel Fernandes wrote: > > > > > > > > #define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ > > > > > extern struct tracepoint __tracepoint_##name; \ > > > > > static inline void trace_##name(proto) \ > > > > > { \ > > > > > if (static_key_false(&__tracepoint_##name.key)) \ > > > > > __DO_TRACE(&__tracepoint_##name, \ > > > > > TP_PROTO(data_proto), \ > > > > > TP_ARGS(data_args), \ > > > > > TP_CONDITION(cond), 0); \ > > > > > if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) { \ > > > > > rcu_read_lock_sched_notrace(); \ > > > > > rcu_dereference_sched(__tracepoint_##name.funcs);\ > > > > > rcu_read_unlock_sched_notrace(); \ > > > > > } \ > > > > > } > > > > > > > > > > Because lockdep would only trigger warnings when the tracepoint was > > > > > enabled and used in a place it shouldn't be, we added the above > > > > > IS_ENABLED(CONFIG_LOCKDEP) part to test regardless if the the > > > > > tracepoint was enabled or not. Because we do this, we don't need to > > > > > have the test in the __DO_TRACE() code itself. That means we can clean > > > > > up the code as per Peter's suggestion. > > > > > > > > Sounds good, I'm Ok with making this change. > > > > > > > > Just to clarify, are you proposing to change the rcu_dereference_sched to > > > > rcu_dereference_raw in both __DECLARE_TRACE and __DO_TRACE? > > > > > > No, just in __DO_TRACE(). The rcu_dereference_sched() above in > > > __DECLARE_TRACE() in the if (IS_ENABLED(CONFIG_LOCKDEP) block is > > > required to show the warnings if trace_##name() is used wrong, and is > > > the reason we can use rcu_dereference_raw() in __DO_TRACE() in the > > > first place ;-) > > > > > > This brings up another point. We should probably add to > > > __DECLARE_TRACE_RCU() this: > > > > > > #ifndef MODULE > > > #define __DECLARE_TRACE_RCU(name, proto, args, cond, data_proto, data_args) \ > > > static inline void trace_##name##_rcuidle(proto) \ > > > { \ > > > if (static_key_false(&__tracepoint_##name.key)) \ > > > __DO_TRACE(&__tracepoint_##name, \ > > > TP_PROTO(data_proto), \ > > > TP_ARGS(data_args), \ > > > TP_CONDITION(cond), 1); \ > > > + if (IS_ENABLED(CONFIG_LOCKDEP) && (cond)) { \ > > > + int idx; \ > > > + idx = srcu_read_lock_notrace(&tracepoint_srcu); \ > > > + srcu_dereference_notrace(__tracepoint_##name.funcs, \ > > > + &tracepoint_srcu); \ > > > + srcu_read_unlock_notrace(&tracepoint_srcu, idx); \ > > > + } \ > > > } > > > #else > > > > > > > > > So that lockdep works with trace_##name##__rcuidle() when the trace > > > event is not enabled. > > > > > > But that should be a separate patch and not part of this series. I may > > > write that up tomorrow. > > > > Yes, that sounds good to me and would be good to add the safe guard there. > > But you meant srcu_dereference above, not srcu_dereference_notrace right? > > We don't need to trace them. I believe that the "srcu_*_notrace" still > performs the lockdep checks. That's what we want. If they don't then we > should not use notrace. But I believe they still do lockdep. AFAICT, _notrace doesn't call into lockdep or tracing (there's also a comment that says so): /** * srcu_dereference_notrace - no tracing and no lockdep calls from here */ So then, we should use the regular variant for this additional check you're suggesting. thanks, - Joel