Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp676532yba; Sat, 4 May 2019 10:16:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjn3hMEEGOes/Nuj1bN/8AeixmKFpTLpf5uOMrBuG541cC1ZKTwZTg55ODkdJJwO11h8Yj X-Received: by 2002:a65:4589:: with SMTP id o9mr20097955pgq.381.1556990168607; Sat, 04 May 2019 10:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556990168; cv=none; d=google.com; s=arc-20160816; b=BMawXrTWV9zvf8C9dY2KcYcVQfK803bDlzn1SHNjoxFIGfNGVNbdvLVYFDVOwdbfok ELa2SYvZPG0OGstwJyY/npBpcGFWye5HTgX/FZEp2C+i9BJ9Mgw/dn4nEA5Yseu0iF6U TXbECBeUDM2YGsFpk6iOFPy9ycbEcJK2SoYVZz66MysFAwWIY53L0dxKlJVBkPTyYBhZ r6wiL+lXT8QQ2u6wKQpy0DXNAsn6B68AZRMlaMAs5OB8T1JAnc3Gv30XdA32mPYTxKe2 dD+k5yg+tAJprXp398EBn1ZbhpRl/3oIZeBG/32HZ29WZZ473uA6yP9WIzulEi6QMJ79 ZP0A== 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; bh=iOjZV9PSSRl0bVJzHlyqakIGIVKpkRTY5TVtwEOyWCc=; b=rECGW9s6al1KfnSfD3Ux/YDPufZ1U1MIgLUdh81n3rCQoyM6xyi+1cWN9rTIfjUK0D /jlRBYOUqU9iIiNedUE97aP5DP2zXYVkOaQvrOMx/C2xlTlgH9FfmvFNrInclkCXlK4k 1yOuXuya6oAdUc8HN5a151fVkZ5OONx+yPlEHjRKkSEq+x9XKsPfpRRsayTS5ANr7i1I 0DSb5l1Rlf2mVjT6XV0wI9NdjpFR5Fkjh9J3+IGtFzLBT3Xes/ET3qclTzYTM2cGAsEq vdA3caXCPg2X759GTXWNUcuuOQgiBr0tLzHI6oS1VLKLQ2XGviaTgcknqLCrbNTieXI5 mk2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=k7XBhL8c; 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 i7si2970436pgb.597.2019.05.04.10.15.19; Sat, 04 May 2019 10:16:08 -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=k7XBhL8c; 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 S1726763AbfEDQrN (ORCPT + 99 others); Sat, 4 May 2019 12:47:13 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:33282 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726217AbfEDQrN (ORCPT ); Sat, 4 May 2019 12:47:13 -0400 Received: by mail-pg1-f193.google.com with SMTP id k19so4291137pgh.0 for ; Sat, 04 May 2019 09:47:13 -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=iOjZV9PSSRl0bVJzHlyqakIGIVKpkRTY5TVtwEOyWCc=; b=k7XBhL8cal8SNiBFGLQcBDHBWmyyz0mWap57Z5Io442A5Y9lU3//9law5zcEBNIzn9 KqLNRToBRRfN33RkUvdf99BUb/8sbTZrdDpEEuqha7b6dCAevwqKbIk0Oxd2B/D30R4J lNhlmS/+L+BtSAvqQ49vjhLP+x8D79Vgndu3Y= 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=iOjZV9PSSRl0bVJzHlyqakIGIVKpkRTY5TVtwEOyWCc=; b=PjZhozBReY2cuLD3V8xRHjdDrQeICjdMNrlq46L0gNzve7j76/sMQ8lt6tp0muSHQy L+HryaIdLsYs1FYSA5BxTFMnTE/PJD/F1SLOM5JYGYN2/hTj1E4A0TyKqJOPiISZsbPb 0BPYRL0zZHa4IQj8upa7vvsghzv0v9pXqLkas2F/zLUjnuQX6n5Jt3KE8Am0pFIqqbF+ e/8kHWw/0EWHt1/7E7TkWswxG5SnmVFkdxuMSAw+PvS+7ZUvylL8Vql9Wde/N+apEwj+ 4GanfM4FsdkBCDi6yiHRJdr+SN0DP79gzlktBCiPpZ8+IDRyeh7Zr+NzBKcrmOqruCeV NDug== X-Gm-Message-State: APjAAAWQqWP9ouvpvln4G8nQl2Ig0V2d+V/mj53cvizdnvl71SHjtUth FU3556s/nR7sofE671UOwv493Q== X-Received: by 2002:a63:ee15:: with SMTP id e21mr19977248pgi.180.1556988432727; Sat, 04 May 2019 09:47:12 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id c17sm7026957pfn.173.2019.05.04.09.47.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 04 May 2019 09:47:11 -0700 (PDT) Date: Sat, 4 May 2019 12:47:10 -0400 From: Joel Fernandes To: Viktor Rosendahl Cc: Steven Rostedt , Ingo Molnar , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/4] ftrace: Implement fs notification for preempt/irqsoff tracers Message-ID: <20190504164710.GA55790@google.com> References: <20190501203650.29548-1-viktor.rosendahl@gmail.com> <20190501203650.29548-2-viktor.rosendahl@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190501203650.29548-2-viktor.rosendahl@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 01, 2019 at 10:36:47PM +0200, Viktor Rosendahl wrote: > This patch implements the feature that the trace file, e.g. > /sys/kernel/debug/tracing/trace will receive notifications through > the fsnotify framework when a new trace is available. > > This makes it possible to implement a user space program that can, > with equal probability, obtain traces of latencies that occur > immediately after each other in spite of the fact that the > preempt/irqsoff tracers operate in overwrite mode. > > Signed-off-by: Viktor Rosendahl I agree with the general idea, but I don't really like how it is done in the patch. We do have a notification mechanism already in the form of trace_pipe. Can we not improve that in some way to be notified of a new trace data? In theory, the trace_pipe does fit into the description in the documentation: "Reads from this file will block until new data is retrieved" More comment below: > --- > kernel/trace/Kconfig | 10 ++++++++++ > kernel/trace/trace.c | 31 +++++++++++++++++++++++++++++-- > kernel/trace/trace.h | 5 +++++ > kernel/trace/trace_irqsoff.c | 35 +++++++++++++++++++++++++++++++++++ > 4 files changed, 79 insertions(+), 2 deletions(-) > > diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig > index 8bd1d6d001d7..35e5fd3224f6 100644 > --- a/kernel/trace/Kconfig > +++ b/kernel/trace/Kconfig > @@ -234,6 +234,16 @@ config PREEMPT_TRACER > enabled. This option and the irqs-off timing option can be > used together or separately.) > > + config PREEMPTIRQ_FSNOTIFY > + bool "Generate fsnotify events for the latency tracers" > + default n > + depends on (IRQSOFF_TRACER || PREEMPT_TRACER) && FSNOTIFY > + help > + This option will enable the generation of fsnotify events for the > + trace file. This makes it possible for userspace to be notified about > + modification of /sys/kernel/debug/tracing/trace through the inotify > + interface. Does this have to be a CONFIG option? If prefer if the code automatically does the notification and it is always enabled. I don't see any drawbacks of that. > + > config SCHED_TRACER > bool "Scheduling Latency Tracer" > select GENERIC_TRACER > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c > index ca1ee656d6d8..ebefb8d4e072 100644 > --- a/kernel/trace/trace.c > +++ b/kernel/trace/trace.c > @@ -44,6 +44,8 @@ > #include > #include > #include > +#include > +#include > > #include "trace.h" > #include "trace_output.h" > @@ -8191,6 +8193,32 @@ static __init void create_trace_instances(struct dentry *d_tracer) > return; > } > > +#ifdef CONFIG_PREEMPTIRQ_FSNOTIFY > + > +static void trace_notify_workfn(struct work_struct *work) [snip] I prefer if this facility is available to other tracers as well such as the wakeup tracer which is similar in output (check Documentation/trace/ftrace.txt). I believe this should be a generic trace facility, and not tracer specific. thanks, - Joel