Message ID | 20211027205919.1648553-3-kaleshsingh@google.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | tracing/kselftest: histogram trigger expression tests | expand |
Hi Kalesh, On Wed, 27 Oct 2021 13:59:09 -0700 Kalesh Singh <kaleshsingh@google.com> wrote: > If an event trigger references a variable defined in another trigger, it > has to be removed before the trigger that defines the variable is > removed. > > Signed-off-by: Kalesh Singh <kaleshsingh@google.com> > --- > tools/testing/selftests/ftrace/test.d/functions | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions > index 000fd05e84b1..bd9e85f4d626 100644 > --- a/tools/testing/selftests/ftrace/test.d/functions > +++ b/tools/testing/selftests/ftrace/test.d/functions > @@ -22,6 +22,15 @@ reset_trigger_file() { > file=`echo $line | cut -f1 -d:` > echo "!$cmd" >> $file > done > + > + # remove triggers with references next > + grep -H '\$' $@ | > + while read line; do > + cmd=`echo $line | cut -f2- -d: | cut -f1 -d"["` > + file=`echo $line | cut -f1 -d:` > + echo "!$cmd" >> $file > + done > + Why don't you use 'tac'? I love that idea :) Did you find any issue? I think the function which cleaning up the tracing file should use the 'tac' rollback method, because it is natural, simple and robust. Then the first loop for removing action triggers is not needed anymore. Thank you, > grep -Hv ^# $@ | > while read line; do > cmd=`echo $line | cut -f2- -d: | cut -f1 -d"["` > -- > 2.33.0.1079.g6e70778dc9-goog >
On Wed, Oct 27, 2021 at 2:58 PM Masami Hiramatsu <mhiramat@kernel.org> wrote: > > Hi Kalesh, > > On Wed, 27 Oct 2021 13:59:09 -0700 > Kalesh Singh <kaleshsingh@google.com> wrote: > > > If an event trigger references a variable defined in another trigger, it > > has to be removed before the trigger that defines the variable is > > removed. > > > > Signed-off-by: Kalesh Singh <kaleshsingh@google.com> > > --- > > tools/testing/selftests/ftrace/test.d/functions | 9 +++++++++ > > 1 file changed, 9 insertions(+) > > > > diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions > > index 000fd05e84b1..bd9e85f4d626 100644 > > --- a/tools/testing/selftests/ftrace/test.d/functions > > +++ b/tools/testing/selftests/ftrace/test.d/functions > > @@ -22,6 +22,15 @@ reset_trigger_file() { > > file=`echo $line | cut -f1 -d:` > > echo "!$cmd" >> $file > > done > > + > > + # remove triggers with references next > > + grep -H '\$' $@ | > > + while read line; do > > + cmd=`echo $line | cut -f2- -d: | cut -f1 -d"["` > > + file=`echo $line | cut -f1 -d:` > > + echo "!$cmd" >> $file > > + done > > + > > Why don't you use 'tac'? I love that idea :) > Did you find any issue? Hi Masami, Thanks for the reviews. As with the first set of patches using tac gives a regression here, though I'm not sure why it doesn't work -- I also thought reversing the order would handle any dependencies correctly. - Kalesh > > I think the function which cleaning up the tracing file should use > the 'tac' rollback method, because it is natural, simple and robust. > Then the first loop for removing action triggers is not needed anymore. > > Thank you, > > > grep -Hv ^# $@ | > > while read line; do > > cmd=`echo $line | cut -f2- -d: | cut -f1 -d"["` > > -- > > 2.33.0.1079.g6e70778dc9-goog > > > > > -- > Masami Hiramatsu <mhiramat@kernel.org>
On Wed, 27 Oct 2021 16:26:00 -0700 Kalesh Singh <kaleshsingh@google.com> wrote: > > Why don't you use 'tac'? I love that idea :) > > Did you find any issue? > > Hi Masami, > > Thanks for the reviews. As with the first set of patches using tac > gives a regression here, though I'm not sure why it doesn't work -- I > also thought reversing the order would handle any dependencies > correctly. Right, because are triggers not added by list_add_rcu() which adds to the head of the list. If anything, shouldn't things be removed in order? -- Steve
On Wed, 27 Oct 2021 19:54:54 -0400 Steven Rostedt <rostedt@goodmis.org> wrote: > On Wed, 27 Oct 2021 16:26:00 -0700 > Kalesh Singh <kaleshsingh@google.com> wrote: > > > > Why don't you use 'tac'? I love that idea :) > > > Did you find any issue? > > > > Hi Masami, > > > > Thanks for the reviews. As with the first set of patches using tac > > gives a regression here, though I'm not sure why it doesn't work -- I > > also thought reversing the order would handle any dependencies > > correctly. > > Right, because are triggers not added by list_add_rcu() which adds to > the head of the list. Oops, so are the triggers shown in the reverse order? (newer entry is top, older one is bottom) Then do we need this patch, because we don't care about the dependency. > If anything, shouldn't things be removed in order? Hmm, I think the trigger itself might better to be changed. If any dependency in the trigger list, it can not be restored from the copied file, like below may fail. cat events/foo/bar/trigger > /tmp/foo.bar.trigger cat /tmp/foo.bar.trigger > events/foo/bar/trigger (of course we can use 'tac' to restore it ...) This is Thank you,
On Wed, Oct 27, 2021 at 5:43 PM Masami Hiramatsu <mhiramat@kernel.org> wrote: > > On Wed, 27 Oct 2021 19:54:54 -0400 > Steven Rostedt <rostedt@goodmis.org> wrote: > > > On Wed, 27 Oct 2021 16:26:00 -0700 > > Kalesh Singh <kaleshsingh@google.com> wrote: > > > > > > Why don't you use 'tac'? I love that idea :) > > > > Did you find any issue? > > > > > > Hi Masami, > > > > > > Thanks for the reviews. As with the first set of patches using tac > > > gives a regression here, though I'm not sure why it doesn't work -- I > > > also thought reversing the order would handle any dependencies > > > correctly. > > > > Right, because are triggers not added by list_add_rcu() which adds to > > the head of the list. > > Oops, so are the triggers shown in the reverse order? > (newer entry is top, older one is bottom) > Then do we need this patch, because we don't care about the > dependency. In the case of the hist expression tests. they create a variable: echo 'hist:keys=common_pid:x=1+2' >> trigger Then print its value in another histogram: echo 'hist:keys=common_pid:vals=$x' >> trigger At least in this case, the triggers are listed from oldest (top) to newest (bottom): cat trigger hist:keys=common_pid:vals=hitcount:x=3:sort=hitcount:size=2048 [active] hist:keys=common_pid:vals=hitcount,$x:sort=hitcount:size=2048 [active] So we need to remove the trigger with the var ref first. - Kalesh > > > If anything, shouldn't things be removed in order? > > Hmm, I think the trigger itself might better to be changed. If any dependency in > the trigger list, it can not be restored from the copied file, like > below may fail. > > cat events/foo/bar/trigger > /tmp/foo.bar.trigger > cat /tmp/foo.bar.trigger > events/foo/bar/trigger > > (of course we can use 'tac' to restore it ...) > > This is > > Thank you, > > > -- > Masami Hiramatsu <mhiramat@kernel.org>
On Wed, Oct 27, 2021 at 7:58 PM Kalesh Singh <kaleshsingh@google.com> wrote: > > On Wed, Oct 27, 2021 at 5:43 PM Masami Hiramatsu <mhiramat@kernel.org> wrote: > > > > On Wed, 27 Oct 2021 19:54:54 -0400 > > Steven Rostedt <rostedt@goodmis.org> wrote: > > > > > On Wed, 27 Oct 2021 16:26:00 -0700 > > > Kalesh Singh <kaleshsingh@google.com> wrote: > > > > > > > > Why don't you use 'tac'? I love that idea :) > > > > > Did you find any issue? > > > > > > > > Hi Masami, > > > > > > > > Thanks for the reviews. As with the first set of patches using tac > > > > gives a regression here, though I'm not sure why it doesn't work -- I > > > > also thought reversing the order would handle any dependencies > > > > correctly. > > > > > > Right, because are triggers not added by list_add_rcu() which adds to > > > the head of the list. > > > > Oops, so are the triggers shown in the reverse order? > > (newer entry is top, older one is bottom) > > Then do we need this patch, because we don't care about the > > dependency. > > In the case of the hist expression tests. they create a variable: > echo 'hist:keys=common_pid:x=1+2' >> trigger > > Then print its value in another histogram: > echo 'hist:keys=common_pid:vals=$x' >> trigger > > At least in this case, the triggers are listed from oldest (top) to > newest (bottom): > cat trigger > hist:keys=common_pid:vals=hitcount:x=3:sort=hitcount:size=2048 [active] I realized the result of the expression can be read directly from the trigger info, now that expressions of constants are squashed to a single constant. So we wouldn't need the second trigger to see the value and can drop this patch. I'll resend a new version. Thanks, Kalesh > hist:keys=common_pid:vals=hitcount,$x:sort=hitcount:size=2048 [active] > > So we need to remove the trigger with the var ref first. > > - Kalesh > > > > > If anything, shouldn't things be removed in order? > > > > Hmm, I think the trigger itself might better to be changed. If any dependency in > > the trigger list, it can not be restored from the copied file, like > > below may fail. > > > > cat events/foo/bar/trigger > /tmp/foo.bar.trigger > > cat /tmp/foo.bar.trigger > events/foo/bar/trigger > > > > (of course we can use 'tac' to restore it ...) > > > > This is > > > > Thank you, > > > > > > -- > > Masami Hiramatsu <mhiramat@kernel.org>
diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions index 000fd05e84b1..bd9e85f4d626 100644 --- a/tools/testing/selftests/ftrace/test.d/functions +++ b/tools/testing/selftests/ftrace/test.d/functions @@ -22,6 +22,15 @@ reset_trigger_file() { file=`echo $line | cut -f1 -d:` echo "!$cmd" >> $file done + + # remove triggers with references next + grep -H '\$' $@ | + while read line; do + cmd=`echo $line | cut -f2- -d: | cut -f1 -d"["` + file=`echo $line | cut -f1 -d:` + echo "!$cmd" >> $file + done + grep -Hv ^# $@ | while read line; do cmd=`echo $line | cut -f2- -d: | cut -f1 -d"["`
If an event trigger references a variable defined in another trigger, it has to be removed before the trigger that defines the variable is removed. Signed-off-by: Kalesh Singh <kaleshsingh@google.com> --- tools/testing/selftests/ftrace/test.d/functions | 9 +++++++++ 1 file changed, 9 insertions(+)