• Ian Rogers's avatar
    perf expr: Allow a double if expression · 4b65fc7b
    Ian Rogers authored
    
    
    Some TMA metrics have double if expressions like:
    
      ( CPU_CLK_UNHALTED.THREAD / 2 ) * ( 1 + CPU_CLK_UNHALTED.ONE_THREAD_ACTIVE / CPU_CLK_UNHALTED.REF_XCLK ) ) if #core_wide < 1 else ( CPU_CLK_UNHALTED.THREAD_ANY / 2 ) if #SMT_on else CPU_CLK_UNHALTED.THREAD
    
    This currently fails to parse as the left hand side if expression needs
    to be in parentheses. By allowing the if expression to have a right hand
    side that is an if expression we can parse the expression above, with
    left to right evaluation order that matches languages like Python.
    Signed-off-by: default avatarIan Rogers <irogers@google.com>
    Cc: Ahmad Yasin <ahmad.yasin@intel.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Andi Kleen <ak@linux.intel.com>
    Cc: Caleb Biggers <caleb.biggers@intel.com>
    Cc: Florian Fischer <florian.fischer@muhq.space>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: James Clark <james.clark@arm.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: John Garry <john.garry@huawei.com>
    Cc: Kajol Jain <kjain@linux.ibm.com>
    Cc: Kan Liang <kan.liang@linux.intel.com>
    Cc: Kshipra Bopardikar <kshipra.bopardikar@intel.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Miaoqian Lin <linmq006@gmail.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Perry Taylor <perry.taylor@intel.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Samantha Alt <samantha.alt@intel.com>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Thomas Richter <tmricht@linux.ibm.com>
    Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
    Link: https://lore.kernel.org/r/20221004021612.325521-2-irogers@google.com
    
    Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    4b65fc7b
expr.c 7.33 KB