• Steven Rostedt (VMware)'s avatar
    tracing: Add linear buckets to histogram logic · de9a48a3
    Steven Rostedt (VMware) authored
    There's been several times I wished the histogram logic had a "grouping"
    feature for the buckets. Currently, each bucket has a size of one. That
    is, if you trace the amount of requested allocations, each allocation is
    its own bucket, even if you are interested in what allocates 100 bytes or
    less, 100 to 200, 200 to 300, etc.
    
    Also, without grouping, it fills up the allocated histogram buckets
    quickly. If you are tracking latency, and don't care if something is 200
    microseconds off, or 201 microseconds off, but want to track them by say
    10 microseconds each. This can not currently be done.
    
    There is a log2 but that grouping get's too big too fast for a lot of
    cases.
    
    Introduce a "buckets=SIZE" command to each field where it will record in a
    rounded number. For example:
    
     ># echo 'hist:keys=bytes_req.buckets=100:sort=bytes_req' > events/kmem/kmalloc/trigger
     ># cat events/kmem/kmalloc/hist
     # event histogram
     #
     # trigger info:
     hist:keys=bytes_req.buckets=100:vals=hitcount:sort=bytes_req.buckets=100:size=2048
     [active]
     #
    
     { bytes_req: ~ 0-99 } hitcount:       3149
     { bytes_req: ~ 100-199 } hitcount:       1468
     { bytes_req: ~ 200-299 } hitcount:         39
     { bytes_req: ~ 300-399 } hitcount:        306
     { bytes_req: ~ 400-499 } hitcount:        364
     { bytes_req: ~ 500-599 } hitcount:         32
     { bytes_req: ~ 600-699 } hitcount:         69
     { bytes_req: ~ 700-799 } hitcount:         37
     { bytes_req: ~ 1200-1299 } hitcount:         16
     { bytes_req: ~ 1400-1499 } hitcount:         30
     { bytes_req: ~ 2000-2099 } hitcount:          6
     { bytes_req: ~ 4000-4099 } hitcount:       2168
     { bytes_req: ~ 5000-5099 } hitcount:          6
    
     Totals:
         Hits: 7690
         Entries: 13
         Dropped: 0
    
    Link: https://lkml.kernel.org/r/20210707213921.980359719@goodmis.orgAcked-by: default avatarNamhyung Kim <namhyung@kernel.org>
    Reviewed-by: default avatarTom Zanussi <zanussi@kernel.org>
    Reviewed-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
    Tested-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
    de9a48a3
trace_events_hist.c 146 KB