1. 27 Oct, 2021 4 commits
    • Kalesh Singh's avatar
      tracing: Fix operator precedence for hist triggers expression · 9710b2f3
      Kalesh Singh authored
      The current histogram expression evaluation logic evaluates the
      expression from right to left. This can lead to incorrect results
      if the operations are not associative (as is the case for subtraction
      and, the now added, division operators).
      	e.g. 16-8-4-2 should be 2 not 10 --> 16-8-4-2 = ((16-8)-4)-2
      	     64/8/4/2 should be 1 not 16 --> 64/8/4/2 = ((64/8)/4)/2
      
      Division and multiplication are currently limited to single operation
      expression due to operator precedence support not yet implemented.
      
      Rework the expression parsing to support the correct evaluation of
      expressions containing operators of different precedences; and fix
      the associativity error by evaluating expressions with operators of
      the same precedence from left to right.
      
      Examples:
              (1) echo 'hist:keys=common_pid:a=8,b=4,c=2,d=1,w=$a-$b-$c-$d' \
                        >> event/trigger
              (2) echo 'hist:keys=common_pid:x=$a/$b/3/2' >> event/trigger
              (3) echo 'hist:keys=common_pid:y=$a+10/$c*1024' >> event/trigger
              (4) echo 'hist:keys=common_pid:z=$a/$b+$c*$d' >> event/trigger
      
      Link: https://lkml.kernel.org/r/20211025200852.3002369-4-kaleshsingh@google.comSigned-off-by: default avatarKalesh Singh <kaleshsingh@google.com>
      Reviewed-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      9710b2f3
    • Kalesh Singh's avatar
      tracing: Add division and multiplication support for hist triggers · bcef0441
      Kalesh Singh authored
      Adds basic support for division and multiplication operations for
      hist trigger variable expressions.
      
      For simplicity this patch only supports, division and multiplication
      for a single operation expression (e.g. x=$a/$b), as currently
      expressions are always evaluated right to left. This can lead to some
      incorrect results:
      
      	e.g. echo 'hist:keys=common_pid:x=8-4-2' >> event/trigger
      
      	     8-4-2 should evaluate to 2 i.e. (8-4)-2
      	     but currently x evaluate to  6 i.e. 8-(4-2)
      
      Multiplication and division in sub-expressions will work correctly, once
      correct operator precedence support is added (See next patch in this
      series).
      
      For the undefined case of division by 0, the histogram expression
      evaluates to (u64)(-1). Since this cannot be detected when the
      expression is created, it is the responsibility of the user to be
      aware and account for this possibility.
      
      Examples:
      	echo 'hist:keys=common_pid:a=8,b=4,x=$a/$b' \
                         >> event/trigger
      
      	echo 'hist:keys=common_pid:y=5*$b' \
                         >> event/trigger
      
      Link: https://lkml.kernel.org/r/20211025200852.3002369-3-kaleshsingh@google.comSigned-off-by: default avatarKalesh Singh <kaleshsingh@google.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      bcef0441
    • Kalesh Singh's avatar
      tracing: Add support for creating hist trigger variables from literal · 52cfb373
      Kalesh Singh authored
      Currently hist trigger expressions don't support the use of numeric
      literals:
      	e.g. echo 'hist:keys=common_pid:x=$y-1234'
      		--> is not valid expression syntax
      
      Having the ability to use numeric constants in hist triggers supports
      a wider range of expressions for creating variables.
      
      Add support for creating trace event histogram variables from numeric
      literals.
      
      	e.g. echo 'hist:keys=common_pid:x=1234,y=size-1024' >> event/trigger
      
      A negative numeric constant is created, using unary minus operator
      (parentheses are required).
      
      	e.g. echo 'hist:keys=common_pid:z=-(2)' >> event/trigger
      
      Constants can be used with division/multiplication (added in the
      next patch in this series) to implement granularity filters for frequent
      trace events. For instance we can limit emitting the rss_stat
      trace event to when there is a 512KB cross over in the rss size:
      
        # Create a synthetic event to monitor instead of the high frequency
        # rss_stat event
        echo 'rss_stat_throttled unsigned int mm_id; unsigned int curr;
      	int member; long size' >> tracing/synthetic_events
      
        # Create a hist trigger that emits the synthetic rss_stat_throttled
        # event only when the rss size crosses a 512KB boundary.
        echo 'hist:keys=keys=mm_id,member:bucket=size/0x80000:onchange($bucket)
            .rss_stat_throttled(mm_id,curr,member,size)'
              >> events/kmem/rss_stat/trigger
      
      A use case for using constants with addition/subtraction is not yet
      known, but for completeness the use of constants are supported for all
      operators.
      
      Link: https://lkml.kernel.org/r/20211025200852.3002369-2-kaleshsingh@google.comSigned-off-by: default avatarKalesh Singh <kaleshsingh@google.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      52cfb373
    • Masami Hiramatsu's avatar
      selftests/ftrace: Stop tracing while reading the trace file by default · 25b95138
      Masami Hiramatsu authored
      Stop tracing while reading the trace file by default, to prevent
      the test results while checking it and to avoid taking a long time
      to check the result.
      If there is any testcase which wants to test the tracing while reading
      the trace file, please override this setting inside the test case.
      
      This also recovers the pause-on-trace when clean it up.
      
      Link: https://lkml.kernel.org/r/163529053143.690749.15365238954175942026.stgit@devnote2Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      25b95138
  2. 26 Oct, 2021 17 commits
  3. 22 Oct, 2021 7 commits
  4. 21 Oct, 2021 12 commits