Skip to content
Snippets Groups Projects
  • Steven Rostedt (VMware)'s avatar
    2c05caa7
    tracing / histogram: Give calculation hist_fields a size · 2c05caa7
    Steven Rostedt (VMware) authored
    When working on my user space applications, I found a bug in the synthetic
    event code where the automated synthetic event field was not matching the
    event field calculation it was attached to. Looking deeper into it, it was
    because the calculation hist_field was not given a size.
    
    The synthetic event fields are matched to their hist_fields either by
    having the field have an identical string type, or if that does not match,
    then the size and signed values are used to match the fields.
    
    The problem arose when I tried to match a calculation where the fields
    were "unsigned int". My tool created a synthetic event of type "u32". But
    it failed to match. The string was:
    
      diff=field1-field2:onmatch(event).trace(synth,$diff)
    
    Adding debugging into the kernel, I found that the size of "diff" was 0.
    And since it was given "unsigned int" as a type, the histogram fallback
    code used size and signed. The signed matched, but the size of u32 (4) did
    not match zero, and the event failed to be created.
    
    This can be worse if the field you want to match is not one of the
    acceptable fields for a synthetic event. As event fields can have any type
    that is supported in Linux, this can cause an issue. For example, if a
    type is an enum. Then there's no way to use that with any calculations.
    
    Have the calculation field simply take on the size of what it is
    calculating.
    
    Link: https://lkml.kernel.org/r/20210730171951.59c7743f@oasis.local.home
    
    
    
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: stable@vger.kernel.org
    Fixes: 100719dc ("tracing: Add simple expression support to hist triggers")
    Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
    2c05caa7
    History
    tracing / histogram: Give calculation hist_fields a size
    Steven Rostedt (VMware) authored
    When working on my user space applications, I found a bug in the synthetic
    event code where the automated synthetic event field was not matching the
    event field calculation it was attached to. Looking deeper into it, it was
    because the calculation hist_field was not given a size.
    
    The synthetic event fields are matched to their hist_fields either by
    having the field have an identical string type, or if that does not match,
    then the size and signed values are used to match the fields.
    
    The problem arose when I tried to match a calculation where the fields
    were "unsigned int". My tool created a synthetic event of type "u32". But
    it failed to match. The string was:
    
      diff=field1-field2:onmatch(event).trace(synth,$diff)
    
    Adding debugging into the kernel, I found that the size of "diff" was 0.
    And since it was given "unsigned int" as a type, the histogram fallback
    code used size and signed. The signed matched, but the size of u32 (4) did
    not match zero, and the event failed to be created.
    
    This can be worse if the field you want to match is not one of the
    acceptable fields for a synthetic event. As event fields can have any type
    that is supported in Linux, this can cause an issue. For example, if a
    type is an enum. Then there's no way to use that with any calculations.
    
    Have the calculation field simply take on the size of what it is
    calculating.
    
    Link: https://lkml.kernel.org/r/20210730171951.59c7743f@oasis.local.home
    
    
    
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: stable@vger.kernel.org
    Fixes: 100719dc ("tracing: Add simple expression support to hist triggers")
    Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>