From nobody Wed Feb 11 05:13:58 2026 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.74]) (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 3819220E6E5 for ; Mon, 3 Feb 2025 14:31:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738593075; cv=none; b=XFy5KvN78KYVcJF9vrgKXz63Jg/R//CNGDw5jOWzyQczFyr8e/5SVxxby35J0/p7Ax8LSdjjnb8a+D8G512jgJrCTNlICvGqByZ6VrGpukOJbCGb3f+nxfZVQgd/z6WLyZsm45otmyD3Cs8WmrQ9n9rlUJYKOsrcC9SsrwcoxKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738593075; c=relaxed/simple; bh=ouB9vCO60RBwHqR1z/Isx31uYGH0D3yEBxVjr4wx+9k=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=fTAKTJk4X5YQTukTzQ2/2j5MDAqsO8bpeQkya3Z3kybgVqZDIER5yqwKacfRRGFeLiJwXpHNEFGFXYmdesTz9laME7h0lrkZWwnfkgBzCuODbt4FZXUu2pPOLCEvpIYPOxNxyoNZTieQC5Vfd8xSg9QWwGdYhpeBCOLHAd4bOxo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dvyukov.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=AyHlIgo7; arc=none smtp.client-ip=209.85.218.74 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--dvyukov.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AyHlIgo7" Received: by mail-ej1-f74.google.com with SMTP id a640c23a62f3a-aaf8396f65fso483615666b.0 for ; Mon, 03 Feb 2025 06:31:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1738593072; x=1739197872; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=9MsIRX7DG9MGtj3A+aD4rpdCKFF6CVLblb/noWICajE=; b=AyHlIgo708f1lTU8p4+2a0UmmaGc770Kf04CJuMOGYPBtATqDhVwm260r6Madzgzwn tOfbNzbkHmQ7CpXkRzrlZ+4m0Ysam2lC5ucdQlFPcCPQ+Ik0UPp1mbVQRdzIsYICsndR p1DhiAoEcfQwCbN+m+SO7XhtmxFG1gM1qEsU0XQD+/tgnvihy6Jf5Lr5HWL+JU33/pRY q6Z6qC/wXGx8PObGj1pVx2hMzIKBWYWSu0VxBKM5hpXgt8m+6cvGeXGfVvmuEveN+79u e2cBIiStwFV9Q8rcK5A7S3HcA3waFNbwk16M/5AZzabRxKsxGoAbNJc8i3PrMKK2VUC7 RDvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738593072; x=1739197872; h=cc: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=9MsIRX7DG9MGtj3A+aD4rpdCKFF6CVLblb/noWICajE=; b=Xa8jQtt4PoPXL4qSyOLBfc/05pyeoa5dgDwaCsQJaZzfbg/pLP6NLHMHWyrO1iSnCv PVmlHi9L64z1EwQMEGF8NBVJ5Nsi1ZgJwPosCgCz3Zr/1U7Y69uamEHQJRNgT6qdzMoa dz73UoSyZK/bP0FI3ZI2fXCKtqUdhjXp1NjbRuRmeg8opg/7zmw63dagLkjXT+SEHL6p 8doH3PoAxZ87cYHUSvOcaFBseliIgLw7NOtI0fIGBgMPcpXHN9r3l///HottsXRce+4C NFXrSS7judpmoHDMiu/sWfkECu0f6Me165z4E+G0xDqLjq5C0UmI+5XiN6WoePYxaxvs X5rw== X-Forwarded-Encrypted: i=1; AJvYcCXqosLHy4d1DNi00I8Rt0IZOgZl9agvulaWerH5nLuthjbPIow6hqj4dPCnrPGMFLQHut7REIewSmdr9+8=@vger.kernel.org X-Gm-Message-State: AOJu0YxAx/bnsbciNh/++TOFg8+Hw98+E8XbUJcOqe9l71HYvEA+a3c/ CVwG3xbYB6+l/WBumeJ4Y4gNCfw8N4A3lNtUIQENG0KchYiaeG1eFVt+waQX8SQOXR0kt5YPFY3 GEU+cOA== X-Google-Smtp-Source: AGHT+IG9ymIMti540LEptQJHIhiHqLWmwE7t/pCnlvQQ/g0ph3CipPs2W4EGQRkWjQ8zw26VGwYMiMSCC96D X-Received: from ejcvg18.prod.google.com ([2002:a17:907:d312:b0:ab6:9b62:b39c]) (user=dvyukov job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:774b:b0:ab6:d5a6:e4c with SMTP id a640c23a62f3a-ab6d5a61059mr2121297466b.5.1738593071878; Mon, 03 Feb 2025 06:31:11 -0800 (PST) Date: Mon, 3 Feb 2025 15:30:37 +0100 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.48.1.362.g079036d154-goog Message-ID: Subject: [PATCH v3 2/8] perf report: Add parallelism sort key From: Dmitry Vyukov To: namhyung@kernel.org, irogers@google.com, acme@kernel.org Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Vyukov Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Show parallelism level in profiles if requested by user. Signed-off-by: Dmitry Vyukov Cc: Namhyung Kim Cc: Arnaldo Carvalho de Melo Cc: Ian Rogers Cc: linux-perf-users@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- tools/perf/builtin-report.c | 11 +++++++++++ tools/perf/util/hist.c | 2 ++ tools/perf/util/hist.h | 3 +++ tools/perf/util/session.c | 12 ++++++++++++ tools/perf/util/session.h | 1 + tools/perf/util/sort.c | 23 +++++++++++++++++++++++ tools/perf/util/sort.h | 1 + 7 files changed, 53 insertions(+) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 0d9bd090eda71..14d49f0625881 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -1720,6 +1720,17 @@ int cmd_report(int argc, const char **argv) symbol_conf.annotate_data_sample =3D true; } =20 + if (report.disable_order || !perf_session__has_switch_events(session)) { + if ((sort_order && strstr(sort_order, "parallelism")) || + (field_order && strstr(field_order, "parallelism"))) { + if (report.disable_order) + ui__error("Use of parallelism is incompatible with --disable-order.\n"= ); + else + ui__error("Use of parallelism requires --switch-events during record.\= n"); + return -1; + } + } + if (sort_order && strstr(sort_order, "ipc")) { parse_options_usage(report_usage, options, "s", 1); goto error; diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 0f30f843c566d..cafd693568189 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -207,6 +207,7 @@ void hists__calc_col_len(struct hists *hists, struct hi= st_entry *h) =20 hists__new_col_len(hists, HISTC_CGROUP, 6); hists__new_col_len(hists, HISTC_CGROUP_ID, 20); + hists__new_col_len(hists, HISTC_PARALLELISM, 11); hists__new_col_len(hists, HISTC_CPU, 3); hists__new_col_len(hists, HISTC_SOCKET, 6); hists__new_col_len(hists, HISTC_MEM_LOCKED, 6); @@ -741,6 +742,7 @@ __hists__add_entry(struct hists *hists, .ip =3D al->addr, .level =3D al->level, .code_page_size =3D sample->code_page_size, + .parallelism =3D al->parallelism, .stat =3D { .nr_events =3D 1, .period =3D sample->period, diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 46c8373e31465..a6e662d77dc24 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -42,6 +42,7 @@ enum hist_column { HISTC_CGROUP_ID, HISTC_CGROUP, HISTC_PARENT, + HISTC_PARALLELISM, HISTC_CPU, HISTC_SOCKET, HISTC_SRCLINE, @@ -228,6 +229,7 @@ struct hist_entry { u64 transaction; s32 socket; s32 cpu; + int parallelism; u64 code_page_size; u64 weight; u64 ins_lat; @@ -580,6 +582,7 @@ bool perf_hpp__is_thread_entry(struct perf_hpp_fmt *fmt= ); bool perf_hpp__is_comm_entry(struct perf_hpp_fmt *fmt); bool perf_hpp__is_dso_entry(struct perf_hpp_fmt *fmt); bool perf_hpp__is_sym_entry(struct perf_hpp_fmt *fmt); +bool perf_hpp__is_parallelism_entry(struct perf_hpp_fmt *fmt); =20 struct perf_hpp_fmt *perf_hpp_fmt__dup(struct perf_hpp_fmt *fmt); =20 diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index c06e3020a9769..00fcf8d8ac255 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -2403,6 +2403,18 @@ bool perf_session__has_traces(struct perf_session *s= ession, const char *msg) return false; } =20 +bool perf_session__has_switch_events(struct perf_session *session) +{ + struct evsel *evsel; + + evlist__for_each_entry(session->evlist, evsel) { + if (evsel->core.attr.context_switch) + return true; + } + + return false; +} + int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_na= me, u64 addr) { char *bracket; diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index bcf1bcf06959b..db1c120a9e67f 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h @@ -141,6 +141,7 @@ int perf_session__resolve_callchain(struct perf_session= *session, struct symbol **parent); =20 bool perf_session__has_traces(struct perf_session *session, const char *ms= g); +bool perf_session__has_switch_events(struct perf_session *session); =20 void perf_event__attr_swap(struct perf_event_attr *attr); =20 diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 3dd33721823f3..7eef43f5be360 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -892,6 +892,27 @@ struct sort_entry sort_cpu =3D { .se_width_idx =3D HISTC_CPU, }; =20 +/* --sort parallelism */ + +static int64_t +sort__parallelism_cmp(struct hist_entry *left, struct hist_entry *right) +{ + return right->parallelism - left->parallelism; +} + +static int hist_entry__parallelism_snprintf(struct hist_entry *he, char *b= f, + size_t size, unsigned int width) +{ + return repsep_snprintf(bf, size, "%*d", width, he->parallelism); +} + +struct sort_entry sort_parallelism =3D { + .se_header =3D "Parallelism", + .se_cmp =3D sort__parallelism_cmp, + .se_snprintf =3D hist_entry__parallelism_snprintf, + .se_width_idx =3D HISTC_PARALLELISM, +}; + /* --sort cgroup_id */ =20 static int64_t _sort__cgroup_dev_cmp(u64 left_dev, u64 right_dev) @@ -2534,6 +2555,7 @@ static struct sort_dimension common_sort_dimensions[]= =3D { DIM(SORT_ANNOTATE_DATA_TYPE_OFFSET, "typeoff", sort_type_offset), DIM(SORT_SYM_OFFSET, "symoff", sort_sym_offset), DIM(SORT_ANNOTATE_DATA_TYPE_CACHELINE, "typecln", sort_type_cacheline), + DIM(SORT_PARALLELISM, "parallelism", sort_parallelism), }; =20 #undef DIM @@ -2735,6 +2757,7 @@ MK_SORT_ENTRY_CHK(thread) MK_SORT_ENTRY_CHK(comm) MK_SORT_ENTRY_CHK(dso) MK_SORT_ENTRY_CHK(sym) +MK_SORT_ENTRY_CHK(parallelism) =20 =20 static bool __sort__hpp_equal(struct perf_hpp_fmt *a, struct perf_hpp_fmt = *b) diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index a8572574e1686..11fb15f914093 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -72,6 +72,7 @@ enum sort_type { SORT_ANNOTATE_DATA_TYPE_OFFSET, SORT_SYM_OFFSET, SORT_ANNOTATE_DATA_TYPE_CACHELINE, + SORT_PARALLELISM, =20 /* branch stack specific sort keys */ __SORT_BRANCH_STACK, --=20 2.48.1.362.g079036d154-goog