Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3514239pxx; Mon, 2 Nov 2020 10:53:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJxS6aQl8i1h5ZhyiHnwACtJS+cudqiiHVDYkB5yDuXAvU3gXkxsM03bLfqeKd8DbCBQu+H8 X-Received: by 2002:a17:906:13cd:: with SMTP id g13mr5621410ejc.394.1604343210363; Mon, 02 Nov 2020 10:53:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604343210; cv=none; d=google.com; s=arc-20160816; b=lJ2qAcU8ucgNfg9jceBrL51ElTDQHUC/sZ3VKNQvxy3P2hDJ42mGQmalZBRYhQU1TR DgAPKZObJywIE325WD4/DoRZVeMqZhnJI3UqVDm5p4NLk87M6SSPCxr8ivrIEYNyRMeA vPPoxtRXFOH8pcNEEX6mMIpWQRsP01lYnj1r/JtqD10ms5rhanjnIYpC3odSRYwBgHA6 A5yKJVO8xIqwA3zRFjaKjfMQkAMtkPoj7JbnFBllLYO8M0PODI026CgE8eIQP6NMpgrM gO2mpcRdY1P2CUE7MlqZo4Yy+iD/wtGLCMHmbjhX9ywUAEIBeem/fED8ByiWnCRAVyy9 sKxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Rxilry/ji3nfiO3JLB2z5Ve/eVy0zWt8AyEvNUngD2c=; b=xgMuh5f04XB5zFTgYU2/EncgZ7/ItzqZlv9CyiIw+gp2jwhd/+39J9fJO8jINwm7k9 6/gc+5kf4HppGG5vhwjiQ45Xsy8/OZQE6u1VhZsctQnaTAtV9m1wBwEBYCfjdrC2Ici+ 2Vg3oEJEF3Cq5O2ILNRMrutOg5LPeac9qQr+44UUFlEO5LeqWS7nyzhxWjZaoTArwQqf jyE08axavD7h7dNSI90ImnJG6EaJoBze0uBIbMB+IgsT/oTZtMXy6AR1WiYTvrbi9gnT jANvYaNmvKfE6qQiRDCtERLOWBpLvuk6mOgRCHf6iORme83GfSZnjsxoaaqQAgySasAz 97Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=dKtG6LmA; 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 p3si11015829eja.565.2020.11.02.10.53.06; Mon, 02 Nov 2020 10:53:30 -0800 (PST) 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=dKtG6LmA; 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 S1725929AbgKBSv3 (ORCPT + 99 others); Mon, 2 Nov 2020 13:51:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbgKBSv3 (ORCPT ); Mon, 2 Nov 2020 13:51:29 -0500 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAFBDC0617A6 for ; Mon, 2 Nov 2020 10:51:28 -0800 (PST) Received: by mail-qk1-x741.google.com with SMTP id r7so12456944qkf.3 for ; Mon, 02 Nov 2020 10:51:28 -0800 (PST) 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=Rxilry/ji3nfiO3JLB2z5Ve/eVy0zWt8AyEvNUngD2c=; b=dKtG6LmAlh3COooqJe2opsc1vsdAPado7jNhzT70IvKawfZtenI/Woq5VZgoB0+zZ1 m6OKk6LlKYnTnR6JxLDAm7d42kdgHj268lvzUjwxWfTYn5ds2bZAC9IgCf0sbhuiKKyl HxSiwHd5jFd/3DD72IanvqHDuEWCb2grAqguE= 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=Rxilry/ji3nfiO3JLB2z5Ve/eVy0zWt8AyEvNUngD2c=; b=Q+TucLtMquXNTAFhK03+d9NkvM5IdZ6s1J5o1QtoI3F1H/EpRHJmG0zp5QXDyTtzTy 8iFWQel06rFUZrZV2QHtBCVGCPrFFClaK1Yo1G6AYapbbe5qvRyuGi7jTfoxmoIs73l1 6AUOgXkSJe3m7AjZ5Vz9EskS91/jKnljnMbPJfDK64D15jaT4gzKINSZweAI3lmUSbHL OywQUSzvJc9Sf2YEnDit0YNAu/I9+0/4NFHsFi0Amo6Fz9fqnSW9BEoi5pQ+lNe4b4bE jH6bfSRW6qrLGdEXB8ge6FUFM46PQPDnyFy9PHuWRXeUfpT8HWhxTagxH7Ai+pKU1nTb ml9w== X-Gm-Message-State: AOAM53030CVHVn7DR1/LNF/IS724wSpdGhpeKl4Sg1XkBkw738W9UFR3 xpqj4ZQrvrFxoS+xSCS6+XenWw== X-Received: by 2002:a37:9a46:: with SMTP id c67mr16146337qke.292.1604343087896; Mon, 02 Nov 2020 10:51:27 -0800 (PST) Received: from localhost ([2620:15c:6:411:cad3:ffff:feb3:bd59]) by smtp.gmail.com with ESMTPSA id x22sm8543868qki.104.2020.11.02.10.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 10:51:27 -0800 (PST) Date: Mon, 2 Nov 2020 13:51:26 -0500 From: Joel Fernandes To: Mathieu Desnoyers Cc: Alexei Starovoitov , Michael Jeanson , linux-kernel , rostedt , Peter Zijlstra , Alexei Starovoitov , Yonghong Song , paulmck , Ingo Molnar , acme , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , bpf Subject: Re: [RFC PATCH 1/6] tracing: introduce sleepable tracepoints Message-ID: <20201102185126.GB595952@google.com> References: <20201023195352.26269-1-mjeanson@efficios.com> <20201023195352.26269-2-mjeanson@efficios.com> <20201026224301.gi4bakmj3pov5zyu@ast-mbp.dhcp.thefacebook.com> <1631556114.38532.1603805828748.JavaMail.zimbra@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1631556114.38532.1603805828748.JavaMail.zimbra@efficios.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 27, 2020 at 09:37:08AM -0400, Mathieu Desnoyers wrote: > > ----- On Oct 26, 2020, at 6:43 PM, Alexei Starovoitov alexei.starovoitov@gmail.com wrote: > > > On Fri, Oct 23, 2020 at 03:53:47PM -0400, Michael Jeanson wrote: > >> -#define __DO_TRACE(tp, proto, args, cond, rcuidle) \ > >> +#define __DO_TRACE(tp, proto, args, cond, rcuidle, tp_flags) \ > >> do { \ > >> struct tracepoint_func *it_func_ptr; \ > >> void *it_func; \ > >> void *__data; \ > >> int __maybe_unused __idx = 0; \ > >> + bool maysleep = (tp_flags) & TRACEPOINT_MAYSLEEP; \ > >> \ > >> if (!(cond)) \ > >> return; \ > >> @@ -170,8 +178,13 @@ static inline struct tracepoint > >> *tracepoint_ptr_deref(tracepoint_ptr_t *p) > >> /* srcu can't be used from NMI */ \ > >> WARN_ON_ONCE(rcuidle && in_nmi()); \ > >> \ > >> - /* keep srcu and sched-rcu usage consistent */ \ > >> - preempt_disable_notrace(); \ > >> + if (maysleep) { \ > >> + might_sleep(); \ > > > > The main purpose of the patch set is to access user memory in tracepoints, > > right? > > Yes, exactly. > > > In such case I suggest to use stronger might_fault() here. > > We used might_sleep() in sleepable bpf and it wasn't enough to catch > > a combination where sleepable hook was invoked while mm->mmap_lock was > > taken which may cause a deadlock. > > Good point! We will do that for the next round. > > By the way, we named this "sleepable" tracepoint (with flag TRACEPOINT_MAYSLEEP), > but we are open to a better name. Would TRACEPOINT_MAYFAULT be more descriptive ? > (a "faultable" tracepoint sounds weird though) What about keeping it might_sleep() here and then adding might_fault() in the probe handler? Since the probe handler knows that it may cause page fault, it could itself make sure about it. One more thought: Should we make _all_ tracepoints sleepable, and then move the preempt_disable() bit to the probe handler as needed? That could simplify the tracepoint API as well. Steven said before that whoever registers probes knows what they are doing so I am ok with that. No strong feelings one way or the other, for either of these though. thanks, - Joel > > Thanks, > > Mathieu > > > > >> + rcu_read_lock_trace(); \ > >> + } else { \ > >> + /* keep srcu and sched-rcu usage consistent */ \ > >> + preempt_disable_notrace(); \ > > > + } \ > > -- > Mathieu Desnoyers > EfficiOS Inc. > http://www.efficios.com