Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp19049580ybl; Fri, 3 Jan 2020 14:38:09 -0800 (PST) X-Google-Smtp-Source: APXvYqwKhPEig5FRP59YZbBE5qoqGrDoHlpf9giAIXSfBbt222B6SpH2slLQkY50B85QOIudya9m X-Received: by 2002:a9d:5786:: with SMTP id q6mr80869635oth.164.1578091089478; Fri, 03 Jan 2020 14:38:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578091089; cv=none; d=google.com; s=arc-20160816; b=v+iFwVssqnKf8jtLxar+ZAX1Oe1PjEDGWqalh+xf12QpB+B9xrEhTPzRAtsQfGB0V9 gSn/C3bBxh5b5+46o61L98ND5eRK8KrqUEbcWB0kjGpX3xmUzFVsm9XSktJl660II+Ta Gm+qrkSYfmFdiIjFD5eMMx1pkFibWuhdGJdK3ayCdHQHsJw/rLcnD/8t5CubgfZ5KRiA 4V4YJ0/ud1SGRksuVqyWf69fFKzUkAmqlaxzNQjSo4Z/PoQb17kH2YYr5+XblJ6EanAw bYUH4j8oFNQqTPgeLfXGbUQn9RpW7eARJCcZfO5ntA1950PXJGlT8PjQUTk8OQbhElRD yPfg== 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=9z2Jrxz8B+NqLAfVzgb4mOFXsmumv7Pnna32uCgS49s=; b=KSZIpFQmoZfGNf7PGoGLWQ6J9SQ8dRvm/KCuYd39+PdwUSLo42pl+1H4KqzkOi6net zfUTwJ97TxuHvgmU/9QggopuA3WoNIn+RKspQMf/HTAGgUIvNSO/4mSb9sgs6NG1wqSi d45c6wL6R7vF2/4VUt8cYMnC3JpzfVsYZ0p38KK0P+9Uo9AFhsO9fOP1tAyQXtfczbjc 0EOr08KLPAttrAmo48/c12/Ej7CzJquNFO9B9bw9HzYdMjqFPid8ZofOg54iX4li8gDv /w4RujBYCDDajB7lmP2+gukupAclK2NlITG21n6fJqKY2LMYteElUVw7blZ9yfZkyNHW EGUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=tnVP3zsf; 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 l14si22336349oic.222.2020.01.03.14.37.57; Fri, 03 Jan 2020 14:38:09 -0800 (PST) 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=tnVP3zsf; 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 S1728825AbgACWhO (ORCPT + 99 others); Fri, 3 Jan 2020 17:37:14 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:39630 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728781AbgACWhN (ORCPT ); Fri, 3 Jan 2020 17:37:13 -0500 Received: by mail-pf1-f194.google.com with SMTP id q10so24104670pfs.6 for ; Fri, 03 Jan 2020 14:37:13 -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:user-agent; bh=9z2Jrxz8B+NqLAfVzgb4mOFXsmumv7Pnna32uCgS49s=; b=tnVP3zsfQZQf9IWPzBds6IQBbwJHd5p9iz+Gd5cjZpF6689inCWlaBe62w13DNeDts ej4KRjVqOYZWa2LQT+cejZuDr+nfEP45lqqszvee0l3CRBTAE+l9TQ9hSaujLNxnVLY4 yRsI7qYYntWPdQ8etEekh8I+a+JLY87H+cSFo= 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=9z2Jrxz8B+NqLAfVzgb4mOFXsmumv7Pnna32uCgS49s=; b=GmfjFNQuBYPKtAkKZcOgv9h+LrzqeCWzXzE3+phgLkdCHu4FLjnavC+I0jAr3N7I2V h4D6omz+UUVnB015FcG4vwgau4WiNIDToy86xaWYrRcuTPPG2g+iffoW71S1VIGdtA3p DsBnN4arD1nX6lBZdlHhbe2Em2cHlrgRxMn6TurT8VyhVdMwYYmXqwp1HWUzmTCZ13qZ /dQV7XkXqHwuGrvlO4FGJyp5mV9ujfA2lnKRBKtxJwjT9sRh8zr8m6XW3V+ulwy967/+ Eq6wkDjLlTmyYJeM2TfCVJV0PvjJmNNoRKuEfYP3VS33fvPtK5Ano3bmvEHuNQirwYt3 CNKw== X-Gm-Message-State: APjAAAXfg8CttznrWeNjOac5Vl3gFVERNmTc+rj1v9os74Cslw024oqs f98RFj18vU91kFVjgD/tmiiVJg== X-Received: by 2002:a63:de03:: with SMTP id f3mr100645112pgg.141.1578091033299; Fri, 03 Jan 2020 14:37:13 -0800 (PST) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id z6sm54042858pfa.155.2020.01.03.14.37.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2020 14:37:12 -0800 (PST) Date: Fri, 3 Jan 2020 17:37:11 -0500 From: Joel Fernandes To: Steven Rostedt Cc: "Frank A. Cancio Bello" , Ingo Molnar , linux-kernel@vger.kernel.org, saiprakash.ranjan@codeaurora.org, nachukannan@gmail.com Subject: Re: [PATCH] tracing: Resets the trace buffer after a snapshot Message-ID: <20200103223711.GC189259@google.com> References: <20191231085822.yxhph6wcguejb7al@frank-laptop> <20200103114001.2c118ab1@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200103114001.2c118ab1@gandalf.local.home> 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 Fri, Jan 03, 2020 at 11:40:01AM -0500, Steven Rostedt wrote: > On Tue, 31 Dec 2019 03:58:22 -0500 > "Frank A. Cancio Bello" wrote: > > > Currently, when a snapshot is taken the trace_buffer and the > > max_buffer are swapped. After this swap, the "new" trace_buffer is > > not reset. This produces an odd behavior: after a snapshot is taken > > the previous snapshot entries become available to the next reader of > > the trace_buffer as far as the reading occurs before the buffer is > > refilled with new entries by a writer. > > I consider this a feature not a bug ;-) > > Anyway, this behavior should be determined by an option. Care to create > one? (reset_on_snapshot?) I would keep the default behavior the same, > but document this a bit better. I relate to what Steve said as well. It is not strictly a bug per-se. An option to do this would be nice but I am doubting a user will really turn on such option (or even know an option exists) ;-). I would say leave it in the current state unless some usecase is disrupted by the current behavior.. thanks! - Joel > > Thanks! > > -- Steve > > > > > This patch resets the trace buffer after a snapshot is taken. > > > > Signed-off-by: Frank A. Cancio Bello > > --- > > > > The following commands illustrate this odd behavior: > > > > # cd /sys/kernel/debug/tracing > > # echo nop > current_tracer > > # echo 1 > tracing_on > > # echo m1 > trace_marker > > # echo 1 > snapshot > > # echo m2 > trace_marker > > # echo 1 > snapshot > > # cat trace > > # tracer: nop > > # > > # entries-in-buffer/entries-written: 1/1 #P:2 > > # > > # _-----=> irqs-off > > # / _----=> need-resched > > # | / _---=> hardirq/softirq > > # || / _--=> preempt-depth > > # ||| / delay > > # TASK-PID CPU# |||| TIMESTAMP FUNCTION > > # | | | |||| | | > > bash-550 [000] .... 50.479755: tracing_mark_write: m1 > > > > > > kernel/trace/trace.c | 7 +++++-- > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c > > index ddb7e7f5fe8d..58373b5ae0cf 100644 > > --- a/kernel/trace/trace.c > > +++ b/kernel/trace/trace.c > > @@ -6867,10 +6867,13 @@ tracing_snapshot_write(struct file *filp, const char __user *ubuf, size_t cnt, > > break; > > local_irq_disable(); > > /* Now, we're going to swap */ > > - if (iter->cpu_file == RING_BUFFER_ALL_CPUS) > > + if (iter->cpu_file == RING_BUFFER_ALL_CPUS) { > > update_max_tr(tr, current, smp_processor_id(), NULL); > > - else > > + tracing_reset_online_cpus(&tr->trace_buffer); > > + } else { > > update_max_tr_single(tr, current, iter->cpu_file); > > + tracing_reset_cpu(&tr->trace_buffer, iter->cpu_file); > > + } > > local_irq_enable(); > > break; > > default: >