]> git.baikalelectronics.ru Git - kernel.git/commit
tracing: Add division and multiplication support for hist triggers
authorKalesh Singh <kaleshsingh@google.com>
Mon, 25 Oct 2021 20:08:34 +0000 (13:08 -0700)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Wed, 27 Oct 2021 00:27:19 +0000 (20:27 -0400)
commit4f8d8d39eec613d08c1cb09cfade80c4622640b6
tree168de8e69da0be1ecd3140e4f556db54909f2488
parent160034ef5e14d4993dd9de74226eec82157c380c
tracing: Add division and multiplication support for hist triggers

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.com
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/trace_events_hist.c