From nobody Sun Dec 14 19:26:22 2025 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3010F1632F2 for ; Wed, 21 May 2025 13:55:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747835714; cv=none; b=s9CcKSvfczl4Hx3Y5b78Rwxes1OOhRGONmdNgPbRaPMb7eVBIj7GDydGb4euhkNxz0U0tFLVv4VOlJ5eoPUyBCSVYf/pL0OB8fDSjvYy2vBcHXxTUW894nfZ0bMKg8ZYkLXohumnW7giKoNc1kBdtC/PEkgwbERs2QaVuBuFjOQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747835714; c=relaxed/simple; bh=fG2EQD4pWKzxvhn11dop3lFmr3qYuuLIJu17X/Z/8AY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=MRUNuooF7rMvqNOWqC2a9ltbODJpO3SsuuPemKPmR6vVLAsF+QkmveHoNCVVxfYg3pKSQQ3hnxXcQNq+7Bmpy3JLyBUddoxQ2aXZpAg/z8TcP8DtZJZp/RE6IfQwa+59qeT8tJzdm378I6q0qOqUothtY6F+b97+ne79jhMa9w4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=g/ewc31z; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="g/ewc31z" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e73194d7744so9562096276.0 for ; Wed, 21 May 2025 06:55:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1747835711; x=1748440511; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=atmK08ol3WW/ppnYVn9Uz3Hh/SB0GDdHA4mC+AOhirQ=; b=g/ewc31zXnOiEoymNnVsgrqW1vAUhDDszUO2SjX1u3+fBqakRpIBFn5ogtAol6B8F5 do7UHfjKRberrYjqpUsMmHhGqUWrDhxGEOkL/GWp5qX4JsWstbmtC4dUECIGyY9Ponlp 1gThxzRs8hUr6O8/ZuFny1u7ajnYSNS8zWjHn3KqIEi8GMMtJIrR0MFBeFPkgBmvLq3K rMcYra9X1UuWba4W3ULbqvaiJ4vBrq12V9MTC0XNEzgxq6/0Z07A48c3e5kumMKymDwm 2sUC+G2x9jZOCdY+dEnNf43G7tktww/EtcxRlKTCjQRiqODRSvJUfrcGkg6mOQ5er7oB T72g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747835711; x=1748440511; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=atmK08ol3WW/ppnYVn9Uz3Hh/SB0GDdHA4mC+AOhirQ=; b=VDH5TxGDRtt8gjKeU5g7JKc4+sytwEBqqKI1CWjCq9ZLG+8UxHPJ4Xmkh/Y0HcHboV 713D7rczRNzzmnmu1o4EyU1CLT1QL7BlIfboBKqIpxTTcVI8jEQ9JO8+EIag0UVYehhC 1YadK2nz+74hx2BKz2hpR7KEDMFll7VSWCdROWDFEl0OvOZvVfmb1A44lAhcD0xfzCSL bCCLNt4yEuc2tjaRW1cyrmjDDO7eGEkTZdZQw6Z/RHmCVgxJBf4zCbaxZytLp0hAlGbo 9L+tvctLterc3HistL8R/muLSZvxu8dlLcTg05v29P2ANjiOBv9dLwmYeyw7OxDX+U+Z twfQ== X-Forwarded-Encrypted: i=1; AJvYcCWuA6T4vNzXYpbcAz4m0tJLJjTkXO5uHe2rW0KLs8kT/29q+vZLwOeWdzsLT/L/lVMNJeQ+C5FH2KlkJKU=@vger.kernel.org X-Gm-Message-State: AOJu0Yz8rHgDbExVQOJJOPapU2kLuW13rTbTJxmiDGN+n12R5g+MIT3L /R+TlVWOP/elBMcQO6XAbc/vnanyup73w2AF+uwSFsAFrpQPliqreHn71bAdIMiy7wv9s2Pt+3N AuDha0DIpeQ== X-Google-Smtp-Source: AGHT+IGvXKaEfUBjfROjFc2BJrLoF70+H5fA22cCYPNw51sfb3lgLxzFduaZVUHFaIbgVLpJq+7ynPJM+DfL X-Received: from ybbdr5.prod.google.com ([2002:a05:6902:2405:b0:e7a:b53d:55e]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6902:2210:b0:e70:a83d:da74 with SMTP id 3f1490d57ef6-e7b6b157714mr27761773276.9.1747835711207; Wed, 21 May 2025 06:55:11 -0700 (PDT) Date: Wed, 21 May 2025 06:54:57 -0700 In-Reply-To: <20250521135500.677508-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250521135500.677508-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.1112.g889b7c5bd8-goog Message-ID: <20250521135500.677508-2-irogers@google.com> Subject: [PATCH v2 1/3] perf sample: Remove arch notion of sample parsing From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , "Masami Hiramatsu (Google)" , Ravi Bangoria , Leo Yan , Yujie Liu , Graham Woodward , Howard Chu , Weilin Wang , Dmitry Vyukov , Andi Kleen , Thomas Falcon , Matt Fleming , Chun-Tse Shao , Ben Gainey , Song Liu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" By definition arch sample parsing and synthesis will inhibit certain kinds of cross-platform record then analysis (report, script, etc.). Remove arch_perf_parse_sample_weight and arch_perf_synthesize_sample_weight replacing with a common implementation. Combine perf_sample p_stage_cyc and retire_lat to capture the differing uses regardless of compiled for architecture. Signed-off-by: Ian Rogers --- tools/perf/arch/powerpc/util/event.c | 26 --------------------- tools/perf/arch/x86/tests/sample-parsing.c | 4 ++-- tools/perf/arch/x86/util/event.c | 27 ---------------------- tools/perf/builtin-script.c | 2 +- tools/perf/util/dlfilter.c | 2 +- tools/perf/util/event.h | 2 -- tools/perf/util/evsel.c | 17 ++++++++++---- tools/perf/util/hist.c | 4 ++-- tools/perf/util/hist.h | 2 +- tools/perf/util/intel-tpebs.c | 4 ++-- tools/perf/util/sample.h | 5 +--- tools/perf/util/session.c | 2 +- tools/perf/util/sort.c | 6 ++--- tools/perf/util/synthetic-events.c | 10 ++++++-- 14 files changed, 34 insertions(+), 79 deletions(-) diff --git a/tools/perf/arch/powerpc/util/event.c b/tools/perf/arch/powerpc= /util/event.c index 77d8cc2b5691..024ac8b54c33 100644 --- a/tools/perf/arch/powerpc/util/event.c +++ b/tools/perf/arch/powerpc/util/event.c @@ -11,32 +11,6 @@ #include "../../../util/debug.h" #include "../../../util/sample.h" =20 -void arch_perf_parse_sample_weight(struct perf_sample *data, - const __u64 *array, u64 type) -{ - union perf_sample_weight weight; - - weight.full =3D *array; - if (type & PERF_SAMPLE_WEIGHT) - data->weight =3D weight.full; - else { - data->weight =3D weight.var1_dw; - data->ins_lat =3D weight.var2_w; - data->p_stage_cyc =3D weight.var3_w; - } -} - -void arch_perf_synthesize_sample_weight(const struct perf_sample *data, - __u64 *array, u64 type) -{ - *array =3D data->weight; - - if (type & PERF_SAMPLE_WEIGHT_STRUCT) { - *array &=3D 0xffffffff; - *array |=3D ((u64)data->ins_lat << 32); - } -} - const char *arch_perf_header_entry(const char *se_header) { if (!strcmp(se_header, "Local INSTR Latency")) diff --git a/tools/perf/arch/x86/tests/sample-parsing.c b/tools/perf/arch/x= 86/tests/sample-parsing.c index a061e8619267..95d8f7f1d2fb 100644 --- a/tools/perf/arch/x86/tests/sample-parsing.c +++ b/tools/perf/arch/x86/tests/sample-parsing.c @@ -29,7 +29,7 @@ static bool samples_same(const struct perf_sample *s1, { if (type & PERF_SAMPLE_WEIGHT_STRUCT) { COMP(ins_lat); - COMP(retire_lat); + COMP(p_stage_cyc_or_retire_lat); } =20 return true; @@ -50,7 +50,7 @@ static int do_test(u64 sample_type) struct perf_sample sample =3D { .weight =3D 101, .ins_lat =3D 102, - .retire_lat =3D 103, + .p_stage_cyc_or_retire_lat =3D 103, }; struct perf_sample sample_out; size_t i, sz, bufsz; diff --git a/tools/perf/arch/x86/util/event.c b/tools/perf/arch/x86/util/ev= ent.c index a0400707180c..576c1c36046c 100644 --- a/tools/perf/arch/x86/util/event.c +++ b/tools/perf/arch/x86/util/event.c @@ -92,33 +92,6 @@ int perf_event__synthesize_extra_kmaps(const struct perf= _tool *tool, =20 #endif =20 -void arch_perf_parse_sample_weight(struct perf_sample *data, - const __u64 *array, u64 type) -{ - union perf_sample_weight weight; - - weight.full =3D *array; - if (type & PERF_SAMPLE_WEIGHT) - data->weight =3D weight.full; - else { - data->weight =3D weight.var1_dw; - data->ins_lat =3D weight.var2_w; - data->retire_lat =3D weight.var3_w; - } -} - -void arch_perf_synthesize_sample_weight(const struct perf_sample *data, - __u64 *array, u64 type) -{ - *array =3D data->weight; - - if (type & PERF_SAMPLE_WEIGHT_STRUCT) { - *array &=3D 0xffffffff; - *array |=3D ((u64)data->ins_lat << 32); - *array |=3D ((u64)data->retire_lat << 48); - } -} - const char *arch_perf_header_entry(const char *se_header) { if (!strcmp(se_header, "Local Pipeline Stage Cycle")) diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 6c3bf74dd78c..c02c435e0f0b 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c @@ -2251,7 +2251,7 @@ static void process_event(struct perf_script *script, fprintf(fp, "%16" PRIu16, sample->ins_lat); =20 if (PRINT_FIELD(RETIRE_LAT)) - fprintf(fp, "%16" PRIu16, sample->retire_lat); + fprintf(fp, "%16" PRIu16, sample->p_stage_cyc_or_retire_lat); =20 if (PRINT_FIELD(CGROUP)) { const char *cgrp_name; diff --git a/tools/perf/util/dlfilter.c b/tools/perf/util/dlfilter.c index ddacef881af2..7e61ddfa66b8 100644 --- a/tools/perf/util/dlfilter.c +++ b/tools/perf/util/dlfilter.c @@ -526,7 +526,7 @@ int dlfilter__do_filter_event(struct dlfilter *d, ASSIGN(period); ASSIGN(weight); ASSIGN(ins_lat); - ASSIGN(p_stage_cyc); + d_sample.p_stage_cyc =3D sample->p_stage_cyc_or_retire_lat; ASSIGN(transaction); ASSIGN(insn_cnt); ASSIGN(cyc_cnt); diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 664bf39567ce..119bce37f4fd 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -390,8 +390,6 @@ extern unsigned int proc_map_timeout; #define PAGE_SIZE_NAME_LEN 32 char *get_page_size_name(u64 size, char *str); =20 -void arch_perf_parse_sample_weight(struct perf_sample *data, const __u64 *= array, u64 type); -void arch_perf_synthesize_sample_weight(const struct perf_sample *data, __= u64 *array, u64 type); const char *arch_perf_header_entry(const char *se_header); int arch_support_sort_key(const char *sort_key); =20 diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index d55482f094bf..097ab98bb81a 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -2846,11 +2846,18 @@ perf_event__check_size(union perf_event *event, uns= igned int sample_size) return 0; } =20 -void __weak arch_perf_parse_sample_weight(struct perf_sample *data, - const __u64 *array, - u64 type __maybe_unused) +static void perf_parse_sample_weight(struct perf_sample *data, const __u64= *array, u64 type) { - data->weight =3D *array; + union perf_sample_weight weight; + + weight.full =3D *array; + if (type & PERF_SAMPLE_WEIGHT) { + data->weight =3D weight.full; + } else { + data->weight =3D weight.var1_dw; + data->ins_lat =3D weight.var2_w; + data->p_stage_cyc_or_retire_lat =3D weight.var3_w; + } } =20 u64 evsel__bitfield_swap_branch_flags(u64 value) @@ -3236,7 +3243,7 @@ int evsel__parse_sample(struct evsel *evsel, union pe= rf_event *event, =20 if (type & PERF_SAMPLE_WEIGHT_TYPE) { OVERFLOW_CHECK_u64(array); - arch_perf_parse_sample_weight(data, array, type); + perf_parse_sample_weight(data, array, type); array++; } =20 diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index afc6855327ab..ae9803dca0b1 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -829,7 +829,7 @@ __hists__add_entry(struct hists *hists, .period =3D sample->period, .weight1 =3D sample->weight, .weight2 =3D sample->ins_lat, - .weight3 =3D sample->p_stage_cyc, + .weight3 =3D sample->p_stage_cyc_or_retire_lat, .latency =3D al->latency, }, .parent =3D sym_parent, @@ -846,7 +846,7 @@ __hists__add_entry(struct hists *hists, .time =3D hist_time(sample->time), .weight =3D sample->weight, .ins_lat =3D sample->ins_lat, - .p_stage_cyc =3D sample->p_stage_cyc, + .p_stage_cyc_or_retire_lat =3D sample->p_stage_cyc_or_retire_lat, .simd_flags =3D sample->simd_flags, }, *he =3D hists__findnew_entry(hists, &entry, al, sample_self); =20 diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index c64254088fc7..67033bdabcf4 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -255,7 +255,7 @@ struct hist_entry { u64 code_page_size; u64 weight; u64 ins_lat; - u64 p_stage_cyc; + u64 p_stage_cyc_or_retire_lat; s32 socket; s32 cpu; int parallelism; diff --git a/tools/perf/util/intel-tpebs.c b/tools/perf/util/intel-tpebs.c index 4ad4bc118ea5..ec2f3ecf1e1c 100644 --- a/tools/perf/util/intel-tpebs.c +++ b/tools/perf/util/intel-tpebs.c @@ -202,8 +202,8 @@ static int process_sample_event(const struct perf_tool = *tool __maybe_unused, * latency value will be used. Save the number of samples and the sum of * retire latency value for each event. */ - t->last =3D sample->retire_lat; - update_stats(&t->stats, sample->retire_lat); + t->last =3D sample->p_stage_cyc_or_retire_lat; + update_stats(&t->stats, sample->p_stage_cyc_or_retire_lat); mutex_unlock(tpebs_mtx_get()); return 0; } diff --git a/tools/perf/util/sample.h b/tools/perf/util/sample.h index 0e96240052e9..3330d18fb5fd 100644 --- a/tools/perf/util/sample.h +++ b/tools/perf/util/sample.h @@ -104,10 +104,7 @@ struct perf_sample { u8 cpumode; u16 misc; u16 ins_lat; - union { - u16 p_stage_cyc; - u16 retire_lat; - }; + u16 p_stage_cyc_or_retire_lat; bool no_hw_idx; /* No hw_idx collected in branch_stack */ char insn[MAX_INSN]; void *raw_data; diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index a320672c264e..451bc24ccfba 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -1094,7 +1094,7 @@ static void dump_sample(struct evsel *evsel, union pe= rf_event *event, printf("... weight: %" PRIu64 "", sample->weight); if (sample_type & PERF_SAMPLE_WEIGHT_STRUCT) { printf(",0x%"PRIx16"", sample->ins_lat); - printf(",0x%"PRIx16"", sample->p_stage_cyc); + printf(",0x%"PRIx16"", sample->p_stage_cyc_or_retire_lat); } printf("\n"); } diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 45e654653960..dda4ef0b5a73 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -1879,21 +1879,21 @@ struct sort_entry sort_global_ins_lat =3D { static int64_t sort__p_stage_cyc_cmp(struct hist_entry *left, struct hist_entry *right) { - return left->p_stage_cyc - right->p_stage_cyc; + return left->p_stage_cyc_or_retire_lat - right->p_stage_cyc_or_retire_lat; } =20 static int hist_entry__global_p_stage_cyc_snprintf(struct hist_entry *he, = char *bf, size_t size, unsigned int width) { return repsep_snprintf(bf, size, "%-*u", width, - he->p_stage_cyc * he->stat.nr_events); + he->p_stage_cyc_or_retire_lat * he->stat.nr_events); } =20 =20 static int hist_entry__p_stage_cyc_snprintf(struct hist_entry *he, char *b= f, size_t size, unsigned int width) { - return repsep_snprintf(bf, size, "%-*u", width, he->p_stage_cyc); + return repsep_snprintf(bf, size, "%-*u", width, he->p_stage_cyc_or_retire= _lat); } =20 struct sort_entry sort_local_p_stage_cyc =3D { diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic= -events.c index 2fc4d0537840..449a41900fc4 100644 --- a/tools/perf/util/synthetic-events.c +++ b/tools/perf/util/synthetic-events.c @@ -1567,10 +1567,16 @@ size_t perf_event__sample_event_size(const struct p= erf_sample *sample, u64 type, return result; } =20 -void __weak arch_perf_synthesize_sample_weight(const struct perf_sample *d= ata, +static void perf_synthesize_sample_weight(const struct perf_sample *data, __u64 *array, u64 type __maybe_unused) { *array =3D data->weight; + + if (type & PERF_SAMPLE_WEIGHT_STRUCT) { + *array &=3D 0xffffffff; + *array |=3D ((u64)data->ins_lat << 32); + *array |=3D ((u64)data->p_stage_cyc_or_retire_lat << 48); + } } =20 static __u64 *copy_read_group_values(__u64 *array, __u64 read_format, @@ -1730,7 +1736,7 @@ int perf_event__synthesize_sample(union perf_event *e= vent, u64 type, u64 read_fo } =20 if (type & PERF_SAMPLE_WEIGHT_TYPE) { - arch_perf_synthesize_sample_weight(sample, array, type); + perf_synthesize_sample_weight(sample, array, type); array++; } =20 --=20 2.49.0.1112.g889b7c5bd8-goog From nobody Sun Dec 14 19:26:22 2025 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D172E174EF0 for ; Wed, 21 May 2025 13:55:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747835715; cv=none; b=LnrkO04XEGkJx1jqKXFg/3w8BpdaO5ESkJDLyMTK89WcmEWRlfUAsF1LBi4kJuOaTYzbLXEafMYuJjgdruljwORaKYSgu8xOzJguuNrN0kAC9WnL65y+4aCGbVxgiZx/dejzsM1sZQ7mO0lh30Q8OQ4R+Y6uYf0z+UfXK1hnbJE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747835715; c=relaxed/simple; bh=SU/zhua3xa27X+58HP7pYg365af4hTGs/rxoiCSK+P4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=ZNyaqmePgYQhXbf7h8JH7NTL6EjEiNr4R5FEggwDwnbpV40/SNbV9hDbRB0gcc+6dryUWi/Va1WhdouDFmSHPTtZuxr2P4nX/+mc62jne0FjzRpBA9zFCjEoYBIW2Dil5rsl5eZhAcQHzvPk1vk2+qL5tWXpDDjMsIG3r2eqkrw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=yTkc7ui3; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="yTkc7ui3" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2321215e4c1so36483395ad.1 for ; Wed, 21 May 2025 06:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1747835713; x=1748440513; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=XLEd97eLycBLRrMYdGKv6zqrSBs+TaaO8Dx0WIFYaV8=; b=yTkc7ui3SAGo9wBRZXK/cUa6a5hpO6stV9M8M5dPtAhszVkVS2PF3HzWN68pozgQUJ jYqp6xNkQAfaWK/2WWRPicAsAAsDGGHQR4BJGfZAMqYzwsgWathBmw87FfenamAcy+Rj zXyWHX7DlBjIF1JJOOaJtlD3XxqW3CzAzaAsQgGQ8DVQsPDs85X9l6g6LL4UQivw2Srj rrw+KKoBj9uX9x1H7eX16r9Wi8aNNu83uUwSDh7Ul03PwAI8GSHfQIV/tOK5g55K2g7k qclJo8PtaV2JCejtkv/J7WuYaXSmcAn47IXoiYEiBs/BArMZU7JzKLM31OaFuXv8DTr/ B3/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747835713; x=1748440513; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XLEd97eLycBLRrMYdGKv6zqrSBs+TaaO8Dx0WIFYaV8=; b=MELiRTVSLwwN1/4hAGAdihqj9TA9sNyfFbI5BHIPvvtaLJGpsGFrUF3Rq1ayFwLcRd 3VjxYbNlx4SQHqBrgly31palS4iI8u6Q2Vz5/F9z7joAtCPHuYQ8gv0uvqngfp6Ci+Fq dCGA/OYrLUbNYO/hywlrBXMmROv5Z8oVqkA0LlaIo9YFoUKMzzzjWQwZAo2NbHjcBVsC wyN6u2deQOe+n5atZUMdD3ZyxQ8KcaWtamCTDLd5wBcnqxggrgGr+TRVItZ5zLNycUzi +W1+CJs/wS6XQQF7wyh/U0K+txo9KuDGMM1GrT5YJ+IHdqWUnAqZ1HiqtK3uKFRpm+vV cmPg== X-Forwarded-Encrypted: i=1; AJvYcCWW5IOHqoooDhnbyrmnYv1hXwMDAM14vPVDCo/HrsdWD9VaUoxpDKqXjh1z2MjFgGxElLEGa4wdjfhSLms=@vger.kernel.org X-Gm-Message-State: AOJu0YxllHOsSQXiBxxnqEDRcdUKHVtTmvx9nSXBv06do+QV7NMnrGpB pxw71BbcQ13381KV6aqHEZ8+up8S5namnG26Va3EHs8m+FmGmkL1/RT8Bi0aqXye98yvqQ2X5Fn ZoOZGI93EtQ== X-Google-Smtp-Source: AGHT+IHyOgWMJM+Jm7+23t/3ya1R1B3lcBDgerPSi7JUmcRzo+zuylvJ1yEn12ln2cGrprDi603H7/+XxJcr X-Received: from pljs15.prod.google.com ([2002:a17:903:3baf:b0:223:432c:56d4]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:1b2e:b0:21f:5063:d3ca with SMTP id d9443c01a7336-231b39ad033mr402535065ad.16.1747835713076; Wed, 21 May 2025 06:55:13 -0700 (PDT) Date: Wed, 21 May 2025 06:54:58 -0700 In-Reply-To: <20250521135500.677508-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250521135500.677508-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.1112.g889b7c5bd8-goog Message-ID: <20250521135500.677508-3-irogers@google.com> Subject: [PATCH v2 2/3] perf test: Move PERF_SAMPLE_WEIGHT_STRUCT parsing to common test From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , "Masami Hiramatsu (Google)" , Ravi Bangoria , Leo Yan , Yujie Liu , Graham Woodward , Howard Chu , Weilin Wang , Dmitry Vyukov , Andi Kleen , Thomas Falcon , Matt Fleming , Chun-Tse Shao , Ben Gainey , Song Liu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" test__x86_sample_parsing is identical to test__sample_parsing except it explicitly tested PERF_SAMPLE_WEIGHT_STRUCT. Now the parsing code is common move the PERF_SAMPLE_WEIGHT_STRUCT to the common sample parsing test and remove the x86 version. Signed-off-by: Ian Rogers --- tools/perf/arch/x86/include/arch-tests.h | 1 - tools/perf/arch/x86/tests/Build | 1 - tools/perf/arch/x86/tests/arch-tests.c | 2 - tools/perf/arch/x86/tests/sample-parsing.c | 125 --------------------- tools/perf/tests/sample-parsing.c | 14 +++ 5 files changed, 14 insertions(+), 129 deletions(-) delete mode 100644 tools/perf/arch/x86/tests/sample-parsing.c diff --git a/tools/perf/arch/x86/include/arch-tests.h b/tools/perf/arch/x86= /include/arch-tests.h index 4fd425157d7d..957934417b26 100644 --- a/tools/perf/arch/x86/include/arch-tests.h +++ b/tools/perf/arch/x86/include/arch-tests.h @@ -12,7 +12,6 @@ int test__insn_x86(struct test_suite *test, int subtest); int test__intel_pt_pkt_decoder(struct test_suite *test, int subtest); int test__intel_pt_hybrid_compat(struct test_suite *test, int subtest); int test__bp_modify(struct test_suite *test, int subtest); -int test__x86_sample_parsing(struct test_suite *test, int subtest); int test__amd_ibs_via_core_pmu(struct test_suite *test, int subtest); int test__amd_ibs_period(struct test_suite *test, int subtest); int test__hybrid(struct test_suite *test, int subtest); diff --git a/tools/perf/arch/x86/tests/Build b/tools/perf/arch/x86/tests/Bu= ild index 5e00cbfd2d56..4c27b85b960a 100644 --- a/tools/perf/arch/x86/tests/Build +++ b/tools/perf/arch/x86/tests/Build @@ -2,7 +2,6 @@ perf-test-$(CONFIG_DWARF_UNWIND) +=3D regs_load.o perf-test-$(CONFIG_DWARF_UNWIND) +=3D dwarf-unwind.o =20 perf-test-y +=3D arch-tests.o -perf-test-y +=3D sample-parsing.o perf-test-y +=3D hybrid.o perf-test-$(CONFIG_AUXTRACE) +=3D intel-pt-test.o ifeq ($(CONFIG_EXTRA_TESTS),y) diff --git a/tools/perf/arch/x86/tests/arch-tests.c b/tools/perf/arch/x86/t= ests/arch-tests.c index bfee2432515b..1023c83684ce 100644 --- a/tools/perf/arch/x86/tests/arch-tests.c +++ b/tools/perf/arch/x86/tests/arch-tests.c @@ -23,7 +23,6 @@ struct test_suite suite__intel_pt =3D { #if defined(__x86_64__) DEFINE_SUITE("x86 bp modify", bp_modify); #endif -DEFINE_SUITE("x86 Sample parsing", x86_sample_parsing); DEFINE_SUITE("AMD IBS via core pmu", amd_ibs_via_core_pmu); DEFINE_SUITE_EXCLUSIVE("AMD IBS sample period", amd_ibs_period); static struct test_case hybrid_tests[] =3D { @@ -49,7 +48,6 @@ struct test_suite *arch_tests[] =3D { #if defined(__x86_64__) &suite__bp_modify, #endif - &suite__x86_sample_parsing, &suite__amd_ibs_via_core_pmu, &suite__amd_ibs_period, &suite__hybrid, diff --git a/tools/perf/arch/x86/tests/sample-parsing.c b/tools/perf/arch/x= 86/tests/sample-parsing.c deleted file mode 100644 index 95d8f7f1d2fb..000000000000 --- a/tools/perf/arch/x86/tests/sample-parsing.c +++ /dev/null @@ -1,125 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -#include -#include -#include -#include -#include -#include -#include - -#include "event.h" -#include "evsel.h" -#include "debug.h" -#include "util/sample.h" -#include "util/synthetic-events.h" - -#include "tests/tests.h" -#include "arch-tests.h" - -#define COMP(m) do { \ - if (s1->m !=3D s2->m) { \ - pr_debug("Samples differ at '"#m"'\n"); \ - return false; \ - } \ -} while (0) - -static bool samples_same(const struct perf_sample *s1, - const struct perf_sample *s2, - u64 type) -{ - if (type & PERF_SAMPLE_WEIGHT_STRUCT) { - COMP(ins_lat); - COMP(p_stage_cyc_or_retire_lat); - } - - return true; -} - -static int do_test(u64 sample_type) -{ - struct evsel evsel =3D { - .needs_swap =3D false, - .core =3D { - . attr =3D { - .sample_type =3D sample_type, - .read_format =3D 0, - }, - }, - }; - union perf_event *event; - struct perf_sample sample =3D { - .weight =3D 101, - .ins_lat =3D 102, - .p_stage_cyc_or_retire_lat =3D 103, - }; - struct perf_sample sample_out; - size_t i, sz, bufsz; - int err, ret =3D -1; - - sz =3D perf_event__sample_event_size(&sample, sample_type, 0); - bufsz =3D sz + 4096; /* Add a bit for overrun checking */ - event =3D malloc(bufsz); - if (!event) { - pr_debug("malloc failed\n"); - return -1; - } - - memset(event, 0xff, bufsz); - event->header.type =3D PERF_RECORD_SAMPLE; - event->header.misc =3D 0; - event->header.size =3D sz; - - err =3D perf_event__synthesize_sample(event, sample_type, 0, &sample); - if (err) { - pr_debug("%s failed for sample_type %#"PRIx64", error %d\n", - "perf_event__synthesize_sample", sample_type, err); - goto out_free; - } - - /* The data does not contain 0xff so we use that to check the size */ - for (i =3D bufsz; i > 0; i--) { - if (*(i - 1 + (u8 *)event) !=3D 0xff) - break; - } - if (i !=3D sz) { - pr_debug("Event size mismatch: actual %zu vs expected %zu\n", - i, sz); - goto out_free; - } - - evsel.sample_size =3D __evsel__sample_size(sample_type); - - err =3D evsel__parse_sample(&evsel, event, &sample_out); - if (err) { - pr_debug("%s failed for sample_type %#"PRIx64", error %d\n", - "evsel__parse_sample", sample_type, err); - goto out_free; - } - - if (!samples_same(&sample, &sample_out, sample_type)) { - pr_debug("parsing failed for sample_type %#"PRIx64"\n", - sample_type); - goto out_free; - } - - ret =3D 0; -out_free: - free(event); - - return ret; -} - -/** - * test__x86_sample_parsing - test X86 specific sample parsing - * - * This function implements a test that synthesizes a sample event, parses= it - * and then checks that the parsed sample matches the original sample. If = the - * test passes %0 is returned, otherwise %-1 is returned. - * - * For now, the PERF_SAMPLE_WEIGHT_STRUCT is the only X86 specific sample = type. - * The test only checks the PERF_SAMPLE_WEIGHT_STRUCT type. - */ -int test__x86_sample_parsing(struct test_suite *test __maybe_unused, int s= ubtest __maybe_unused) -{ - return do_test(PERF_SAMPLE_WEIGHT_STRUCT); -} diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-pa= rsing.c index 72411580f869..ad57e34bda19 100644 --- a/tools/perf/tests/sample-parsing.c +++ b/tools/perf/tests/sample-parsing.c @@ -152,6 +152,12 @@ static bool samples_same(struct perf_sample *s1, if (type & PERF_SAMPLE_WEIGHT) COMP(weight); =20 + if (type & PERF_SAMPLE_WEIGHT_STRUCT) { + COMP(weight); + COMP(ins_lat); + COMP(p_stage_cyc_or_retire_lat); + } + if (type & PERF_SAMPLE_DATA_SRC) COMP(data_src); =20 @@ -269,6 +275,8 @@ static int do_test(u64 sample_type, u64 sample_regs, u6= 4 read_format) .cgroup =3D 114, .data_page_size =3D 115, .code_page_size =3D 116, + .ins_lat =3D 117, + .p_stage_cyc_or_retire_lat =3D 118, .aux_sample =3D { .size =3D sizeof(aux_data), .data =3D (void *)aux_data, @@ -439,6 +447,12 @@ static int test__sample_parsing(struct test_suite *tes= t __maybe_unused, int subt if (err) return err; } + sample_type =3D (PERF_SAMPLE_MAX - 1) & ~PERF_SAMPLE_WEIGHT_STRUCT; + for (i =3D 0; i < ARRAY_SIZE(rf); i++) { + err =3D do_test(sample_type, sample_regs, rf[i]); + if (err) + return err; + } =20 return 0; } --=20 2.49.0.1112.g889b7c5bd8-goog From nobody Sun Dec 14 19:26:22 2025 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A17F185955 for ; Wed, 21 May 2025 13:55:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747835719; cv=none; b=f02UAtBbx6iB/9wUFDl5CVcckJ/iLEoWyyqGO8qWiQWceZU6/CK2Iv3Hd+BsMZ7uoTAvjdCdL5kYHr3knMwPQk96kdgWmemRRUJXGwylTf4pUfbR4Cm5kLdRjv8WwjAeqsf2deLf+jnw8DZ+rzvLrzu85pxeIfjocHd4crME5UU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747835719; c=relaxed/simple; bh=gK+Mucf2kShnVMtfsmBrEQ45z0/hHVq5z9DoLv/zTLA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=gR6HB0iQ0vEGuOxVNx01hr3YUqCpzAm698Uh4dEBR3C8N8n/F89j/ipYfSa5aMeEiBKg92vgxmvSeg0O5ccgeNaIHnorVg4jxm+1DzYc0VirUIOEuwSrLXmUcErDD3kGHMh7F7zU+YSCd1jL6C9eDt86BRo7cqrWu/f8wDyoIr4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=EIC8ZISD; arc=none smtp.client-ip=209.85.215.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="EIC8ZISD" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-b26e0fee541so4103848a12.1 for ; Wed, 21 May 2025 06:55:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1747835715; x=1748440515; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=4gJnMxpsaSjZ+6o2NjI2WYwxrpxXBL9KkCJLzhye5/Y=; b=EIC8ZISDmKJEMQqGGLDc1ZwAqfFB8ssfDs3kCtYwGDHOVT30W0u3OLvOhluamQWEt2 HqrCojd9uV4tOTCYxzCwSG59/hmMkdDsYscK4ZyZ6sMHo2GAT6dyGtpnZFdOzGm3M5Zo 94aEA7eZsTt/GsgkoqX3aGBSxSC61zG0Yt+Gvrpy4gDApWb40S5EGnNuhcX5LGKclDX1 og3R/Am47cVR7+F0vOR6fc/n95w01YYivGzci9NpuZb/ODjfYe62m/y8SoOvzDfocgGG yp7z2iJY7z2n1Ol7Ssga7LEZmz99xGgYpdZ6OJNKVvDk6YSS+zalec2yixH99mrCU5MO Fq6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747835715; x=1748440515; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4gJnMxpsaSjZ+6o2NjI2WYwxrpxXBL9KkCJLzhye5/Y=; b=Hfem4J+jqQnacVazi/BNoL0thV2ofDO8l1AGn7bhAcEjIAlPixPSmAES2Vl15wcQwh oyGBsBGMFytMjprxpKajYrLI2/gcaeX6Xa07Pfv8jvKiS13c3hG572GE6pTErKUvhOZ3 721JXdYNRKp70+AZJiHO+6K1MXTAx+RExVaik0eQbvyudHC6vOwPZJ7xb1vjEGGcg+oZ z4gtIOxbl3vPkS+pbcXVV60nWUey7evBx6OMu4OmiD/2oMmz5p+d4iuo1B1awvzu8EF0 4aDDoyhuHyevKguRjfnr7S8S8relYid3pe0cicb4x6RiKmNjyfaQn5D8UgsRl9fIqk2f cjQw== X-Forwarded-Encrypted: i=1; AJvYcCUvPlD+bC7CZWY0zeDZn8+BnrBggwlZwbeCj+4Btt8PUp2BmX1BwaRhLtyztTwQX18N3vjRYRQJ79XoMzY=@vger.kernel.org X-Gm-Message-State: AOJu0YyEkeGL2XsRSAuca9AXzkz5qduWNUQFlF9pYZRSNZ47OVeQHHsn Lw9PoD/oBzTvBatQIkmRAI/YVUJaf6xu7mZqzISeoDEl++MGtrWnUevGRD1MZr0oGnCznL8Rw9L wXWFmyQXX8w== X-Google-Smtp-Source: AGHT+IFsNV3VnDLiZv68yufB0BHS9WdrqTfHLJS7SbQMobAYHU8sm3sW0MRqidRuI+W2TpgzKYYTBI/XPoSI X-Received: from pgbfm14.prod.google.com ([2002:a05:6a02:498e:b0:af9:bc01:4df8]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:6a28:b0:201:4061:bd94 with SMTP id adf61e73a8af0-2170ccaf4e4mr27821889637.19.1747835715275; Wed, 21 May 2025 06:55:15 -0700 (PDT) Date: Wed, 21 May 2025 06:54:59 -0700 In-Reply-To: <20250521135500.677508-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250521135500.677508-1-irogers@google.com> X-Mailer: git-send-email 2.49.0.1112.g889b7c5bd8-goog Message-ID: <20250521135500.677508-4-irogers@google.com> Subject: [PATCH v2 3/3] perf sort: Use perf_env to set arch sort keys and header From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , "Masami Hiramatsu (Google)" , Ravi Bangoria , Leo Yan , Yujie Liu , Graham Woodward , Howard Chu , Weilin Wang , Dmitry Vyukov , Andi Kleen , Thomas Falcon , Matt Fleming , Chun-Tse Shao , Ben Gainey , Song Liu , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Previously arch_support_sort_key and arch_perf_header_entry used a weak symbol to compile as appropriate for x86 and powerpc. A limitation to this is that the handling of a data file could vary in cross-platform development. Change to using the perf_env of the current session to determine the architecture kind and set the sort key and header entries as appropriate. Signed-off-by: Ian Rogers --- tools/perf/arch/powerpc/util/Build | 1 - tools/perf/arch/powerpc/util/event.c | 34 ---------------- tools/perf/arch/x86/util/event.c | 19 --------- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-c2c.c | 53 +++++++++++++----------- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-top.c | 16 ++++---- tools/perf/tests/hists_cumulate.c | 8 ++-- tools/perf/tests/hists_filter.c | 8 ++-- tools/perf/tests/hists_link.c | 8 ++-- tools/perf/tests/hists_output.c | 10 ++--- tools/perf/util/event.h | 3 -- tools/perf/util/sort.c | 61 ++++++++++++++++++++-------- tools/perf/util/sort.h | 5 ++- 15 files changed, 104 insertions(+), 128 deletions(-) delete mode 100644 tools/perf/arch/powerpc/util/event.c diff --git a/tools/perf/arch/powerpc/util/Build b/tools/perf/arch/powerpc/u= til/Build index ed82715080f9..fdd6a77a3432 100644 --- a/tools/perf/arch/powerpc/util/Build +++ b/tools/perf/arch/powerpc/util/Build @@ -5,7 +5,6 @@ perf-util-y +=3D mem-events.o perf-util-y +=3D pmu.o perf-util-y +=3D sym-handling.o perf-util-y +=3D evsel.o -perf-util-y +=3D event.o =20 perf-util-$(CONFIG_LIBDW) +=3D skip-callchain-idx.o =20 diff --git a/tools/perf/arch/powerpc/util/event.c b/tools/perf/arch/powerpc= /util/event.c deleted file mode 100644 index 024ac8b54c33..000000000000 --- a/tools/perf/arch/powerpc/util/event.c +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include -#include - -#include "../../../util/event.h" -#include "../../../util/synthetic-events.h" -#include "../../../util/machine.h" -#include "../../../util/tool.h" -#include "../../../util/map.h" -#include "../../../util/debug.h" -#include "../../../util/sample.h" - -const char *arch_perf_header_entry(const char *se_header) -{ - if (!strcmp(se_header, "Local INSTR Latency")) - return "Finish Cyc"; - else if (!strcmp(se_header, "INSTR Latency")) - return "Global Finish_cyc"; - else if (!strcmp(se_header, "Local Pipeline Stage Cycle")) - return "Dispatch Cyc"; - else if (!strcmp(se_header, "Pipeline Stage Cycle")) - return "Global Dispatch_cyc"; - return se_header; -} - -int arch_support_sort_key(const char *sort_key) -{ - if (!strcmp(sort_key, "p_stage_cyc")) - return 1; - if (!strcmp(sort_key, "local_p_stage_cyc")) - return 1; - return 0; -} diff --git a/tools/perf/arch/x86/util/event.c b/tools/perf/arch/x86/util/ev= ent.c index 576c1c36046c..3cd384317739 100644 --- a/tools/perf/arch/x86/util/event.c +++ b/tools/perf/arch/x86/util/event.c @@ -91,22 +91,3 @@ int perf_event__synthesize_extra_kmaps(const struct perf= _tool *tool, } =20 #endif - -const char *arch_perf_header_entry(const char *se_header) -{ - if (!strcmp(se_header, "Local Pipeline Stage Cycle")) - return "Local Retire Latency"; - else if (!strcmp(se_header, "Pipeline Stage Cycle")) - return "Retire Latency"; - - return se_header; -} - -int arch_support_sort_key(const char *sort_key) -{ - if (!strcmp(sort_key, "p_stage_cyc")) - return 1; - if (!strcmp(sort_key, "local_p_stage_cyc")) - return 1; - return 0; -} diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 9833c2c82a2f..a2d41614ef5e 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -947,7 +947,7 @@ int cmd_annotate(int argc, const char **argv) annotate_opts.show_br_cntr =3D true; } =20 - if (setup_sorting(NULL) < 0) + if (setup_sorting(/*evlist=3D*/NULL, &annotate.session->header.env) < 0) usage_with_options(annotate_usage, options); =20 ret =3D __cmd_annotate(&annotate); diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index e2e257bcc461..324368aabfa2 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -195,12 +195,14 @@ static struct hist_entry_ops c2c_entry_ops =3D { =20 static int c2c_hists__init(struct c2c_hists *hists, const char *sort, - int nr_header_lines); + int nr_header_lines, + struct perf_env *env); =20 static struct c2c_hists* he__get_c2c_hists(struct hist_entry *he, const char *sort, - int nr_header_lines) + int nr_header_lines, + struct perf_env *env) { struct c2c_hist_entry *c2c_he; struct c2c_hists *hists; @@ -214,7 +216,7 @@ he__get_c2c_hists(struct hist_entry *he, if (!hists) return NULL; =20 - ret =3D c2c_hists__init(hists, sort, nr_header_lines); + ret =3D c2c_hists__init(hists, sort, nr_header_lines, env); if (ret) { free(hists); return NULL; @@ -350,7 +352,7 @@ static int process_sample_event(const struct perf_tool = *tool __maybe_unused, =20 mi =3D mi_dup; =20 - c2c_hists =3D he__get_c2c_hists(he, c2c.cl_sort, 2); + c2c_hists =3D he__get_c2c_hists(he, c2c.cl_sort, 2, machine->env); if (!c2c_hists) goto free_mi; =20 @@ -1966,7 +1968,8 @@ static struct c2c_fmt *get_format(const char *name) return c2c_fmt; } =20 -static int c2c_hists__init_output(struct perf_hpp_list *hpp_list, char *na= me) +static int c2c_hists__init_output(struct perf_hpp_list *hpp_list, char *na= me, + struct perf_env *env __maybe_unused) { struct c2c_fmt *c2c_fmt =3D get_format(name); int level =3D 0; @@ -1980,14 +1983,14 @@ static int c2c_hists__init_output(struct perf_hpp_l= ist *hpp_list, char *name) return 0; } =20 -static int c2c_hists__init_sort(struct perf_hpp_list *hpp_list, char *name) +static int c2c_hists__init_sort(struct perf_hpp_list *hpp_list, char *name= , struct perf_env *env) { struct c2c_fmt *c2c_fmt =3D get_format(name); struct c2c_dimension *dim; =20 if (!c2c_fmt) { reset_dimensions(); - return sort_dimension__add(hpp_list, name, NULL, 0); + return sort_dimension__add(hpp_list, name, /*evlist=3D*/NULL, env, /*lev= el=3D*/0); } =20 dim =3D c2c_fmt->dim; @@ -2008,7 +2011,7 @@ static int c2c_hists__init_sort(struct perf_hpp_list = *hpp_list, char *name) \ for (tok =3D strtok_r((char *)_list, ", ", &tmp); \ tok; tok =3D strtok_r(NULL, ", ", &tmp)) { \ - ret =3D _fn(hpp_list, tok); \ + ret =3D _fn(hpp_list, tok, env); \ if (ret =3D=3D -EINVAL) { \ pr_err("Invalid --fields key: `%s'", tok); \ break; \ @@ -2021,7 +2024,8 @@ static int c2c_hists__init_sort(struct perf_hpp_list = *hpp_list, char *name) =20 static int hpp_list__parse(struct perf_hpp_list *hpp_list, const char *output_, - const char *sort_) + const char *sort_, + struct perf_env *env) { char *output =3D output_ ? strdup(output_) : NULL; char *sort =3D sort_ ? strdup(sort_) : NULL; @@ -2052,7 +2056,8 @@ static int hpp_list__parse(struct perf_hpp_list *hpp_= list, =20 static int c2c_hists__init(struct c2c_hists *hists, const char *sort, - int nr_header_lines) + int nr_header_lines, + struct perf_env *env) { __hists__init(&hists->hists, &hists->list); =20 @@ -2066,15 +2071,16 @@ static int c2c_hists__init(struct c2c_hists *hists, /* Overload number of header lines.*/ hists->list.nr_header_lines =3D nr_header_lines; =20 - return hpp_list__parse(&hists->list, NULL, sort); + return hpp_list__parse(&hists->list, /*output=3D*/NULL, sort, env); } =20 static int c2c_hists__reinit(struct c2c_hists *c2c_hists, const char *output, - const char *sort) + const char *sort, + struct perf_env *env) { perf_hpp__reset_output_field(&c2c_hists->list); - return hpp_list__parse(&c2c_hists->list, output, sort); + return hpp_list__parse(&c2c_hists->list, output, sort, env); } =20 #define DISPLAY_LINE_LIMIT 0.001 @@ -2207,8 +2213,9 @@ static int filter_cb(struct hist_entry *he, void *arg= __maybe_unused) return 0; } =20 -static int resort_cl_cb(struct hist_entry *he, void *arg __maybe_unused) +static int resort_cl_cb(struct hist_entry *he, void *arg) { + struct perf_env *env =3D arg; struct c2c_hist_entry *c2c_he; struct c2c_hists *c2c_hists; bool display =3D he__display(he, &c2c.shared_clines_stats); @@ -2222,7 +2229,7 @@ static int resort_cl_cb(struct hist_entry *he, void *= arg __maybe_unused) c2c_he->cacheline_idx =3D idx++; calc_width(c2c_he); =20 - c2c_hists__reinit(c2c_hists, c2c.cl_output, c2c.cl_resort); + c2c_hists__reinit(c2c_hists, c2c.cl_output, c2c.cl_resort, env); =20 hists__collapse_resort(&c2c_hists->hists, NULL); hists__output_resort_cb(&c2c_hists->hists, NULL, filter_cb); @@ -2333,7 +2340,7 @@ static int resort_shared_cl_cb(struct hist_entry *he,= void *arg __maybe_unused) return 0; } =20 -static int hists__iterate_cb(struct hists *hists, hists__resort_cb_t cb) +static int hists__iterate_cb(struct hists *hists, hists__resort_cb_t cb, v= oid *arg) { struct rb_node *next =3D rb_first_cached(&hists->entries); int ret =3D 0; @@ -2342,7 +2349,7 @@ static int hists__iterate_cb(struct hists *hists, his= ts__resort_cb_t cb) struct hist_entry *he; =20 he =3D rb_entry(next, struct hist_entry, rb_node); - ret =3D cb(he, NULL); + ret =3D cb(he, arg); if (ret) break; next =3D rb_next(&he->rb_node); @@ -2448,7 +2455,7 @@ static void print_cacheline(struct c2c_hists *c2c_his= ts, hists__fprintf(&c2c_hists->hists, false, 0, 0, 0, out, false); } =20 -static void print_pareto(FILE *out) +static void print_pareto(FILE *out, struct perf_env *env) { struct perf_hpp_list hpp_list; struct rb_node *nd; @@ -2473,7 +2480,7 @@ static void print_pareto(FILE *out) "dcacheline"; =20 perf_hpp_list__init(&hpp_list); - ret =3D hpp_list__parse(&hpp_list, cl_output, NULL); + ret =3D hpp_list__parse(&hpp_list, cl_output, /*evlist=3D*/NULL, env); =20 if (WARN_ONCE(ret, "failed to setup sort entries\n")) return; @@ -2538,7 +2545,7 @@ static void perf_c2c__hists_fprintf(FILE *out, struct= perf_session *session) fprintf(out, "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D\n"); fprintf(out, "#\n"); =20 - print_pareto(out); + print_pareto(out, &session->header.env); } =20 #ifdef HAVE_SLANG_SUPPORT @@ -3095,7 +3102,7 @@ static int perf_c2c__report(int argc, const char **ar= gv) goto out_session; } =20 - err =3D c2c_hists__init(&c2c.hists, "dcacheline", 2); + err =3D c2c_hists__init(&c2c.hists, "dcacheline", 2, &session->header.env= ); if (err) { pr_debug("Failed to initialize hists\n"); goto out_session; @@ -3179,13 +3186,13 @@ static int perf_c2c__report(int argc, const char **= argv) else if (c2c.display =3D=3D DISPLAY_SNP_PEER) sort_str =3D "tot_peer"; =20 - c2c_hists__reinit(&c2c.hists, output_str, sort_str); + c2c_hists__reinit(&c2c.hists, output_str, sort_str, &session->header.env); =20 ui_progress__init(&prog, c2c.hists.hists.nr_entries, "Sorting..."); =20 hists__collapse_resort(&c2c.hists.hists, NULL); hists__output_resort_cb(&c2c.hists.hists, &prog, resort_shared_cl_cb); - hists__iterate_cb(&c2c.hists.hists, resort_cl_cb); + hists__iterate_cb(&c2c.hists.hists, resort_cl_cb, &session->header.env); =20 ui_progress__finish(); =20 diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index ae490d58af92..f6735cf02329 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -2003,7 +2003,7 @@ int cmd_diff(int argc, const char **argv) sort__mode =3D SORT_MODE__DIFF; } =20 - if (setup_sorting(NULL) < 0) + if (setup_sorting(/*evlist=3D*/NULL, &data__files[0].session->header.env)= < 0) usage_with_options(diff_usage, options); =20 setup_pager(); diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index f0299c7ee025..8be6e7c3bd22 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -1776,7 +1776,7 @@ int cmd_report(int argc, const char **argv) } =20 if ((last_key !=3D K_SWITCH_INPUT_DATA && last_key !=3D K_RELOAD) && - (setup_sorting(session->evlist) < 0)) { + (setup_sorting(session->evlist, &session->header.env) < 0)) { if (sort_order) parse_options_usage(report_usage, options, "s", 1); if (field_order) diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 7b6cde87d2af..13ef0d188a96 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c @@ -1747,7 +1747,14 @@ int cmd_top(int argc, const char **argv) =20 setup_browser(false); =20 - if (setup_sorting(top.evlist) < 0) { + top.session =3D perf_session__new(/*data=3D*/NULL, /*tool=3D*/NULL); + if (IS_ERR(top.session)) { + status =3D PTR_ERR(top.session); + top.session =3D NULL; + goto out_delete_evlist; + } + + if (setup_sorting(top.evlist, &top.session->header.env) < 0) { if (sort_order) parse_options_usage(top_usage, options, "s", 1); if (field_order) @@ -1820,13 +1827,6 @@ int cmd_top(int argc, const char **argv) signal(SIGWINCH, winch_sig); } =20 - top.session =3D perf_session__new(NULL, NULL); - if (IS_ERR(top.session)) { - status =3D PTR_ERR(top.session); - top.session =3D NULL; - goto out_delete_evlist; - } - if (!evlist__needs_bpf_sb_event(top.evlist)) top.record_opts.no_bpf_event =3D true; =20 diff --git a/tools/perf/tests/hists_cumulate.c b/tools/perf/tests/hists_cum= ulate.c index 1e0f5a310fd5..3eb9ef8d7ec6 100644 --- a/tools/perf/tests/hists_cumulate.c +++ b/tools/perf/tests/hists_cumulate.c @@ -295,7 +295,7 @@ static int test1(struct evsel *evsel, struct machine *m= achine) symbol_conf.cumulate_callchain =3D false; evsel__reset_sample_bit(evsel, CALLCHAIN); =20 - setup_sorting(NULL); + setup_sorting(/*evlist=3D*/NULL, machine->env); callchain_register_param(&callchain_param); =20 err =3D add_hist_entries(hists, machine); @@ -442,7 +442,7 @@ static int test2(struct evsel *evsel, struct machine *m= achine) symbol_conf.cumulate_callchain =3D false; evsel__set_sample_bit(evsel, CALLCHAIN); =20 - setup_sorting(NULL); + setup_sorting(/*evlist=3D*/NULL, machine->env); callchain_register_param(&callchain_param); =20 err =3D add_hist_entries(hists, machine); @@ -500,7 +500,7 @@ static int test3(struct evsel *evsel, struct machine *m= achine) symbol_conf.cumulate_callchain =3D true; evsel__reset_sample_bit(evsel, CALLCHAIN); =20 - setup_sorting(NULL); + setup_sorting(/*evlist=3D*/NULL, machine->env); callchain_register_param(&callchain_param); =20 err =3D add_hist_entries(hists, machine); @@ -684,7 +684,7 @@ static int test4(struct evsel *evsel, struct machine *m= achine) symbol_conf.cumulate_callchain =3D true; evsel__set_sample_bit(evsel, CALLCHAIN); =20 - setup_sorting(NULL); + setup_sorting(/*evlist=3D*/NULL, machine->env); =20 callchain_param =3D callchain_param_default; callchain_register_param(&callchain_param); diff --git a/tools/perf/tests/hists_filter.c b/tools/perf/tests/hists_filte= r.c index 4b2e4f2fbe48..1cebd20cc91c 100644 --- a/tools/perf/tests/hists_filter.c +++ b/tools/perf/tests/hists_filter.c @@ -131,10 +131,6 @@ static int test__hists_filter(struct test_suite *test = __maybe_unused, int subtes goto out; err =3D TEST_FAIL; =20 - /* default sort order (comm,dso,sym) will be used */ - if (setup_sorting(NULL) < 0) - goto out; - machines__init(&machines); =20 /* setup threads/dso/map/symbols also */ @@ -145,6 +141,10 @@ static int test__hists_filter(struct test_suite *test = __maybe_unused, int subtes if (verbose > 1) machine__fprintf(machine, stderr); =20 + /* default sort order (comm,dso,sym) will be used */ + if (setup_sorting(evlist, machine->env) < 0) + goto out; + /* process sample events */ err =3D add_hist_entries(evlist, machine); if (err < 0) diff --git a/tools/perf/tests/hists_link.c b/tools/perf/tests/hists_link.c index 5b6f1e883466..996f5f0b3bd1 100644 --- a/tools/perf/tests/hists_link.c +++ b/tools/perf/tests/hists_link.c @@ -303,10 +303,6 @@ static int test__hists_link(struct test_suite *test __= maybe_unused, int subtest goto out; =20 err =3D TEST_FAIL; - /* default sort order (comm,dso,sym) will be used */ - if (setup_sorting(NULL) < 0) - goto out; - machines__init(&machines); =20 /* setup threads/dso/map/symbols also */ @@ -317,6 +313,10 @@ static int test__hists_link(struct test_suite *test __= maybe_unused, int subtest if (verbose > 1) machine__fprintf(machine, stderr); =20 + /* default sort order (comm,dso,sym) will be used */ + if (setup_sorting(evlist, machine->env) < 0) + goto out; + /* process sample events */ err =3D add_hist_entries(evlist, machine); if (err < 0) diff --git a/tools/perf/tests/hists_output.c b/tools/perf/tests/hists_outpu= t.c index 33b5cc8352a7..ee5ec8bda60e 100644 --- a/tools/perf/tests/hists_output.c +++ b/tools/perf/tests/hists_output.c @@ -146,7 +146,7 @@ static int test1(struct evsel *evsel, struct machine *m= achine) field_order =3D NULL; sort_order =3D NULL; /* equivalent to sort_order =3D "comm,dso,sym" */ =20 - setup_sorting(NULL); + setup_sorting(/*evlist=3D*/NULL, machine->env); =20 /* * expected output: @@ -248,7 +248,7 @@ static int test2(struct evsel *evsel, struct machine *m= achine) field_order =3D "overhead,cpu"; sort_order =3D "pid"; =20 - setup_sorting(NULL); + setup_sorting(/*evlist=3D*/NULL, machine->env); =20 /* * expected output: @@ -304,7 +304,7 @@ static int test3(struct evsel *evsel, struct machine *m= achine) field_order =3D "comm,overhead,dso"; sort_order =3D NULL; =20 - setup_sorting(NULL); + setup_sorting(/*evlist=3D*/NULL, machine->env); =20 /* * expected output: @@ -378,7 +378,7 @@ static int test4(struct evsel *evsel, struct machine *m= achine) field_order =3D "dso,sym,comm,overhead,dso"; sort_order =3D "sym"; =20 - setup_sorting(NULL); + setup_sorting(/*evlist=3D*/NULL, machine->env); =20 /* * expected output: @@ -480,7 +480,7 @@ static int test5(struct evsel *evsel, struct machine *m= achine) field_order =3D "cpu,pid,comm,dso,sym"; sort_order =3D "dso,pid"; =20 - setup_sorting(NULL); + setup_sorting(/*evlist=3D*/NULL, machine->env); =20 /* * expected output: diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 119bce37f4fd..3b97a31736c5 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -390,9 +390,6 @@ extern unsigned int proc_map_timeout; #define PAGE_SIZE_NAME_LEN 32 char *get_page_size_name(u64 size, char *str); =20 -const char *arch_perf_header_entry(const char *se_header); -int arch_support_sort_key(const char *sort_key); - static inline bool perf_event_header__cpumode_is_guest(u8 cpumode) { return cpumode =3D=3D PERF_RECORD_MISC_GUEST_KERNEL || diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index dda4ef0b5a73..ccab10cd24a5 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -2526,19 +2526,44 @@ struct sort_dimension { int taken; }; =20 -int __weak arch_support_sort_key(const char *sort_key __maybe_unused) +static int arch_support_sort_key(const char *sort_key, struct perf_env *en= v) { + const char *arch =3D perf_env__arch(env); + + if (!strcmp("x86", arch) || !strcmp("powerpc", arch)) { + if (!strcmp(sort_key, "p_stage_cyc")) + return 1; + if (!strcmp(sort_key, "local_p_stage_cyc")) + return 1; + } return 0; } =20 -const char * __weak arch_perf_header_entry(const char *se_header) -{ +static const char *arch_perf_header_entry(const char *se_header, struct pe= rf_env *env) +{ + const char *arch =3D perf_env__arch(env); + + if (!strcmp("x86", arch)) { + if (!strcmp(se_header, "Local Pipeline Stage Cycle")) + return "Local Retire Latency"; + else if (!strcmp(se_header, "Pipeline Stage Cycle")) + return "Retire Latency"; + } else if (!strcmp("powerpc", arch)) { + if (!strcmp(se_header, "Local INSTR Latency")) + return "Finish Cyc"; + else if (!strcmp(se_header, "INSTR Latency")) + return "Global Finish_cyc"; + else if (!strcmp(se_header, "Local Pipeline Stage Cycle")) + return "Dispatch Cyc"; + else if (!strcmp(se_header, "Pipeline Stage Cycle")) + return "Global Dispatch_cyc"; + } return se_header; } =20 -static void sort_dimension_add_dynamic_header(struct sort_dimension *sd) +static void sort_dimension_add_dynamic_header(struct sort_dimension *sd, s= truct perf_env *env) { - sd->entry->se_header =3D arch_perf_header_entry(sd->entry->se_header); + sd->entry->se_header =3D arch_perf_header_entry(sd->entry->se_header, env= ); } =20 #define DIM(d, n, func) [d] =3D { .name =3D n, .entry =3D &(func) } @@ -3590,7 +3615,7 @@ int hpp_dimension__add_output(unsigned col, bool impl= icit) } =20 int sort_dimension__add(struct perf_hpp_list *list, const char *tok, - struct evlist *evlist, + struct evlist *evlist, struct perf_env *env, int level) { unsigned int i, j; @@ -3603,7 +3628,7 @@ int sort_dimension__add(struct perf_hpp_list *list, c= onst char *tok, */ for (j =3D 0; j < ARRAY_SIZE(arch_specific_sort_keys); j++) { if (!strcmp(arch_specific_sort_keys[j], tok) && - !arch_support_sort_key(tok)) { + !arch_support_sort_key(tok, env)) { return 0; } } @@ -3616,7 +3641,7 @@ int sort_dimension__add(struct perf_hpp_list *list, c= onst char *tok, =20 for (j =3D 0; j < ARRAY_SIZE(dynamic_headers); j++) { if (sd->name && !strcmp(dynamic_headers[j], sd->name)) - sort_dimension_add_dynamic_header(sd); + sort_dimension_add_dynamic_header(sd, env); } =20 if (sd->entry =3D=3D &sort_parent && parent_pattern) { @@ -3712,13 +3737,13 @@ int sort_dimension__add(struct perf_hpp_list *list,= const char *tok, } =20 /* This should match with sort_dimension__add() above */ -static bool is_hpp_sort_key(const char *key) +static bool is_hpp_sort_key(const char *key, struct perf_env *env) { unsigned i; =20 for (i =3D 0; i < ARRAY_SIZE(arch_specific_sort_keys); i++) { if (!strcmp(arch_specific_sort_keys[i], key) && - !arch_support_sort_key(key)) { + !arch_support_sort_key(key, env)) { return false; } } @@ -3740,7 +3765,7 @@ static bool is_hpp_sort_key(const char *key) } =20 static int setup_sort_list(struct perf_hpp_list *list, char *str, - struct evlist *evlist) + struct evlist *evlist, struct perf_env *env) { char *tmp, *tok; int ret =3D 0; @@ -3769,7 +3794,7 @@ static int setup_sort_list(struct perf_hpp_list *list= , char *str, } =20 if (*tok) { - if (is_hpp_sort_key(tok)) { + if (is_hpp_sort_key(tok, env)) { /* keep output (hpp) sort keys in the same level */ if (prev_was_hpp) { bool next_same =3D (level =3D=3D next_level); @@ -3782,7 +3807,7 @@ static int setup_sort_list(struct perf_hpp_list *list= , char *str, prev_was_hpp =3D false; } =20 - ret =3D sort_dimension__add(list, tok, evlist, level); + ret =3D sort_dimension__add(list, tok, evlist, env, level); if (ret =3D=3D -EINVAL) { if (!cacheline_size() && !strncasecmp(tok, "dcacheline", strlen(tok))) ui__error("The \"dcacheline\" --sort key needs to know the cacheline = size and it couldn't be determined on this system"); @@ -3911,7 +3936,7 @@ static char *setup_overhead(char *keys) return keys; } =20 -static int __setup_sorting(struct evlist *evlist) +static int __setup_sorting(struct evlist *evlist, struct perf_env *env) { char *str; const char *sort_keys; @@ -3951,7 +3976,7 @@ static int __setup_sorting(struct evlist *evlist) } } =20 - ret =3D setup_sort_list(&perf_hpp_list, str, evlist); + ret =3D setup_sort_list(&perf_hpp_list, str, evlist, env); =20 free(str); return ret; @@ -4187,16 +4212,16 @@ static int __setup_output_field(void) return ret; } =20 -int setup_sorting(struct evlist *evlist) +int setup_sorting(struct evlist *evlist, struct perf_env *env) { int err; =20 - err =3D __setup_sorting(evlist); + err =3D __setup_sorting(evlist, env); if (err < 0) return err; =20 if (parent_pattern !=3D default_parent_pattern) { - err =3D sort_dimension__add(&perf_hpp_list, "parent", evlist, -1); + err =3D sort_dimension__add(&perf_hpp_list, "parent", evlist, env, -1); if (err < 0) return err; } diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index a742ab7f3c67..d7787958e06b 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -6,6 +6,7 @@ #include "hist.h" =20 struct option; +struct perf_env; =20 extern regex_t parent_regex; extern const char *sort_order; @@ -130,7 +131,7 @@ extern struct sort_entry sort_thread; =20 struct evlist; struct tep_handle; -int setup_sorting(struct evlist *evlist); +int setup_sorting(struct evlist *evlist, struct perf_env *env); int setup_output_field(void); void reset_output_field(void); void sort__setup_elide(FILE *fp); @@ -145,7 +146,7 @@ bool is_strict_order(const char *order); int hpp_dimension__add_output(unsigned col, bool implicit); void reset_dimensions(void); int sort_dimension__add(struct perf_hpp_list *list, const char *tok, - struct evlist *evlist, + struct evlist *evlist, struct perf_env *env, int level); int output_field_add(struct perf_hpp_list *list, const char *tok, int *lev= el); int64_t --=20 2.49.0.1112.g889b7c5bd8-goog