Commit a7e0adb3 authored by Kim Phillips's avatar Kim Phillips Committed by PvsNarasimha
Browse files

perf evsel: Make evsel__env() always return a valid env

mainline inclusion
from mainline-v5.18-rc1
commit 7b830875
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IAU6ZD

Reference: https://github.com/torvalds/linux/commit/7b830875d22d68f9a49a02a23c24272513ddb392



--------------------------------

commit 7b830875 upstream

It's possible to have an evsel and evsel->evlist populated without
an evsel->evlist->env, when, e.g., cmd_record is in its error path.

Future patches will add support for evsel__open_strerror to be able
to customize error messaging based on perf_env__{arch,cpuid}, so
let's have evsel__env return &perf_env instead of NULL in that case.

Reviewed-by: default avatarKajol Jain <kjain@linux.ibm.com>
Signed-off-by: default avatarKim Phillips <kim.phillips@amd.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Joao Martins <joao.m.martins@oracle.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Robert Richter <robert.richter@amd.com>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20211004214114.188477-1-kim.phillips@amd.com


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarPvsNarasimha <PVS.NarasimhaRao@amd.com>
parent 3d6078b4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2760,7 +2760,7 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target,

struct perf_env *evsel__env(struct evsel *evsel)
{
	if (evsel && evsel->evlist)
	if (evsel && evsel->evlist && evsel->evlist->env)
		return evsel->evlist->env;
	return &perf_env;
}