Skip to content
  • Daniel Wagner's avatar
    bpf: BPF based latency tracing · 0fb1170e
    Daniel Wagner authored
    BPF offers another way to generate latency histograms. We attach
    kprobes at trace_preempt_off and trace_preempt_on and calculate the
    time it takes to from seeing the off/on transition.
    
    The first array is used to store the start time stamp. The key is the
    CPU id. The second array stores the log2(time diff). We need to use
    static allocation here (array and not hash tables). The kprobes
    hooking into trace_preempt_on|off should not calling any dynamic
    memory allocation or free path. We need to avoid recursivly
    getting called. Besides that, it reduces jitter in the measurement.
    
    CPU 0
          latency        : count     distribution
           1 -> 1        : 0        |                                        |
           2 -> 3        : 0        |                                        |
           4 -> 7        : 0        |                                        |
           8 -> 15       : 0        |                                        |
          16 -> 31       : 0        |                      ...
    0fb1170e