This is a note to let you know that I've just added the patch titled perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support to the 5.14-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: perf-script-fix-perf_sample_weight_struct-support.patch and it can be found in the queue-5.14 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 79b2f616e7ab9197da947467a23d9cd04b54803f Author: Kan Liang <kan.liang@xxxxxxxxxxxxxxx> Date: Wed Sep 29 08:38:13 2021 -0700 perf script: Fix PERF_SAMPLE_WEIGHT_STRUCT support [ Upstream commit 27730c8cd60d1574d8337276e7a9d7d2ca92e0d1 ] -F weight in perf script is broken. # ./perf mem record # ./perf script -F weight Samples for 'dummy:HG' event do not have WEIGHT attribute set. Cannot print 'weight' field. The sample type, PERF_SAMPLE_WEIGHT_STRUCT, is an alternative of the PERF_SAMPLE_WEIGHT sample type. They share the same space, weight. The lower 32 bits are exactly the same for both sample type. The higher 32 bits may be different for different architecture. For a new kernel on x86, the PERF_SAMPLE_WEIGHT_STRUCT is used. For an old kernel or other ARCHs, the PERF_SAMPLE_WEIGHT is used. With -F weight, current perf script will only check the input string "weight" with the PERF_SAMPLE_WEIGHT sample type. Because the commit ea8d0ed6eae3 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT") didn't update the PERF_SAMPLE_WEIGHT_STRUCT sample type for perf script. For a new kernel on x86, the check fails. Use PERF_SAMPLE_WEIGHT_TYPE, which supports both sample types, to replace PERF_SAMPLE_WEIGHT Fixes: ea8d0ed6eae37b01 ("perf tools: Support PERF_SAMPLE_WEIGHT_STRUCT") Reported-by: Joe Mario <jmario@xxxxxxxxxx> Reviewed-by: Kajol Jain <kjain@xxxxxxxxxxxxx> Signed-off-by: Kan Liang <kan.liang@xxxxxxxxxxxxxxx> Tested-by: Jiri Olsa <jolsa@xxxxxxxxxx> Tested-by: Joe Mario <jmario@xxxxxxxxxx> Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx> Acked-by: Joe Mario <jmario@xxxxxxxxxx> Cc: Andi Kleen <ak@xxxxxxxxxxxxxxx> Link: https://lore.kernel.org/r/1632929894-102778-1-git-send-email-kan.liang@xxxxxxxxxxxxxxx Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 064da7f3618d..52ff827ca799 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -469,7 +469,7 @@ static int evsel__check_attr(struct evsel *evsel, struct perf_session *session) return -EINVAL; if (PRINT_FIELD(WEIGHT) && - evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT, "WEIGHT", PERF_OUTPUT_WEIGHT)) + evsel__check_stype(evsel, PERF_SAMPLE_WEIGHT_TYPE, "WEIGHT", PERF_OUTPUT_WEIGHT)) return -EINVAL; if (PRINT_FIELD(SYM) &&