From nobody Thu Jan 30 19:14:12 2025 Received: from mail-ed1-f74.google.com (mail-ed1-f74.google.com [209.85.208.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 00FD41FCFC0 for ; Mon, 27 Jan 2025 09:59:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737971959; cv=none; b=Mss3I7+1S5aYT1Pmu6t0Sbo6dOWxJJ8cmrfrppf2XR9W4tzj3S6XgQ4P2RHJWEaCU7vVhjNdv4BSOrXAzWK+FPY8vLCnJHWn0q6mdagSEYlAysN9IJpwf7gkkP0tFjKr04Fe/t5BknOJwjW4ET/BzTB9nJOj/7tv0e0k4EglQXs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737971959; c=relaxed/simple; bh=7Lwmz2qowc+FL2S348X3fs0ddxo5HZNQI1A8WhNfwmM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=B7Ig0KmhplWAWTU1y8GM26OAaNl6FaZpyPu17UZS4CuHGsL16mSgRDLVqFqnPp0dCVTzmfbVZkXoK1pPdAlszuWJxs5nfe0msNZjiPfOeBWE8w79x3bKbyQ/ssj728mg3o7xHztSmQ3CNLUmGc9FE8dtKS+yOqLM0klDKt7ghs0= 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=23D0DEL1; arc=none smtp.client-ip=209.85.208.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="23D0DEL1" Received: by mail-ed1-f74.google.com with SMTP id 4fb4d7f45d1cf-5da0b47115aso4080816a12.1 for ; Mon, 27 Jan 2025 01:59:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1737971956; x=1738576756; 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=wY6YjR33QYUTFA2QpzMQp9zL626GKLB+VcfcqXYl4og=; b=23D0DEL18KYt5Yqv75lVQiJyWNLsTiuhFGSinubLbFBwh4SiMTzHVAmAPRJp1FJKCD 946xU1laTwVZwJAXPdo8qTOugy2JCgRmcWcJUH5oX9pZNKmY1wV1Nq93plpNDCPzTQBW GJby9XqUhIVL9jqK28P8IgtkpsIPoerdoTxZz2/p2RWcm4yCeC43fAXfeodqsWOvLOMt eg5KK+O9owY4hpl2SYlIvd4W6SmP5KPlBgJJSRJXtdRXLFvngxiZI9qJIt9reBkq200H s4/oRAY4is4jkKkx/GbnSCo9/w4/rFNHmIvsB888S9vtUqs6FyvLumIxB2oBbrlar17H A28A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737971956; x=1738576756; 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=wY6YjR33QYUTFA2QpzMQp9zL626GKLB+VcfcqXYl4og=; b=ZctJcs+Jlt1SYNUAZ5vrPFb1/kKVL3kX5aCFIjrCl1to0AYpsRz+8D2f8jcpawRAsT bBHSUXvvYyc+FuSL8RHQR6dzAJHbXVjmjoVvOI6kErbugatW6o/7H01Onjwjf8i1rd4p VC22C83Zj9qNOhBee4cwl59hjO2JMCynUBgv73yfvJc+yATrrjVMO00y5+SwNKjAaxt8 5FrgnJlfCnMOjRZA6GF6RLABbN3Vz8jF4RMDPWqPAhXy1mbKrSfDHyslh/DxM5XucgQY AcJHm+RH4klRtvS2sRgDGCorYM/2QEgaFIdBMfBMuoSwvXakEvAZHQ0RsoetK3p31S1D NwiA== X-Forwarded-Encrypted: i=1; AJvYcCVMy9RJAR1Hu3Hjlo1IPDLd3r/Qic0nup/qH6ZBbGdHBTEDjkaJypeEAqXvqpteiEwc02sTPPXu8HYGhG0=@vger.kernel.org X-Gm-Message-State: AOJu0YwamWxarlYqGo5U0qpgiwGCfNMFCWThbfIRh50gHmPiN2OeG76J 2NQzXVAnWlcFSSj5yG5fJEcgk7ni1rWGzTf65ul/tuSg4FqjbnGecZPKFBzn022O4mIEVKuNfgy 8UAqAEw== X-Google-Smtp-Source: AGHT+IHWR5KT444/HwyTkeF8oEknrLW504GPADqAKXMZXiZu/CWtg9MudjXP4L1rx2P21ydNd5cATZPXKLPB X-Received: from edap3.prod.google.com ([2002:a05:6402:5003:b0:5dc:37ed:79fc]) (user=dvyukov job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:26c6:b0:5dc:545:40a7 with SMTP id 4fb4d7f45d1cf-5dc05454350mr17309711a12.12.1737971956452; Mon, 27 Jan 2025 01:59:16 -0800 (PST) Date: Mon, 27 Jan 2025 10:58:48 +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.262.g85cc9f2d1e-goog Message-ID: <35860043ef3c4a25d36211853c3f2a6f83cd74b7.1737971364.git.dvyukov@google.com> Subject: [PATCH v3 1/7] perf report: Add machine parallelism From: Dmitry Vyukov To: namhyung@kernel.org, irogers@google.com Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Vyukov , Arnaldo Carvalho de Melo Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add calculation of the current parallelism level (number of threads actively running on CPUs). The parallelism level can be shown in reports on its own, and to calculate latency overheads. 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 | 1 + tools/perf/util/addr_location.c | 1 + tools/perf/util/addr_location.h | 2 ++ tools/perf/util/event.c | 3 +++ tools/perf/util/machine.c | 7 +++++++ tools/perf/util/machine.h | 6 ++++++ 6 files changed, 20 insertions(+) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index f5fbd670d619a..0d9bd090eda71 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -1568,6 +1568,7 @@ int cmd_report(int argc, const char **argv) report.tool.cgroup =3D perf_event__process_cgroup; report.tool.exit =3D perf_event__process_exit; report.tool.fork =3D perf_event__process_fork; + report.tool.context_switch =3D perf_event__process_switch; report.tool.lost =3D perf_event__process_lost; report.tool.read =3D process_read_event; report.tool.attr =3D process_attr; diff --git a/tools/perf/util/addr_location.c b/tools/perf/util/addr_locatio= n.c index 51825ef8c0ab7..007a2f5df9a6a 100644 --- a/tools/perf/util/addr_location.c +++ b/tools/perf/util/addr_location.c @@ -17,6 +17,7 @@ void addr_location__init(struct addr_location *al) al->cpumode =3D 0; al->cpu =3D 0; al->socket =3D 0; + al->parallelism =3D 1; } =20 /* diff --git a/tools/perf/util/addr_location.h b/tools/perf/util/addr_locatio= n.h index d8ac0428dff23..36aaa45445f24 100644 --- a/tools/perf/util/addr_location.h +++ b/tools/perf/util/addr_location.h @@ -21,6 +21,8 @@ struct addr_location { u8 cpumode; s32 cpu; s32 socket; + /* Same as machine.parallelism but within [1, nr_cpus]. */ + int parallelism; }; =20 void addr_location__init(struct addr_location *al); diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index aac96d5d19170..3d3ac58e1c660 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -767,6 +767,9 @@ int machine__resolve(struct machine *machine, struct ad= dr_location *al, al->socket =3D env->cpu[al->cpu].socket_id; } =20 + /* Account for possible out-of-order switch events. */ + al->parallelism =3D min(max(machine->parallelism, 1), machine__nr_cpus_av= ail(machine)); + if (al->map) { if (symbol_conf.dso_list && (!dso || !(strlist__has_entry(symbol_conf.dso_list, diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 2d51badfbf2e2..0e65c5377f983 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -94,6 +94,8 @@ int machine__init(struct machine *machine, const char *ro= ot_dir, pid_t pid) machine->comm_exec =3D false; machine->kernel_start =3D 0; machine->vmlinux_map =3D NULL; + /* There is no initial context switch in, so we start at 1. */ + machine->parallelism =3D 1; =20 machine->root_dir =3D strdup(root_dir); if (machine->root_dir =3D=3D NULL) @@ -677,8 +679,11 @@ int machine__process_aux_output_hw_id_event(struct mac= hine *machine __maybe_unus int machine__process_switch_event(struct machine *machine __maybe_unused, union perf_event *event) { + bool out =3D event->header.misc & PERF_RECORD_MISC_SWITCH_OUT; + if (dump_trace) perf_event__fprintf_switch(event, stdout); + machine->parallelism +=3D out ? -1 : 1; return 0; } =20 @@ -1900,6 +1905,8 @@ int machine__process_exit_event(struct machine *machi= ne, union perf_event *event if (dump_trace) perf_event__fprintf_task(event, stdout); =20 + /* There is no context switch out before exit, so we decrement here. */ + machine->parallelism--; if (thread !=3D NULL) { if (symbol_conf.keep_exited_threads) thread__set_exited(thread, /*exited=3D*/true); diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index 2e5a4cb342d82..a5f28652873ce 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h @@ -50,6 +50,12 @@ struct machine { u64 text_start; u64 text_end; } sched, lock, traceiter, trace; + /* + * The current parallelism level (number of threads that run on CPUs). + * This value can be less than 1, or larger than the total number + * of CPUs, if events are poorly ordered. + */ + int parallelism; pid_t *current_tid; size_t current_tid_sz; union { /* Tool specific area */ --=20 2.48.1.262.g85cc9f2d1e-goog From nobody Thu Jan 30 19:14:12 2025 Received: from mail-ed1-f73.google.com (mail-ed1-f73.google.com [209.85.208.73]) (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 45DAC1FDA86 for ; Mon, 27 Jan 2025 09:59:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737971962; cv=none; b=Ud9JrL6byedzCrQ1nnncKHUY8YynSXUByzZrfn0UbB5tWo3Ukppw60SIfLpe374iIkWJPwYUXnJqdaeJov563g6I6VL8y5gDOEH7bGnrScKrA88LEbbSiTB0eV34pEcKl9rG0xGqeL7b17GeM6H0L/Vrb5ehoCadpAhfbbt8hZc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737971962; c=relaxed/simple; bh=cNclnO68vswCkh+84xPCh9o2+/2+lsK7sgZCyii1PpI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=l+E2BmIXtNS9r8HN7YsZwIRthglQEH5x99ol69aYoiosQTbv0oKJMSe4nLwvfk7cyUBJRaX7F09M46oS2aOsa0f9u29NEV7rqa05ttZLTh2FwFAsXkj7zWYIfUMBY9YSMWwy7A8j/5AmUpEz1lil5v+pw+/gm4y2Y8DpXcVi7gg= 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=YZWRN+S9; arc=none smtp.client-ip=209.85.208.73 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="YZWRN+S9" Received: by mail-ed1-f73.google.com with SMTP id 4fb4d7f45d1cf-5d3fe75a9f0so3817110a12.3 for ; Mon, 27 Jan 2025 01:59:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1737971959; x=1738576759; 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=fOELaFIO5iUqHVPdsTFBOAPxUJnQlKBp6D46phdh9Z0=; b=YZWRN+S9QjmgF6FtkKaDX709nQI4/zIKQW8StVo0FxyPyNiduKkf4Mjq42ApN4X/hb 5vzjNIwTBPsjx9MHeUXhCn8qkmpx4Z0BnCxEVl8qm81dofV+9z2FWv7dUcQ+9+/PUMPN zFSDDYNckdIsZUz4Kyu/RbB+mb+0NMEpoxSjGO2EcPW7UCy8HveaJPcCE7v4S78MakN9 7B536/SIHDSXSUJaIcsfLT26PwJ4NHnUY+3nwKVswqgiaV2KZhzgy6v7/7IbknqoTBom 2PSMO4bUOBsdihp7+c3/QivxVkfXvNx6E9+Al+gPTxRLisw4UkSWRTdCVRxdZuwpA/wK CSWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737971959; x=1738576759; 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=fOELaFIO5iUqHVPdsTFBOAPxUJnQlKBp6D46phdh9Z0=; b=Ey3lbbZGLQo8alSMWabjy8tgoh6dr22+5iSrMm2nmYwMvWqaniLOfZe1DpiOf4Vx0o d5iwfGxVzRHJAz0543ByW7aziCrCflwOnwRH2S3oXhG2Tr7zZkF+C9HWEBFdotauIDXf GH1B2Qb0cngoGMn8JzS8vvcTmKLKDs8kXVryOE5EyhjlU/xC/uyr8sdMDE6aM1tAnsOY tZgvDdHfmr9NLeQzEfScRQPvWCD/f28r6LmOfHNSnSve5paOJsv+O8SXTIf3IVZ3fnWw dM8dIFDEReZ7ogqKGPjN+G7tU5+4levDjyGWd+74N6mZev7Ez5L4FhrcLsGCHQJVMRPR 09dg== X-Forwarded-Encrypted: i=1; AJvYcCXnwYP3/+VAux3wmOCB9wQ5gqlL+QL8lDXFc+njMfv1FH3l7gmu4GOIt8mf37XD4VmktBvoViexfOS598c=@vger.kernel.org X-Gm-Message-State: AOJu0YwwxT4azgUpbieWItsNJGgl+mO3hvRIVkk7dLRKTury3l9cMUZh RzXeKNDN7rSJBdj+QOfu1E2AIrPGZWbszSnJQpIIP82Q94h8i6tIDlaBxOmyBsrZlS7IMxhS5Us 1fkB22g== X-Google-Smtp-Source: AGHT+IGA9+D9Jw5XlvJVQYmyZq4z9qPj1Raw20IsgspYZ/XEthKM0PaESyfATbCHjlFPN+y77Ajbop+3/fBw X-Received: from edbb6.prod.google.com ([2002:a05:6402:1f06:b0:5d8:7c86:ecac]) (user=dvyukov job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:278f:b0:5d2:7346:3ecb with SMTP id 4fb4d7f45d1cf-5db7d2f8066mr38124892a12.12.1737971958994; Mon, 27 Jan 2025 01:59:18 -0800 (PST) Date: Mon, 27 Jan 2025 10:58:49 +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.262.g85cc9f2d1e-goog Message-ID: <3e52ed435e0ce98e1108b172fdcadc4749a25c98.1737971364.git.dvyukov@google.com> Subject: [PATCH v3 2/7] perf report: Add parallelism sort key From: Dmitry Vyukov To: namhyung@kernel.org, irogers@google.com Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Vyukov , Arnaldo Carvalho de Melo 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.262.g85cc9f2d1e-goog From nobody Thu Jan 30 19:14:12 2025 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.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 E32571FE44D for ; Mon, 27 Jan 2025 09:59:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737971964; cv=none; b=ks+7AaAYbSGKHVIBIH5l+AKykRBVeDo3xHiUj+k6j2hpeTpojv63EqSzNdGZlB6Kcgi4EJlmViDwvzTtRKKgpYnhnY72faGmP6ofryfqLbcgKmJ3b7VoF3vRwKA/LwREjNNZfNJgmQ8tAqGHLxmqCJiG/kQsIWxG6bkwr1LqY4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737971964; c=relaxed/simple; bh=CMm71ocJ13ENhSwg83YLPq3qIcUDzcZT3Q0wIiZ2TJ0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=GwpEFuPV/nAUa+ZG+f/UYOS5nyZqqA4dTzDZOlHFI/ji235bQQnCFUkonPXWQtewrYxkDfgS9AQUlDc6cOvejNP+Ar3qeHhy3R4q83KNvVpaIOO+yrJSI9pezHq0rbyHa7S46yJJZq6tr9RKvxPc8bHjV/Undu++5sc9toua0S4= 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=K9zhUMk6; arc=none smtp.client-ip=209.85.128.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="K9zhUMk6" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-43625ceae52so22834155e9.0 for ; Mon, 27 Jan 2025 01:59:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1737971961; x=1738576761; 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=qZi36qj3Dk8D5X5YEhL/AUUUkfpPn0nYoCcDBPXmPQQ=; b=K9zhUMk6SiTXozuOaGkTN8lcTcLaOsVy0H5wEcOYYlZcGDg/wNw3KVpgNhzSio+0ed AJOV5PMN3VRQWqqKxPftKiXQDyV8MFHfodx/KgRRnK5Fp68UOYkFfABTidRIIO1J/7hZ QVCTLP/7duJ3Ci1QClaqUVrVJejyB1JSKXpSP8bTpFI+n/AJVvlfjtUKc/CLiobNdKtQ inRiynfNaRBGm3w5Fom74f+bftQeIr2/klndA6+am1eNj2E2v/YGXfAFpnD9jXl1EK2U 58Fh8hWNjFJq7GeF6t0ZiUMQKkk9QGOm+bnNGCb5dJrH2VCb+uHsi9v1RQGjE58ZSwHC H3Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737971961; x=1738576761; 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=qZi36qj3Dk8D5X5YEhL/AUUUkfpPn0nYoCcDBPXmPQQ=; b=v2bqyVJwYQJzHafM+QQ3jArfpUUrLWB8joYGhVYaAbkuPub3wmoC/ZSP4c+SHGCjj5 Rflvq3BwziGU4YhtEB+hi/zs+G5v5ZTVMoBZkh8V9zAAt5fpy/VwwsMwquPH4Ul72GOa co4tcNFHi362z5z2z/nffBE+wl/4eLmIXcJOpzvV0zFt81OlFFjqiZpp+7rj5AZCwHSC zFugOvUUVsvRQBJj0POH+F6j8OH2jY2kVUm0QaSxeqwB+Rw6dzQHCas45EsiQMJY88Ag YgtuFrlvHSp3ETTk/B0EckSoM8s3pAwPx4W8amBkbdsSckdsJPrnMlK2eQOyIo18jMp+ /kPg== X-Forwarded-Encrypted: i=1; AJvYcCUNeXjAyz+rL17jRAlPWpd4BGeaZIrN8KbGpayil6ciFOTN5XLoO3nAgZ5pRB0Q4+MrhgWeP4FJUI7f41Y=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9BLfElJn+57t7MGBw0sQRKOAN08Yq0killSCAT3ce+k5tefph DMV2tWdu0WuoLQmgqsaG5HdywQ6uthibVfF1wzAdjAS2N1VN1QqnGRSwc8pMr8UXwJ4qH3YpqcS STw2Hhg== X-Google-Smtp-Source: AGHT+IHmH3Gqb/Z2o7jzI0F2xckNIS1ZWcj3WZmmtB5FP/KGhgCpjXrsbfIsdGeJn+tXm3YFAkftIGHWW/sG X-Received: from wmga3.prod.google.com ([2002:a05:600c:2d43:b0:434:9da4:2fa5]) (user=dvyukov job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:5112:b0:434:a5bc:70fc with SMTP id 5b1f17b1804b1-438913cfa0emr355327075e9.8.1737971961472; Mon, 27 Jan 2025 01:59:21 -0800 (PST) Date: Mon, 27 Jan 2025 10:58:50 +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.262.g85cc9f2d1e-goog Message-ID: Subject: [PATCH v3 3/7] perf report: Switch filtered from u8 to u16 From: Dmitry Vyukov To: namhyung@kernel.org, irogers@google.com Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Vyukov , Arnaldo Carvalho de Melo Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We already have all u8 bits taken, adding one more filter leads to unpleasa= nt failure mode, where code compiles w/o warnings, but the last filters silent= ly don't work. Add a typedef and switch to u16. 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/util/addr_location.h | 3 ++- tools/perf/util/hist.c | 2 +- tools/perf/util/hist.h | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/addr_location.h b/tools/perf/util/addr_locatio= n.h index 36aaa45445f24..f83d74e370b2f 100644 --- a/tools/perf/util/addr_location.h +++ b/tools/perf/util/addr_location.h @@ -3,6 +3,7 @@ #define __PERF_ADDR_LOCATION 1 =20 #include +#include "hist.h" =20 struct thread; struct maps; @@ -17,7 +18,7 @@ struct addr_location { const char *srcline; u64 addr; char level; - u8 filtered; + filter_mask_t filtered; u8 cpumode; s32 cpu; s32 socket; diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index cafd693568189..6b8f8da8d3b66 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -585,7 +585,7 @@ static struct hist_entry *hist_entry__new(struct hist_e= ntry *template, return he; } =20 -static u8 symbol__parent_filter(const struct symbol *parent) +static filter_mask_t symbol__parent_filter(const struct symbol *parent) { if (symbol_conf.exclude_other && parent =3D=3D NULL) return 1 << HIST_FILTER__PARENT; diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index a6e662d77dc24..4035106a74087 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -33,6 +33,8 @@ enum hist_filter { HIST_FILTER__C2C, }; =20 +typedef u16 filter_mask_t; + enum hist_column { HISTC_SYMBOL, HISTC_TIME, @@ -244,7 +246,7 @@ struct hist_entry { bool leaf; =20 char level; - u8 filtered; + filter_mask_t filtered; =20 u16 callchain_size; union { --=20 2.48.1.262.g85cc9f2d1e-goog From nobody Thu Jan 30 19:14:12 2025 Received: from mail-ed1-f73.google.com (mail-ed1-f73.google.com [209.85.208.73]) (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 7D39A1FE46F for ; Mon, 27 Jan 2025 09:59:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737971967; cv=none; b=neyuUjbIBtoDvghyEpUNEEDl2zFNHX31XPIMdyjw6QmdN6QMZ7QND8uVLMRDrLtprntNH5ZowVD09qEi8/G8fneYOr+BFi2IDQtTf9Tr2nngKsKRJ965S5TJNSqqIJeStMmsFqMjOUshx1UwYG5kY+NAwheGr4Y5MdxdCBla8DM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737971967; c=relaxed/simple; bh=7O0m46F8ICV6OKRIzDTCptkWRUW9yw0QnAtK3wP7ZIc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=n7+GEQRYZLR0kieK9AVlCHlIWtJCtXnz+k1bhfLY6ZV15Xf98yBa1MpOVIQhei7g39BGUqQSqD2HjCy1LX9QS8UWec7+HX+4Ntc/gerGztEYBRaz06/fBd5CogclBoIlaAkot+qy9yKw5hHq412IZ+vPDxRezvYiEw0GIoFl4cI= 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=EccBemID; arc=none smtp.client-ip=209.85.208.73 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="EccBemID" Received: by mail-ed1-f73.google.com with SMTP id 4fb4d7f45d1cf-5d3fe991854so4630476a12.0 for ; Mon, 27 Jan 2025 01:59:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1737971964; x=1738576764; 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=z+zT3If5T8XsGWOeao9G4Z2Kmp0udWdvd9bpIxyWibE=; b=EccBemIDIF5n0uFXg411SJ0wus+bjohEi/vTE1unXrpmY6SqNYIJOw8NX2EgMxBO2Y 1IfUpV5oZ2fz8YI5rXSOdPtmNSSh2jY/FE+PWNmMHNQvoAHSzwcMaPP0SWC7CnZKoMyy /Xga9/IZFQvSjgYcekUo1ciZOtGrou1Kjl0peL41Q/fgeWzkPJ8Sf/pAxKDDcfm46mMR bIn/hX4qvFdLVg4OtOpeGj+bGE32fBoSen7Pbd/cSy5PK06TlO/Fui4eiQK9NSQl9t8h HxpijB6GK6SzGmzsK6YyzkTnj2A3DunyoLvrr6Bw9EhCOpIS3U2QgUHobg3rNmEaXGO3 r+rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737971964; x=1738576764; 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=z+zT3If5T8XsGWOeao9G4Z2Kmp0udWdvd9bpIxyWibE=; b=wiBBtovOrVklBGMJXkQYFkGv0vMYSRDsMz8PZw2knemw14+vrmUtR6+bRSjkFKMhBO SejJIePzExFrwKlWUj21TvdgOOCoIDUmefa72zogLVYI70ochqfGR3msA0eD8AZwGwEs JSUqdY1yVw4r9bdBi2Jz6JEERHvB+EDs3MyMqeecFbIRXZpBURCugCf1e95dTgk3US3U rDL4h6M7ACUwPlKGnho5vIt/0XZFrtgaXpGzAq7+K98dFSTa3RAERVySE99Y9E5OpPLd 1ZII+Hg+pHRC1C4L6Rzi0Wqhwq6AQJGl3poF/yRAErMVf9Fp4r/mujqkbCnxILS2YrHd SsJA== X-Forwarded-Encrypted: i=1; AJvYcCW9PP6xr/FfuEtMDbeH3JXALiFOrd0CajGDlNeJ7KGsW0QmjDk1WBBBkJmrGnxEpur57h6jQtFDX4oBTFk=@vger.kernel.org X-Gm-Message-State: AOJu0Yx7ojwX/jzB9cedeEMoWjNIOF7EBaPzHewfc3S1pQWZyNdxY/PP 29q/MKs0C5feJgRrDp/mwhkR1zuoYWEwmEJbXZgsS6UKazWrlZKx5RngymA86Y9xCZL60SsWwRw ikahosw== X-Google-Smtp-Source: AGHT+IGWwuLONGcTFBCVg7atwfx3Q4Hvv7KuI65+C7jlFWWoZSTmOnQdAjp/iRS25wwoAQJomnx1DJLMe7jI X-Received: from edben25.prod.google.com ([2002:a05:6402:5299:b0:5d0:ccd2:6689]) (user=dvyukov job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:2813:b0:5db:731d:4456 with SMTP id 4fb4d7f45d1cf-5db7db07839mr40739040a12.28.1737971963951; Mon, 27 Jan 2025 01:59:23 -0800 (PST) Date: Mon, 27 Jan 2025 10:58:51 +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.262.g85cc9f2d1e-goog Message-ID: <289635b78c94222012184f0331a793741b6f7531.1737971364.git.dvyukov@google.com> Subject: [PATCH v3 4/7] perf report: Add parallelism filter From: Dmitry Vyukov To: namhyung@kernel.org, irogers@google.com Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Vyukov , Arnaldo Carvalho de Melo Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add parallelism filter that can be used to look at specific parallelism levels only. The format is the same as cpu lists. For example: Only single-threaded samples: --parallelism=3D1 Low parallelism only: --parallelism=3D1-4 High parallelism only: --parallelism=3D64-128 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 | 5 ++++- tools/perf/util/event.c | 2 ++ tools/perf/util/hist.c | 31 +++++++++++++++++++++++++++++++ tools/perf/util/hist.h | 6 +++++- tools/perf/util/sort.c | 11 +++++++++++ tools/perf/util/symbol.c | 34 ++++++++++++++++++++++++++++++++++ tools/perf/util/symbol_conf.h | 4 ++++ 7 files changed, 91 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 14d49f0625881..2a19abdc869a1 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -1390,6 +1390,8 @@ int cmd_report(int argc, const char **argv) symbol__config_symfs), OPT_STRING('C', "cpu", &report.cpu_list, "cpu", "list of cpus to profile"), + OPT_STRING(0, "parallelism", &symbol_conf.parallelism_list_str, "parallel= ism", + "only consider these parallelism levels (cpu set format)"), OPT_BOOLEAN('I', "show-info", &report.show_full_info, "Display extended information about perf.data file"), OPT_BOOLEAN(0, "source", &annotate_opts.annotate_src, @@ -1721,7 +1723,8 @@ int cmd_report(int argc, const char **argv) } =20 if (report.disable_order || !perf_session__has_switch_events(session)) { - if ((sort_order && strstr(sort_order, "parallelism")) || + if (symbol_conf.parallelism_list_str || + (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"= ); diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 3d3ac58e1c660..bea9698e0c6bf 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -769,6 +769,8 @@ int machine__resolve(struct machine *machine, struct ad= dr_location *al, =20 /* Account for possible out-of-order switch events. */ al->parallelism =3D min(max(machine->parallelism, 1), machine__nr_cpus_av= ail(machine)); + if (test_bit(al->parallelism, symbol_conf.parallelism_filter)) + al->filtered |=3D (1 << HIST_FILTER__PARALLELISM); =20 if (al->map) { if (symbol_conf.dso_list && diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 6b8f8da8d3b66..446342246f5ee 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -43,6 +43,8 @@ static bool hists__filter_entry_by_symbol(struct hists *h= ists, struct hist_entry *he); static bool hists__filter_entry_by_socket(struct hists *hists, struct hist_entry *he); +static bool hists__filter_entry_by_parallelism(struct hists *hists, + struct hist_entry *he); =20 u16 hists__col_len(struct hists *hists, enum hist_column col) { @@ -1457,6 +1459,10 @@ static void hist_entry__check_and_remove_filter(stru= ct hist_entry *he, if (symbol_conf.sym_list =3D=3D NULL) return; break; + case HIST_FILTER__PARALLELISM: + if (__bitmap_weight(symbol_conf.parallelism_filter, MAX_NR_CPUS + 1) =3D= =3D 0) + return; + break; case HIST_FILTER__PARENT: case HIST_FILTER__GUEST: case HIST_FILTER__HOST: @@ -1515,6 +1521,9 @@ static void hist_entry__apply_hierarchy_filters(struc= t hist_entry *he) hist_entry__check_and_remove_filter(he, HIST_FILTER__SYMBOL, perf_hpp__is_sym_entry); =20 + hist_entry__check_and_remove_filter(he, HIST_FILTER__PARALLELISM, + perf_hpp__is_parallelism_entry); + hists__apply_filters(he->hists, he); } =20 @@ -1711,6 +1720,7 @@ static void hists__apply_filters(struct hists *hists,= struct hist_entry *he) hists__filter_entry_by_thread(hists, he); hists__filter_entry_by_symbol(hists, he); hists__filter_entry_by_socket(hists, he); + hists__filter_entry_by_parallelism(hists, he); } =20 int hists__collapse_resort(struct hists *hists, struct ui_progress *prog) @@ -2197,6 +2207,16 @@ static bool hists__filter_entry_by_socket(struct his= ts *hists, return false; } =20 +static bool hists__filter_entry_by_parallelism(struct hists *hists, + struct hist_entry *he) +{ + if (test_bit(he->parallelism, hists->parallelism_filter)) { + he->filtered |=3D (1 << HIST_FILTER__PARALLELISM); + return true; + } + return false; +} + typedef bool (*filter_fn_t)(struct hists *hists, struct hist_entry *he); =20 static void hists__filter_by_type(struct hists *hists, int type, filter_fn= _t filter) @@ -2366,6 +2386,16 @@ void hists__filter_by_socket(struct hists *hists) hists__filter_entry_by_socket); } =20 +void hists__filter_by_parallelism(struct hists *hists) +{ + if (symbol_conf.report_hierarchy) + hists__filter_hierarchy(hists, HIST_FILTER__PARALLELISM, + hists->parallelism_filter); + else + hists__filter_by_type(hists, HIST_FILTER__PARALLELISM, + hists__filter_entry_by_parallelism); +} + void events_stats__inc(struct events_stats *stats, u32 type) { ++stats->nr_events[0]; @@ -2872,6 +2902,7 @@ int __hists__init(struct hists *hists, struct perf_hp= p_list *hpp_list) hists->entries =3D RB_ROOT_CACHED; mutex_init(&hists->lock); hists->socket_filter =3D -1; + hists->parallelism_filter =3D symbol_conf.parallelism_filter; hists->hpp_list =3D hpp_list; INIT_LIST_HEAD(&hists->hpp_formats); return 0; diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 4035106a74087..c2236e0d89f2a 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -31,6 +31,7 @@ enum hist_filter { HIST_FILTER__HOST, HIST_FILTER__SOCKET, HIST_FILTER__C2C, + HIST_FILTER__PARALLELISM, }; =20 typedef u16 filter_mask_t; @@ -112,6 +113,7 @@ struct hists { const struct dso *dso_filter; const char *uid_filter_str; const char *symbol_filter_str; + unsigned long *parallelism_filter; struct mutex lock; struct hists_stats stats; u64 event_stream; @@ -388,11 +390,13 @@ void hists__filter_by_dso(struct hists *hists); void hists__filter_by_thread(struct hists *hists); void hists__filter_by_symbol(struct hists *hists); void hists__filter_by_socket(struct hists *hists); +void hists__filter_by_parallelism(struct hists *hists); =20 static inline bool hists__has_filter(struct hists *hists) { return hists->thread_filter || hists->dso_filter || - hists->symbol_filter_str || (hists->socket_filter > -1); + hists->symbol_filter_str || (hists->socket_filter > -1) || + hists->parallelism_filter; } =20 u16 hists__col_len(struct hists *hists, enum hist_column col); diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 7eef43f5be360..3055496358ebb 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -900,6 +900,16 @@ sort__parallelism_cmp(struct hist_entry *left, struct = hist_entry *right) return right->parallelism - left->parallelism; } =20 +static int hist_entry__parallelism_filter(struct hist_entry *he, int type,= const void *arg) +{ + const unsigned long *parallelism_filter =3D arg; + + if (type !=3D HIST_FILTER__PARALLELISM) + return -1; + + return test_bit(he->parallelism, parallelism_filter); +} + static int hist_entry__parallelism_snprintf(struct hist_entry *he, char *b= f, size_t size, unsigned int width) { @@ -909,6 +919,7 @@ static int hist_entry__parallelism_snprintf(struct hist= _entry *he, char *bf, struct sort_entry sort_parallelism =3D { .se_header =3D "Parallelism", .se_cmp =3D sort__parallelism_cmp, + .se_filter =3D hist_entry__parallelism_filter, .se_snprintf =3D hist_entry__parallelism_snprintf, .se_width_idx =3D HISTC_PARALLELISM, }; diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 49b08adc6ee34..315f74b5bac06 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -18,6 +18,7 @@ #include "annotate.h" #include "build-id.h" #include "cap.h" +#include "cpumap.h" #include "dso.h" #include "util.h" // lsdir() #include "debug.h" @@ -2471,6 +2472,36 @@ int symbol__annotation_init(void) return 0; } =20 +static int setup_parallelism_bitmap(void) +{ + struct perf_cpu_map *map; + struct perf_cpu cpu; + int i, err =3D -1; + + if (symbol_conf.parallelism_list_str =3D=3D NULL) + return 0; + + map =3D perf_cpu_map__new(symbol_conf.parallelism_list_str); + if (map =3D=3D NULL) { + pr_err("failed to parse parallelism filter list\n"); + return -1; + } + + bitmap_fill(symbol_conf.parallelism_filter, MAX_NR_CPUS + 1); + perf_cpu_map__for_each_cpu(cpu, i, map) { + if (cpu.cpu <=3D 0 || cpu.cpu > MAX_NR_CPUS) { + pr_err("Requested parallelism level %d is invalid.\n", cpu.cpu); + goto out_delete_map; + } + __clear_bit(cpu.cpu, symbol_conf.parallelism_filter); + } + + err =3D 0; +out_delete_map: + perf_cpu_map__put(map); + return err; +} + int symbol__init(struct perf_env *env) { const char *symfs; @@ -2490,6 +2521,9 @@ int symbol__init(struct perf_env *env) return -1; } =20 + if (setup_parallelism_bitmap()) + return -1; + if (setup_list(&symbol_conf.dso_list, symbol_conf.dso_list_str, "dso") < 0) return -1; diff --git a/tools/perf/util/symbol_conf.h b/tools/perf/util/symbol_conf.h index a9c51acc722fe..c5b2e56127e22 100644 --- a/tools/perf/util/symbol_conf.h +++ b/tools/perf/util/symbol_conf.h @@ -3,6 +3,8 @@ #define __PERF_SYMBOL_CONF 1 =20 #include +#include +#include "perf.h" =20 struct strlist; struct intlist; @@ -62,6 +64,7 @@ struct symbol_conf { *pid_list_str, *tid_list_str, *sym_list_str, + *parallelism_list_str, *col_width_list_str, *bt_stop_list_str; const char *addr2line_path; @@ -82,6 +85,7 @@ struct symbol_conf { int pad_output_len_dso; int group_sort_idx; int addr_range; + DECLARE_BITMAP(parallelism_filter, MAX_NR_CPUS + 1); }; =20 extern struct symbol_conf symbol_conf; --=20 2.48.1.262.g85cc9f2d1e-goog From nobody Thu Jan 30 19:14:12 2025 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.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 10FF41FE44D for ; Mon, 27 Jan 2025 09:59:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737971970; cv=none; b=gK3vUzDdRmS+DSxXW+Q83Yg22RZe66erN8HZ2spk6ULDOr5XATcoRxS23ZkTTiKr/KH4F9FSV4jT6ATozaV3lKCCBeaNuIOkXCB87nTVLCAr31NhPhdxqILbxu8z0Dnvtjkf5W2CFtTuIVm5D1YpzbT3IFJ3sOkB9nTvv34ZSXs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737971970; c=relaxed/simple; bh=tj48tJStSoa8NsSIlo5vRazc8JK2OOwEO11JtFudNWI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=KTuV1DsiDSViSq2dmXz4rL3vnGtkQdR0NLqZQUiHQwSN0yaO7EIF7DbENmFYKgpvidpIruQwiOGbysLJRLKl9KBgk5uCq49zq0CwF87cblxefzp9YrCNEI0sPrVQMuG0i3733n/Wejy6KWnMZ918FYqqu+ClZpfoglcfyZIQxhI= 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=F34UM/io; arc=none smtp.client-ip=209.85.221.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="F34UM/io" Received: by mail-wr1-f74.google.com with SMTP id ffacd0b85a97d-3862f3ccf4fso1527577f8f.0 for ; Mon, 27 Jan 2025 01:59:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1737971966; x=1738576766; 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=DEYgr8NiRuf/MUjg0vTTBPjAK5Rg2dASAahcJb1Uu2o=; b=F34UM/ioqvg1y+bFeGWg8lUVG8x7rwqCfHc1qI+Zj5Ul9tVqLhe0Z00xcbZd+qHQl/ EzwwC4dDw+qafwNjDljL+76a2QPuJ5YJL/SIO3ssLDVFmvF4av2O3btr7CTkBPu0ozSq 9k2RleR3GniAea5ZGZPi0XheVBLYHDz6xnqp+HpFqCEPSbNh4t6FtZqC78+qF0srZ2VA z3QLI/pamXV12DtmF8Kiq6a2AKSiAAWjuShJXlwnLA+W5jnkBorvnQ9kNlHMwC1gPunY 8nkyCuI++ab26tqZFoVhR2ZhlSSnu7uaLsrwalRuMO87i+2lx0lU9b6glnzXDREef7yP OwZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737971966; x=1738576766; 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=DEYgr8NiRuf/MUjg0vTTBPjAK5Rg2dASAahcJb1Uu2o=; b=S/9kMoecmFJdV1YfLzJVUGFWksVvFVyAH+AAWHjaOBhkbUBOeDeSBktnnSXoG7oGYL ouUuQ4MG5eaBHsTZdNPEhtJ66Bw05AWmZLnqLvw5s5R9qEULgwE6hyOte0brLr+oCboC 6wEDX35YjjnZP9Kng7sxqq1SgLRAyp2H2q6FpUQXaYK/NMUPBe6bTpil8NGj2s5UczaG aB0Md4adyJi3ZBYJYCnr62+iGcGq8VbAwUtFBUinpxnQhfOivkSwnjxyYszqOoEV4oPW 6fISQRk3cG1dvcjK5xAynnFRv+EKrNWUU09eJhEFG5b3uUBTDyCkmNcEkAKCOQEq32L8 jXKQ== X-Forwarded-Encrypted: i=1; AJvYcCUANHbjFyo5C5bVB90fLmLegwnxT7Kt27r/jLlspQirROhzXyPhZ/+ZBm9j1H53SP2q9pUwAGq7JeAcpgA=@vger.kernel.org X-Gm-Message-State: AOJu0YwEo7T4s6F9mz1CPp+srW4Sca7PxN2JqJPXoKne6HzJxGejbL67 YIth178DXL2GItty8/v/pZTp6ucsKw12F27peO4kfl5PvRYAkbFXp9bd6FU4OaBJCtMYAt5fJfo yJTIYtg== X-Google-Smtp-Source: AGHT+IETMVa60LkLoAi9MKWTaaCLbABz/4gmWn5S0qObeaXzCMUEgSrZ+ZundSlAQkwqbFqzCGMGAwfDM5qg X-Received: from wrbgv19.prod.google.com ([2002:a05:6000:4613:b0:386:36e7:f43f]) (user=dvyukov job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:1f8a:b0:385:f092:e16 with SMTP id ffacd0b85a97d-38bf57be9e6mr33386229f8f.55.1737971966562; Mon, 27 Jan 2025 01:59:26 -0800 (PST) Date: Mon, 27 Jan 2025 10:58:52 +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.262.g85cc9f2d1e-goog Message-ID: Subject: [PATCH v3 5/7] perf report: Add latency output field From: Dmitry Vyukov To: namhyung@kernel.org, irogers@google.com Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Vyukov , Arnaldo Carvalho de Melo Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Latency output field is similar to overhead, but represents overhead for latency rather than CPU consumption. It's re-scaled from overhead by dividi= ng weight by the current parallelism level at the time of the sample. It effectively models profiling with 1 sample taken per unit of wall-clock time rather than unit of CPU time. 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/ui/browsers/hists.c | 27 ++++++++++------ tools/perf/ui/hist.c | 29 ++++++++++------- tools/perf/util/addr_location.h | 2 ++ tools/perf/util/event.c | 6 ++++ tools/perf/util/events_stats.h | 2 ++ tools/perf/util/hist.c | 55 ++++++++++++++++++++++++--------- tools/perf/util/hist.h | 12 +++++++ tools/perf/util/sort.c | 2 ++ 8 files changed, 100 insertions(+), 35 deletions(-) diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 49ba82bf33918..35c10509b797f 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -1226,7 +1226,7 @@ int __hpp__slsmg_color_printf(struct perf_hpp *hpp, c= onst char *fmt, ...) return ret; } =20 -#define __HPP_COLOR_PERCENT_FN(_type, _field) \ +#define __HPP_COLOR_PERCENT_FN(_type, _field, _fmttype) \ static u64 __hpp_get_##_field(struct hist_entry *he) \ { \ return he->stat._field; \ @@ -1238,10 +1238,10 @@ hist_browser__hpp_color_##_type(struct perf_hpp_fmt= *fmt, \ struct hist_entry *he) \ { \ return hpp__fmt(fmt, hpp, he, __hpp_get_##_field, " %*.2f%%", \ - __hpp__slsmg_color_printf, true); \ + __hpp__slsmg_color_printf, _fmttype); \ } =20 -#define __HPP_COLOR_ACC_PERCENT_FN(_type, _field) \ +#define __HPP_COLOR_ACC_PERCENT_FN(_type, _field, _fmttype) \ static u64 __hpp_get_acc_##_field(struct hist_entry *he) \ { \ return he->stat_acc->_field; \ @@ -1262,15 +1262,18 @@ hist_browser__hpp_color_##_type(struct perf_hpp_fmt= *fmt, \ return ret; \ } \ return hpp__fmt(fmt, hpp, he, __hpp_get_acc_##_field, \ - " %*.2f%%", __hpp__slsmg_color_printf, true); \ + " %*.2f%%", __hpp__slsmg_color_printf, \ + _fmttype); \ } =20 -__HPP_COLOR_PERCENT_FN(overhead, period) -__HPP_COLOR_PERCENT_FN(overhead_sys, period_sys) -__HPP_COLOR_PERCENT_FN(overhead_us, period_us) -__HPP_COLOR_PERCENT_FN(overhead_guest_sys, period_guest_sys) -__HPP_COLOR_PERCENT_FN(overhead_guest_us, period_guest_us) -__HPP_COLOR_ACC_PERCENT_FN(overhead_acc, period) +__HPP_COLOR_PERCENT_FN(overhead, period, PERF_HPP_FMT_TYPE__PERCENT) +__HPP_COLOR_PERCENT_FN(latency, latency, PERF_HPP_FMT_TYPE__LATENCY) +__HPP_COLOR_PERCENT_FN(overhead_sys, period_sys, PERF_HPP_FMT_TYPE__PERCEN= T) +__HPP_COLOR_PERCENT_FN(overhead_us, period_us, PERF_HPP_FMT_TYPE__PERCENT) +__HPP_COLOR_PERCENT_FN(overhead_guest_sys, period_guest_sys, PERF_HPP_FMT_= TYPE__PERCENT) +__HPP_COLOR_PERCENT_FN(overhead_guest_us, period_guest_us, PERF_HPP_FMT_TY= PE__PERCENT) +__HPP_COLOR_ACC_PERCENT_FN(overhead_acc, period, PERF_HPP_FMT_TYPE__PERCEN= T) +__HPP_COLOR_ACC_PERCENT_FN(latency_acc, latency, PERF_HPP_FMT_TYPE__LATENC= Y) =20 #undef __HPP_COLOR_PERCENT_FN #undef __HPP_COLOR_ACC_PERCENT_FN @@ -1279,6 +1282,8 @@ void hist_browser__init_hpp(void) { perf_hpp__format[PERF_HPP__OVERHEAD].color =3D hist_browser__hpp_color_overhead; + perf_hpp__format[PERF_HPP__LATENCY].color =3D + hist_browser__hpp_color_latency; perf_hpp__format[PERF_HPP__OVERHEAD_SYS].color =3D hist_browser__hpp_color_overhead_sys; perf_hpp__format[PERF_HPP__OVERHEAD_US].color =3D @@ -1289,6 +1294,8 @@ void hist_browser__init_hpp(void) hist_browser__hpp_color_overhead_guest_us; perf_hpp__format[PERF_HPP__OVERHEAD_ACC].color =3D hist_browser__hpp_color_overhead_acc; + perf_hpp__format[PERF_HPP__LATENCY_ACC].color =3D + hist_browser__hpp_color_latency_acc; =20 res_sample_init(); } diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 34fda1d5eccb4..22e31d835301e 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c @@ -27,9 +27,10 @@ static int __hpp__fmt_print(struct perf_hpp *hpp, struct= hists *hists, u64 val, int nr_samples, const char *fmt, int len, hpp_snprint_fn print_fn, enum perf_hpp_fmt_type fmtype) { - if (fmtype =3D=3D PERF_HPP_FMT_TYPE__PERCENT) { + if (fmtype =3D=3D PERF_HPP_FMT_TYPE__PERCENT || fmtype =3D=3D PERF_HPP_FM= T_TYPE__LATENCY) { double percent =3D 0.0; - u64 total =3D hists__total_period(hists); + u64 total =3D fmtype =3D=3D PERF_HPP_FMT_TYPE__PERCENT ? hists__total_pe= riod(hists) : + hists__total_latency(hists); =20 if (total) percent =3D 100.0 * val / total; @@ -128,7 +129,7 @@ int hpp__fmt(struct perf_hpp_fmt *fmt, struct perf_hpp = *hpp, print_fn, fmtype); } =20 - if (fmtype =3D=3D PERF_HPP_FMT_TYPE__PERCENT) + if (fmtype =3D=3D PERF_HPP_FMT_TYPE__PERCENT || fmtype =3D=3D PERF_HPP_FM= T_TYPE__LATENCY) len -=3D 2; /* 2 for a space and a % sign */ else len -=3D 1; @@ -472,11 +473,13 @@ __HPP_ENTRY_AVERAGE_FN(_type, _field) \ __HPP_SORT_AVERAGE_FN(_type, _field) =20 HPP_PERCENT_FNS(overhead, period) +HPP_PERCENT_FNS(latency, latency) HPP_PERCENT_FNS(overhead_sys, period_sys) HPP_PERCENT_FNS(overhead_us, period_us) HPP_PERCENT_FNS(overhead_guest_sys, period_guest_sys) HPP_PERCENT_FNS(overhead_guest_us, period_guest_us) HPP_PERCENT_ACC_FNS(overhead_acc, period) +HPP_PERCENT_ACC_FNS(latency_acc, latency) =20 HPP_RAW_FNS(samples, nr_events) HPP_RAW_FNS(period, period) @@ -548,11 +551,13 @@ static bool hpp__equal(struct perf_hpp_fmt *a, struct= perf_hpp_fmt *b) =20 struct perf_hpp_fmt perf_hpp__format[] =3D { HPP__COLOR_PRINT_FNS("Overhead", overhead, OVERHEAD), + HPP__COLOR_PRINT_FNS("Latency", latency, LATENCY), HPP__COLOR_PRINT_FNS("sys", overhead_sys, OVERHEAD_SYS), HPP__COLOR_PRINT_FNS("usr", overhead_us, OVERHEAD_US), HPP__COLOR_PRINT_FNS("guest sys", overhead_guest_sys, OVERHEAD_GUEST_SYS), HPP__COLOR_PRINT_FNS("guest usr", overhead_guest_us, OVERHEAD_GUEST_US), HPP__COLOR_ACC_PRINT_FNS("Children", overhead_acc, OVERHEAD_ACC), + HPP__COLOR_ACC_PRINT_FNS("Latency", latency_acc, LATENCY_ACC), HPP__PRINT_FNS("Samples", samples, SAMPLES), HPP__PRINT_FNS("Period", period, PERIOD), HPP__PRINT_FNS("Weight1", weight1, WEIGHT1), @@ -601,6 +606,11 @@ static void fmt_free(struct perf_hpp_fmt *fmt) fmt->free(fmt); } =20 +static bool fmt_equal(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b) +{ + return a->equal && a->equal(a, b); +} + void perf_hpp__init(void) { int i; @@ -671,30 +681,26 @@ static void perf_hpp__column_unregister(struct perf_h= pp_fmt *format) =20 void perf_hpp__cancel_cumulate(void) { - struct perf_hpp_fmt *fmt, *acc, *ovh, *tmp; + struct perf_hpp_fmt *fmt, *acc, *ovh, *acc_lat, *tmp; =20 if (is_strict_order(field_order)) return; =20 ovh =3D &perf_hpp__format[PERF_HPP__OVERHEAD]; acc =3D &perf_hpp__format[PERF_HPP__OVERHEAD_ACC]; + acc_lat =3D &perf_hpp__format[PERF_HPP__LATENCY_ACC]; =20 perf_hpp_list__for_each_format_safe(&perf_hpp_list, fmt, tmp) { - if (acc->equal(acc, fmt)) { + if (fmt_equal(acc, fmt) || fmt_equal(acc_lat, fmt)) { perf_hpp__column_unregister(fmt); continue; } =20 - if (ovh->equal(ovh, fmt)) + if (fmt_equal(ovh, fmt)) fmt->name =3D "Overhead"; } } =20 -static bool fmt_equal(struct perf_hpp_fmt *a, struct perf_hpp_fmt *b) -{ - return a->equal && a->equal(a, b); -} - void perf_hpp__setup_output_field(struct perf_hpp_list *list) { struct perf_hpp_fmt *fmt; @@ -819,6 +825,7 @@ void perf_hpp__reset_width(struct perf_hpp_fmt *fmt, st= ruct hists *hists) =20 switch (fmt->idx) { case PERF_HPP__OVERHEAD: + case PERF_HPP__LATENCY: case PERF_HPP__OVERHEAD_SYS: case PERF_HPP__OVERHEAD_US: case PERF_HPP__OVERHEAD_ACC: diff --git a/tools/perf/util/addr_location.h b/tools/perf/util/addr_locatio= n.h index f83d74e370b2f..663e9a55d8ed3 100644 --- a/tools/perf/util/addr_location.h +++ b/tools/perf/util/addr_location.h @@ -24,6 +24,8 @@ struct addr_location { s32 socket; /* Same as machine.parallelism but within [1, nr_cpus]. */ int parallelism; + /* See he_stat.latency. */ + u64 latency; }; =20 void addr_location__init(struct addr_location *al); diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index bea9698e0c6bf..36e576f141473 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -771,6 +771,12 @@ int machine__resolve(struct machine *machine, struct a= ddr_location *al, al->parallelism =3D min(max(machine->parallelism, 1), machine__nr_cpus_av= ail(machine)); if (test_bit(al->parallelism, symbol_conf.parallelism_filter)) al->filtered |=3D (1 << HIST_FILTER__PARALLELISM); + /* + * Multiply it by some const to avoid precision loss or dealing + * with floats. The multiplier does not matter otherwise since + * we only print it as percents. + */ + al->latency =3D sample->period * 1000 / al->parallelism; =20 if (al->map) { if (symbol_conf.dso_list && diff --git a/tools/perf/util/events_stats.h b/tools/perf/util/events_stats.h index eabd7913c3092..dcff697ed2529 100644 --- a/tools/perf/util/events_stats.h +++ b/tools/perf/util/events_stats.h @@ -57,6 +57,8 @@ struct events_stats { struct hists_stats { u64 total_period; u64 total_non_filtered_period; + u64 total_latency; + u64 total_non_filtered_latency; u32 nr_samples; u32 nr_non_filtered_samples; u32 nr_lost_samples; diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 446342246f5ee..a29324e33ed04 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -305,9 +305,10 @@ static long hist_time(unsigned long htime) return htime; } =20 -static void he_stat__add_period(struct he_stat *he_stat, u64 period) +static void he_stat__add_period(struct he_stat *he_stat, u64 period, u64 l= atency) { he_stat->period +=3D period; + he_stat->latency +=3D latency; he_stat->nr_events +=3D 1; } =20 @@ -322,6 +323,7 @@ static void he_stat__add_stat(struct he_stat *dest, str= uct he_stat *src) dest->weight2 +=3D src->weight2; dest->weight3 +=3D src->weight3; dest->nr_events +=3D src->nr_events; + dest->latency +=3D src->latency; } =20 static void he_stat__decay(struct he_stat *he_stat) @@ -331,6 +333,7 @@ static void he_stat__decay(struct he_stat *he_stat) he_stat->weight1 =3D (he_stat->weight1 * 7) / 8; he_stat->weight2 =3D (he_stat->weight2 * 7) / 8; he_stat->weight3 =3D (he_stat->weight3 * 7) / 8; + he_stat->latency =3D (he_stat->latency * 7) / 8; } =20 static void hists__delete_entry(struct hists *hists, struct hist_entry *he= ); @@ -338,7 +341,7 @@ static void hists__delete_entry(struct hists *hists, st= ruct hist_entry *he); static bool hists__decay_entry(struct hists *hists, struct hist_entry *he) { u64 prev_period =3D he->stat.period; - u64 diff; + u64 prev_latency =3D he->stat.latency; =20 if (prev_period =3D=3D 0) return true; @@ -348,12 +351,16 @@ static bool hists__decay_entry(struct hists *hists, s= truct hist_entry *he) he_stat__decay(he->stat_acc); decay_callchain(he->callchain); =20 - diff =3D prev_period - he->stat.period; - if (!he->depth) { - hists->stats.total_period -=3D diff; - if (!he->filtered) - hists->stats.total_non_filtered_period -=3D diff; + u64 period_diff =3D prev_period - he->stat.period; + u64 latency_diff =3D prev_latency - he->stat.latency; + + hists->stats.total_period -=3D period_diff; + hists->stats.total_latency -=3D latency_diff; + if (!he->filtered) { + hists->stats.total_non_filtered_period -=3D period_diff; + hists->stats.total_non_filtered_latency -=3D latency_diff; + } } =20 if (!he->leaf) { @@ -368,7 +375,7 @@ static bool hists__decay_entry(struct hists *hists, str= uct hist_entry *he) } } =20 - return he->stat.period =3D=3D 0; + return he->stat.period =3D=3D 0 && he->stat.latency =3D=3D 0; } =20 static void hists__delete_entry(struct hists *hists, struct hist_entry *he) @@ -594,14 +601,17 @@ static filter_mask_t symbol__parent_filter(const stru= ct symbol *parent) return 0; } =20 -static void hist_entry__add_callchain_period(struct hist_entry *he, u64 pe= riod) +static void hist_entry__add_callchain_period(struct hist_entry *he, u64 pe= riod, u64 latency) { if (!hist_entry__has_callchains(he) || !symbol_conf.use_callchain) return; =20 he->hists->callchain_period +=3D period; - if (!he->filtered) + he->hists->callchain_latency +=3D latency; + if (!he->filtered) { he->hists->callchain_non_filtered_period +=3D period; + he->hists->callchain_non_filtered_latency +=3D latency; + } } =20 static struct hist_entry *hists__findnew_entry(struct hists *hists, @@ -614,6 +624,7 @@ static struct hist_entry *hists__findnew_entry(struct h= ists *hists, struct hist_entry *he; int64_t cmp; u64 period =3D entry->stat.period; + u64 latency =3D entry->stat.latency; bool leftmost =3D true; =20 p =3D &hists->entries_in->rb_root.rb_node; @@ -632,10 +643,10 @@ static struct hist_entry *hists__findnew_entry(struct= hists *hists, if (!cmp) { if (sample_self) { he_stat__add_stat(&he->stat, &entry->stat); - hist_entry__add_callchain_period(he, period); + hist_entry__add_callchain_period(he, period, latency); } if (symbol_conf.cumulate_callchain) - he_stat__add_period(he->stat_acc, period); + he_stat__add_period(he->stat_acc, period, latency); =20 block_info__delete(entry->block_info); =20 @@ -672,7 +683,7 @@ static struct hist_entry *hists__findnew_entry(struct h= ists *hists, return NULL; =20 if (sample_self) - hist_entry__add_callchain_period(he, period); + hist_entry__add_callchain_period(he, period, latency); hists->nr_entries++; =20 rb_link_node(&he->rb_node_in, parent, p); @@ -751,6 +762,7 @@ __hists__add_entry(struct hists *hists, .weight1 =3D sample->weight, .weight2 =3D sample->ins_lat, .weight3 =3D sample->p_stage_cyc, + .latency =3D al->latency, }, .parent =3D sym_parent, .filtered =3D symbol__parent_filter(sym_parent) | al->filtered, @@ -1768,12 +1780,14 @@ static void hists__reset_filter_stats(struct hists = *hists) { hists->nr_non_filtered_entries =3D 0; hists->stats.total_non_filtered_period =3D 0; + hists->stats.total_non_filtered_latency =3D 0; } =20 void hists__reset_stats(struct hists *hists) { hists->nr_entries =3D 0; hists->stats.total_period =3D 0; + hists->stats.total_latency =3D 0; =20 hists__reset_filter_stats(hists); } @@ -1782,6 +1796,7 @@ static void hists__inc_filter_stats(struct hists *his= ts, struct hist_entry *h) { hists->nr_non_filtered_entries++; hists->stats.total_non_filtered_period +=3D h->stat.period; + hists->stats.total_non_filtered_latency +=3D h->stat.latency; } =20 void hists__inc_stats(struct hists *hists, struct hist_entry *h) @@ -1791,6 +1806,7 @@ void hists__inc_stats(struct hists *hists, struct his= t_entry *h) =20 hists->nr_entries++; hists->stats.total_period +=3D h->stat.period; + hists->stats.total_latency +=3D h->stat.latency; } =20 static void hierarchy_recalc_total_periods(struct hists *hists) @@ -1802,6 +1818,8 @@ static void hierarchy_recalc_total_periods(struct his= ts *hists) =20 hists->stats.total_period =3D 0; hists->stats.total_non_filtered_period =3D 0; + hists->stats.total_latency =3D 0; + hists->stats.total_non_filtered_latency =3D 0; =20 /* * recalculate total period using top-level entries only @@ -1813,8 +1831,11 @@ static void hierarchy_recalc_total_periods(struct hi= sts *hists) node =3D rb_next(node); =20 hists->stats.total_period +=3D he->stat.period; - if (!he->filtered) + hists->stats.total_latency +=3D he->stat.latency; + if (!he->filtered) { hists->stats.total_non_filtered_period +=3D he->stat.period; + hists->stats.total_non_filtered_latency +=3D he->stat.latency; + } } } =20 @@ -2791,6 +2812,12 @@ u64 hists__total_period(struct hists *hists) hists->stats.total_period; } =20 +u64 hists__total_latency(struct hists *hists) +{ + return symbol_conf.filter_relative ? hists->stats.total_non_filtered_late= ncy : + hists->stats.total_latency; +} + int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, b= ool show_freq) { char unit; diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index c2236e0d89f2a..91159f16c60b2 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -109,6 +109,8 @@ struct hists { u64 nr_non_filtered_entries; u64 callchain_period; u64 callchain_non_filtered_period; + u64 callchain_latency; + u64 callchain_non_filtered_latency; struct thread *thread_filter; const struct dso *dso_filter; const char *uid_filter_str; @@ -170,6 +172,12 @@ struct res_sample { =20 struct he_stat { u64 period; + /* + * Period re-scaled from CPU time to wall-clock time (divided by the + * parallelism at the time of the sample). This represents effect of + * the event on latency rather than CPU consumption. + */ + u64 latency; u64 period_sys; u64 period_us; u64 period_guest_sys; @@ -374,6 +382,7 @@ void hists__output_recalc_col_len(struct hists *hists, = int max_rows); struct hist_entry *hists__get_entry(struct hists *hists, int idx); =20 u64 hists__total_period(struct hists *hists); +u64 hists__total_latency(struct hists *hists); void hists__reset_stats(struct hists *hists); void hists__inc_stats(struct hists *hists, struct hist_entry *h); void hists__inc_nr_events(struct hists *hists); @@ -555,11 +564,13 @@ extern struct perf_hpp_fmt perf_hpp__format[]; enum { /* Matches perf_hpp__format array. */ PERF_HPP__OVERHEAD, + PERF_HPP__LATENCY, PERF_HPP__OVERHEAD_SYS, PERF_HPP__OVERHEAD_US, PERF_HPP__OVERHEAD_GUEST_SYS, PERF_HPP__OVERHEAD_GUEST_US, PERF_HPP__OVERHEAD_ACC, + PERF_HPP__LATENCY_ACC, PERF_HPP__SAMPLES, PERF_HPP__PERIOD, PERF_HPP__WEIGHT1, @@ -615,6 +626,7 @@ void hists__reset_column_width(struct hists *hists); enum perf_hpp_fmt_type { PERF_HPP_FMT_TYPE__RAW, PERF_HPP_FMT_TYPE__PERCENT, + PERF_HPP_FMT_TYPE__LATENCY, PERF_HPP_FMT_TYPE__AVERAGE, }; =20 diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index 3055496358ebb..bc4c3acfe7552 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -2628,11 +2628,13 @@ struct hpp_dimension { =20 static struct hpp_dimension hpp_sort_dimensions[] =3D { DIM(PERF_HPP__OVERHEAD, "overhead"), + DIM(PERF_HPP__LATENCY, "latency"), DIM(PERF_HPP__OVERHEAD_SYS, "overhead_sys"), DIM(PERF_HPP__OVERHEAD_US, "overhead_us"), DIM(PERF_HPP__OVERHEAD_GUEST_SYS, "overhead_guest_sys"), DIM(PERF_HPP__OVERHEAD_GUEST_US, "overhead_guest_us"), DIM(PERF_HPP__OVERHEAD_ACC, "overhead_children"), + DIM(PERF_HPP__LATENCY_ACC, "latency_children"), DIM(PERF_HPP__SAMPLES, "sample"), DIM(PERF_HPP__PERIOD, "period"), DIM(PERF_HPP__WEIGHT1, "weight1"), --=20 2.48.1.262.g85cc9f2d1e-goog From nobody Thu Jan 30 19:14:12 2025 Received: from mail-ed1-f73.google.com (mail-ed1-f73.google.com [209.85.208.73]) (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 7EACE1FECB2 for ; Mon, 27 Jan 2025 09:59:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737971972; cv=none; b=CIxvXHgiktxugZEX1837+X+OhiPzCb/LJRAsbhhsoQKBBQqw5UBhJyoB5htZZCKVhfY/un0eOzMRZ09Ij12j0o5ewYVhtUU8a8WsoWo2uiWDdiGfp6MqXETq7mShm3TPxro0CpMxYZjeaG/O0pA+8FBJ/qmJOKtSc7ppf6ypMnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737971972; c=relaxed/simple; bh=gJY4RlMRBrOEWOCFxqwDKzJS4qwdZRHORGp141d42RY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bfCENC93ZtEHcG4BgGroHtBQQLQVagUCF8cAAldYXlscNcjL8tdwhSkfa1beWVNXlS77A7IjXC5vq87zmV2x/1GM4VClmF3mDIvMjwWXKmR4iyhusvCZH11aAhK+/XBDASEvKhyMltnN9PkjdntIkK5kHP1JD848OXFOvXUbQAc= 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=0I88LPs2; arc=none smtp.client-ip=209.85.208.73 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="0I88LPs2" Received: by mail-ed1-f73.google.com with SMTP id 4fb4d7f45d1cf-5d90b88322aso3441010a12.3 for ; Mon, 27 Jan 2025 01:59:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1737971969; x=1738576769; 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=UI3PFDbizjPUwB2DpjyDkLXCl+QfdgHXUWI6TUxru0M=; b=0I88LPs25Qi/RVm7K+IweqGHc149g8jWZ+kFaZ2b76vKYRzCvoSi2erR7Yb9biTuoH BlJnp5SqXphNQqkQo7XdRlpN9JQwhgdHpWsu3mMpQ06r8vRErBO8mtQZeFAFaB5w2f9X VVvPeAbKTQQbIpRj6JaJq/9L7A2WJ79r1jWOE5V1fwPUTBCqeYJX6uDCSkqaN1HJE5af jKJfY+5ifCAzgHz5ZFOpwMO3x5Un/Xv6aTllDkmINqA88wLR9e8L0WW9BNQWt9o4P1Lv jMR0MHeHumbtcaN6JeC34BLzNL9bGFq3vtcwAIenWfH9qLElnTA/5bKGgbZxZfCWBJUa ugTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737971969; x=1738576769; 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=UI3PFDbizjPUwB2DpjyDkLXCl+QfdgHXUWI6TUxru0M=; b=G2y/RC2VDwQ9QawaIkkHaZFyxjnZKmw042j2oWl5GHrNUaIgXewl1hFSjSiULPjWxu SK3t18E/X2+QACfSLIzHGrJc/vm39GPEFYPy4AE2RxXNGaZRMdkIaHQVEIW51QWguojG kRyOoE5iliRDSqfMwyIn7VgJJyB5fVPS8cJNTd20Ctzecfxmq9dvpFKoqXF5kqWer1H/ efjqWqBuqD+z+kTTjnCihlYs5m2KVLvs4FWKv4MdfHNcTdMF8fUhnc1NSkzAfgbD/3qJ 1QTF+zA93CMaTRB/52giAtkp1XSFIZMEGAB9CsRa8vpUqjIE28M/2Ctbu1ZWTXLOioZy sHEg== X-Forwarded-Encrypted: i=1; AJvYcCVWtMdEgcFJZuviIHsGxbjIUGe4oxUVoO0B8/bNVQjiCHBrCL/3FYrPJAG9J6mYKFoWOqW/jZR6M94Vdfg=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9I2ucPtRMwysdaCKUhb1gM8TAv7Hxpgn8CskhYbhLxIXEmSs/ a6pEKWCnGpbTtHy7Xku4klEhqZ2uFWGPnoJnQrEGpz7Sxeakt4dSQ1WAWD57TixSPHe8Fzyqbys SRjT5Iw== X-Google-Smtp-Source: AGHT+IEhlV2/ER+QtAqm2OOo088+LKyzKDZ+VjLfP4b1dzl6eLVAbobMqR3MNBDd9gaBqRYsowO8H3dIKejs X-Received: from edze7.prod.google.com ([2002:a05:6402:1907:b0:5d8:ab23:4682]) (user=dvyukov job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:35d2:b0:5dc:6c1:816c with SMTP id 4fb4d7f45d1cf-5dc06c182e4mr13088466a12.1.1737971969229; Mon, 27 Jan 2025 01:59:29 -0800 (PST) Date: Mon, 27 Jan 2025 10:58:53 +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.262.g85cc9f2d1e-goog Message-ID: <70523ae7dd5d5c41d2d954324297d9d2cfad1b1f.1737971364.git.dvyukov@google.com> Subject: [PATCH v3 6/7] perf report: Add --latency flag From: Dmitry Vyukov To: namhyung@kernel.org, irogers@google.com Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Vyukov , Arnaldo Carvalho de Melo Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add record/report --latency flag that allows to capture and show latency-centric profiles rather than the default CPU-consumption-centric profiles. For latency profiles record captures context switch events, and report shows Latency as the first column. 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-record.c | 20 +++++++++++++++++ tools/perf/builtin-report.c | 32 +++++++++++++++++++++++---- tools/perf/ui/hist.c | 41 ++++++++++++++++++++++++++++------- tools/perf/util/hist.h | 1 + tools/perf/util/sort.c | 33 +++++++++++++++++++++++----- tools/perf/util/sort.h | 2 +- tools/perf/util/symbol_conf.h | 4 +++- 7 files changed, 113 insertions(+), 20 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 5db1aedf48df9..e219639ac401b 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -161,6 +161,7 @@ struct record { struct evlist *sb_evlist; pthread_t thread_id; int realtime_prio; + bool latency; bool switch_output_event_set; bool no_buildid; bool no_buildid_set; @@ -3371,6 +3372,9 @@ static struct option __record_options[] =3D { parse_events_option), OPT_CALLBACK(0, "filter", &record.evlist, "filter", "event filter", parse_filter), + OPT_BOOLEAN(0, "latency", &record.latency, + "Enable data collection for latency profiling.\n" + "\t\t\t Use perf report --latency for latency-centric profile."), OPT_CALLBACK_NOOPT(0, "exclude-perf", &record.evlist, NULL, "don't record events from perf itself", exclude_perf), @@ -4017,6 +4021,22 @@ int cmd_record(int argc, const char **argv) =20 } =20 + if (record.latency) { + /* + * There is no fundamental reason why latency profiling + * can't work for system-wide mode, but exact semantics + * and details are to be defined. + * See the following thread for details: + * https://lore.kernel.org/all/Z4XDJyvjiie3howF@google.com/ + */ + if (record.opts.target.system_wide) { + pr_err("Failed: latency profiling is not supported with system-wide col= lection.\n"); + err =3D -EINVAL; + goto out_opts; + } + record.opts.record_switch_events =3D true; + } + if (rec->buildid_mmap) { if (!perf_can_record_build_id()) { pr_err("Failed: no support to record build id in mmap events, update yo= ur kernel.\n"); diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 2a19abdc869a1..69de6dbefecfa 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -112,6 +112,8 @@ struct report { u64 nr_entries; u64 queue_size; u64 total_cycles; + u64 total_samples; + u64 singlethreaded_samples; int socket_filter; DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); struct branch_type_stat brtype_stat; @@ -331,6 +333,10 @@ static int process_sample_event(const struct perf_tool= *tool, &rep->total_cycles, evsel); } =20 + rep->total_samples++; + if (al.parallelism =3D=3D 1) + rep->singlethreaded_samples++; + ret =3D hist_entry_iter__add(&iter, &al, rep->max_stack, rep); if (ret < 0) pr_debug("problem adding hist entry, skipping event\n"); @@ -1079,6 +1085,11 @@ static int __cmd_report(struct report *rep) return ret; } =20 + /* Don't show Latency column for non-parallel profiles by default. */ + if (rep->singlethreaded_samples * 100 / rep->total_samples >=3D 99 && + !symbol_conf.prefer_latency) + perf_hpp__cancel_latency(); + evlist__check_mem_load_aux(session->evlist); =20 if (rep->stats_mode) @@ -1468,6 +1479,10 @@ int cmd_report(int argc, const char **argv) "Disable raw trace ordering"), OPT_BOOLEAN(0, "skip-empty", &report.skip_empty, "Do not display empty (or dummy) events in the output"), + OPT_BOOLEAN(0, "latency", &symbol_conf.prefer_latency, + "Show latency-centric profile rather than the default\n" + "\t\t\t CPU-consumption-centric profile\n" + "\t\t\t (requires perf record --latency flag)."), OPT_END() }; struct perf_data data =3D { @@ -1722,16 +1737,25 @@ int cmd_report(int argc, const char **argv) symbol_conf.annotate_data_sample =3D true; } =20 + symbol_conf.enable_latency =3D true; if (report.disable_order || !perf_session__has_switch_events(session)) { if (symbol_conf.parallelism_list_str || - (sort_order && strstr(sort_order, "parallelism")) || - (field_order && strstr(field_order, "parallelism"))) { + symbol_conf.prefer_latency || + (sort_order && (strstr(sort_order, "latency") || + strstr(sort_order, "parallelism"))) || + (field_order && (strstr(field_order, "latency") || + strstr(field_order, "parallelism")))) { if (report.disable_order) - ui__error("Use of parallelism is incompatible with --disable-order.\n"= ); + ui__error("Use of latency profile or parallelism is incompatible with = --disable-order.\n"); else - ui__error("Use of parallelism requires --switch-events during record.\= n"); + ui__error("Use of latency profile or parallelism requires --latency fl= ag during record.\n"); return -1; } + /* + * If user did not ask for anything related to + * latency/parallelism explicitly, just don't show it. + */ + symbol_conf.enable_latency =3D false; } =20 if (sort_order && strstr(sort_order, "ipc")) { diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 22e31d835301e..d87046052b432 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c @@ -632,27 +632,36 @@ void perf_hpp__init(void) return; =20 if (symbol_conf.cumulate_callchain) { - hpp_dimension__add_output(PERF_HPP__OVERHEAD_ACC); + /* Use idempotent addition to avoid more complex logic. */ + if (symbol_conf.prefer_latency) + hpp_dimension__add_output(PERF_HPP__LATENCY_ACC, true); + hpp_dimension__add_output(PERF_HPP__OVERHEAD_ACC, true); + if (symbol_conf.enable_latency) + hpp_dimension__add_output(PERF_HPP__LATENCY_ACC, true); perf_hpp__format[PERF_HPP__OVERHEAD].name =3D "Self"; } =20 - hpp_dimension__add_output(PERF_HPP__OVERHEAD); + if (symbol_conf.prefer_latency) + hpp_dimension__add_output(PERF_HPP__LATENCY, true); + hpp_dimension__add_output(PERF_HPP__OVERHEAD, true); + if (symbol_conf.enable_latency) + hpp_dimension__add_output(PERF_HPP__LATENCY, true); =20 if (symbol_conf.show_cpu_utilization) { - hpp_dimension__add_output(PERF_HPP__OVERHEAD_SYS); - hpp_dimension__add_output(PERF_HPP__OVERHEAD_US); + hpp_dimension__add_output(PERF_HPP__OVERHEAD_SYS, false); + hpp_dimension__add_output(PERF_HPP__OVERHEAD_US, false); =20 if (perf_guest) { - hpp_dimension__add_output(PERF_HPP__OVERHEAD_GUEST_SYS); - hpp_dimension__add_output(PERF_HPP__OVERHEAD_GUEST_US); + hpp_dimension__add_output(PERF_HPP__OVERHEAD_GUEST_SYS, false); + hpp_dimension__add_output(PERF_HPP__OVERHEAD_GUEST_US, false); } } =20 if (symbol_conf.show_nr_samples) - hpp_dimension__add_output(PERF_HPP__SAMPLES); + hpp_dimension__add_output(PERF_HPP__SAMPLES, false); =20 if (symbol_conf.show_total_period) - hpp_dimension__add_output(PERF_HPP__PERIOD); + hpp_dimension__add_output(PERF_HPP__PERIOD, false); } =20 void perf_hpp_list__column_register(struct perf_hpp_list *list, @@ -701,6 +710,22 @@ void perf_hpp__cancel_cumulate(void) } } =20 +void perf_hpp__cancel_latency(void) +{ + struct perf_hpp_fmt *fmt, *lat, *acc, *tmp; + + if (is_strict_order(field_order) || is_strict_order(sort_order)) + return; + + lat =3D &perf_hpp__format[PERF_HPP__LATENCY]; + acc =3D &perf_hpp__format[PERF_HPP__LATENCY_ACC]; + + perf_hpp_list__for_each_format_safe(&perf_hpp_list, fmt, tmp) { + if (fmt_equal(lat, fmt) || fmt_equal(acc, fmt)) + perf_hpp__column_unregister(fmt); + } +} + void perf_hpp__setup_output_field(struct perf_hpp_list *list) { struct perf_hpp_fmt *fmt; diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 91159f16c60b2..29d4c7a3d1747 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -582,6 +582,7 @@ enum { =20 void perf_hpp__init(void); void perf_hpp__cancel_cumulate(void); +void perf_hpp__cancel_latency(void); void perf_hpp__setup_output_field(struct perf_hpp_list *list); void perf_hpp__reset_output_field(struct perf_hpp_list *list); void perf_hpp__append_sort_keys(struct perf_hpp_list *list); diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index bc4c3acfe7552..2b6023de7a53a 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c @@ -2622,6 +2622,7 @@ struct hpp_dimension { const char *name; struct perf_hpp_fmt *fmt; int taken; + int was_taken; }; =20 #define DIM(d, n) { .name =3D n, .fmt =3D &perf_hpp__format[d], } @@ -3513,6 +3514,7 @@ static int __hpp_dimension__add(struct hpp_dimension = *hd, return -1; =20 hd->taken =3D 1; + hd->was_taken =3D 1; perf_hpp_list__register_sort_field(list, fmt); return 0; } @@ -3547,10 +3549,15 @@ static int __hpp_dimension__add_output(struct perf_= hpp_list *list, return 0; } =20 -int hpp_dimension__add_output(unsigned col) +int hpp_dimension__add_output(unsigned col, bool implicit) { + struct hpp_dimension *hd; + BUG_ON(col >=3D PERF_HPP__MAX_INDEX); - return __hpp_dimension__add_output(&perf_hpp_list, &hpp_sort_dimensions[c= ol]); + hd =3D &hpp_sort_dimensions[col]; + if (implicit && !hd->was_taken) + return 0; + return __hpp_dimension__add_output(&perf_hpp_list, hd); } =20 int sort_dimension__add(struct perf_hpp_list *list, const char *tok, @@ -3809,10 +3816,24 @@ static char *setup_overhead(char *keys) if (sort__mode =3D=3D SORT_MODE__DIFF) return keys; =20 - keys =3D prefix_if_not_in("overhead", keys); - - if (symbol_conf.cumulate_callchain) - keys =3D prefix_if_not_in("overhead_children", keys); + if (symbol_conf.prefer_latency) { + keys =3D prefix_if_not_in("overhead", keys); + keys =3D prefix_if_not_in("latency", keys); + if (symbol_conf.cumulate_callchain) { + keys =3D prefix_if_not_in("overhead_children", keys); + keys =3D prefix_if_not_in("latency_children", keys); + } + } else if (!keys || (!strstr(keys, "overhead") && + !strstr(keys, "latency"))) { + if (symbol_conf.enable_latency) + keys =3D prefix_if_not_in("latency", keys); + keys =3D prefix_if_not_in("overhead", keys); + if (symbol_conf.cumulate_callchain) { + if (symbol_conf.enable_latency) + keys =3D prefix_if_not_in("latency_children", keys); + keys =3D prefix_if_not_in("overhead_children", keys); + } + } =20 return keys; } diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 11fb15f914093..180d36a2bea35 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h @@ -141,7 +141,7 @@ int report_parse_ignore_callees_opt(const struct option= *opt, const char *arg, i =20 bool is_strict_order(const char *order); =20 -int hpp_dimension__add_output(unsigned col); +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, diff --git a/tools/perf/util/symbol_conf.h b/tools/perf/util/symbol_conf.h index c5b2e56127e22..cd9aa82c7d5ad 100644 --- a/tools/perf/util/symbol_conf.h +++ b/tools/perf/util/symbol_conf.h @@ -49,7 +49,9 @@ struct symbol_conf { keep_exited_threads, annotate_data_member, annotate_data_sample, - skip_empty; + skip_empty, + enable_latency, + prefer_latency; const char *vmlinux_name, *kallsyms_name, *source_prefix, --=20 2.48.1.262.g85cc9f2d1e-goog From nobody Thu Jan 30 19:14:12 2025 Received: from mail-ed1-f73.google.com (mail-ed1-f73.google.com [209.85.208.73]) (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 4AD501FDE04 for ; Mon, 27 Jan 2025 09:59:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737971975; cv=none; b=cNozydSd8woJdSR4YPB6a95gB6vFGIQIAFPE3EFyPqb/cYHhwBWl5w5BvBnVa9WsKikXKOemOWA4C3MM+3aUZ2CPSHww1zOCBg05+GhXLNplAF6gGiK+1yr0zOAf5uDx9HlZCvPJwPiAs8fOsdjF88IF5YTCU+l+WVRezwgKb5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737971975; c=relaxed/simple; bh=GggeSPiR8YbgLXP8wp9zrKxhR5MXY84YH0YwALVqOGA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mNYs89wHbGH+vuScnpyIjzXaRjgEU2LSE2aUlpFjrW5Oen+9khpUIUAm38vcW3YJ5MoA9vqfKreY2gNfdSzPyounseil0gYFDs2XTCcRQm4+JAHs70HBZ4lj+jFNrEoS0zomzQPlILwJJdT+mR/fKb3GW8m0T+X6/ZkbL3E3KY4= 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=s0yyDJ/O; arc=none smtp.client-ip=209.85.208.73 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="s0yyDJ/O" Received: by mail-ed1-f73.google.com with SMTP id 4fb4d7f45d1cf-5d3d9d6293fso3819035a12.0 for ; Mon, 27 Jan 2025 01:59:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1737971972; x=1738576772; 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=bL5cvZ53bMgUb5o74DP+LHGdAWU/IsbnP4gd/RMdofU=; b=s0yyDJ/O+ZAfts+n6mGQ+Uo5AFXsRvjXfgu33WTdAZPHR7uYCeWq9XygxC35P2LZfp fLEJazCB2wMbZta+NPgctS0BTdCfgWyNUA4CrwiOLyCwSH0b1+ZM0zAyWqvd4HV8EaX7 nDs0Sf7V0Ip/g5c7L7dUQaCTbBkAhL+LlvuhfIhDhGEM1/46QdtgH3k15Cx6LDp3ij/d 2+y/FTgkyPyN6JeAyztuwl36x94aXa/QfWdulG7DJaSlgXryJKNKHXgS6R5Is7oopmF7 WGrRLRQBTwWNefMXq6pUi4guI9kDPjFyPhVlzLWYausM8ucHOYfH5ohyL1oQ2OGvgTtX 1APw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737971972; x=1738576772; 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=bL5cvZ53bMgUb5o74DP+LHGdAWU/IsbnP4gd/RMdofU=; b=AqVJknoP/g3d49UiTdFAjg328m/Ici6zwJpp3TyEahU+yNkO9i8Aqmst1KKHRr/1Lz dcNCJNKmgWvrHTKp996WaQVyTOAcVZSS39LXIY9qD1nwK5bszVWufFqv49k/nCYHhHoW rvFZKT5q+xWNYYeG8gOVNkJD8WiCkRsw6/RG1XpMKSCkb9bahQfirAFqCC1ADD6M9nIJ bUt28gYxSw3/WLXq41ID6/6U7ye9CTcjuB7Om1zgKQgLcrjRgCmNw7wUV7QR6bwwnmA3 8V2RzQvHiZJYWphh5bms6kPmZZBvzwd5uqRiuDcSs4nnglrP9AFCJubeHaCKiL+aexWR C7Ig== X-Forwarded-Encrypted: i=1; AJvYcCXO1OS1bgCHCDboA7am0gPVqv7+83iBizeXyVfFjjfRLAKCShXxKezGiAOo41Tkh/a7yUIjx6Nw3tj00xY=@vger.kernel.org X-Gm-Message-State: AOJu0YwI9lTcEaKOqNZmfwmYxYNQEcpivUx/xmR6nhxJ/TeDrOqLkjMv FQZ/2xPrbxh38GR/kfntKQufjexJY+B5BKHSGCb7iblLiqWqps8Bcc9/FFCbqd2aah0niULx0GO EPvie7A== X-Google-Smtp-Source: AGHT+IEGmBHSZs/A63I7ECXvqOSG/Yu96vP2p77HqP1FtAxQ6jqD1LDPSViEIMqS3DYIXjKGTHKNaXRMzBlM X-Received: from edc7.prod.google.com ([2002:a05:6402:4607:b0:5d0:e889:c403]) (user=dvyukov job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6402:210c:b0:5d9:cde9:2b7f with SMTP id 4fb4d7f45d1cf-5db7d3550d5mr33152266a12.23.1737971971687; Mon, 27 Jan 2025 01:59:31 -0800 (PST) Date: Mon, 27 Jan 2025 10:58:54 +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.262.g85cc9f2d1e-goog Message-ID: Subject: [PATCH v3 7/7] perf report: Add latency and parallelism profiling documentation From: Dmitry Vyukov To: namhyung@kernel.org, irogers@google.com Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Vyukov , Arnaldo Carvalho de Melo Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Describe latency and parallelism profiling, related flags, and differences with the currently only supported CPU-consumption-centric profiling. 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 --- .../callchain-overhead-calculation.txt | 5 +- .../cpu-and-latency-overheads.txt | 85 +++++++++++++++++++ tools/perf/Documentation/perf-report.txt | 49 +++++++---- tools/perf/Documentation/tips.txt | 3 + 4 files changed, 123 insertions(+), 19 deletions(-) diff --git a/tools/perf/Documentation/callchain-overhead-calculation.txt b/= tools/perf/Documentation/callchain-overhead-calculation.txt index 1a757927195ed..e0202bf5bd1a0 100644 --- a/tools/perf/Documentation/callchain-overhead-calculation.txt +++ b/tools/perf/Documentation/callchain-overhead-calculation.txt @@ -1,7 +1,8 @@ Overhead calculation -------------------- -The overhead can be shown in two columns as 'Children' and 'Self' when -perf collects callchains. The 'self' overhead is simply calculated by +The CPU overhead can be shown in two columns as 'Children' and 'Self' +when perf collects callchains (and corresponding 'Wall' columns for +wall-clock overhead). The 'self' overhead is simply calculated by adding all period values of the entry - usually a function (symbol). This is the value that perf shows traditionally and sum of all the 'self' overhead values should be 100%. diff --git a/tools/perf/Documentation/cpu-and-latency-overheads.txt b/tools= /perf/Documentation/cpu-and-latency-overheads.txt new file mode 100644 index 0000000000000..3b6d637054651 --- /dev/null +++ b/tools/perf/Documentation/cpu-and-latency-overheads.txt @@ -0,0 +1,85 @@ +CPU and latency overheads +------------------------- +There are two notions of time: wall-clock time and CPU time. +For a single-threaded program, or a program running on a single-core machi= ne, +these notions are the same. However, for a multi-threaded/multi-process pr= ogram +running on a multi-core machine, these notions are significantly different. +Each second of wall-clock time we have number-of-cores seconds of CPU time. +Perf can measure overhead for both of these times (shown in 'overhead' and +'latency' columns for CPU and wall-clock time correspondingly). + +Optimizing CPU overhead is useful to improve 'throughput', while optimizing +latency overhead is useful to improve 'latency'. It's important to underst= and +which one is useful in a concrete situation at hand. For example, the form= er +may be useful to improve max throughput of a CI build server that runs on = 100% +CPU utilization, while the latter may be useful to improve user-perceived +latency of a single interactive program build. +These overheads may be significantly different in some cases. For example, +consider a program that executes function 'foo' for 9 seconds with 1 threa= d, +and then executes function 'bar' for 1 second with 128 threads (consumes +128 seconds of CPU time). The CPU overhead is: 'foo' - 6.6%, 'bar' - 93.4%. +While the latency overhead is: 'foo' - 90%, 'bar' - 10%. If we try to opti= mize +running time of the program looking at the (wrong in this case) CPU overhe= ad, +we would concentrate on the function 'bar', but it can yield only 10% runn= ing +time improvement at best. + +By default, perf shows only CPU overhead. To show latency overhead, use +'perf record --latency' and 'perf report': + +----------------------------------- +Overhead Latency Command + 93.88% 25.79% cc1 + 1.90% 39.87% gzip + 0.99% 10.16% dpkg-deb + 0.57% 1.00% as + 0.40% 0.46% sh +----------------------------------- + +To sort by latency overhead, use 'perf report --latency': + +----------------------------------- +Latency Overhead Command + 39.87% 1.90% gzip + 25.79% 93.88% cc1 + 10.16% 0.99% dpkg-deb + 4.17% 0.29% git + 2.81% 0.11% objtool +----------------------------------- + +To get insight into the difference between the overheads, you may check +parallelization histogram with '--sort=3Dlatency,parallelism,comm,symbol -= -hierarchy' +flags. It shows fraction of (wall-clock) time the workload utilizes differ= ent +numbers of cores ('Parallelism' column). For example, in the following case +the workload utilizes only 1 core most of the time, but also has some +highly-parallel phases, which explains significant difference between +CPU and wall-clock overheads: + +----------------------------------- + Latency Overhead Parallelism / Command / Symbol ++ 56.98% 2.29% 1 ++ 16.94% 1.36% 2 ++ 4.00% 20.13% 125 ++ 3.66% 18.25% 124 ++ 3.48% 17.66% 126 ++ 3.26% 0.39% 3 ++ 2.61% 12.93% 123 +----------------------------------- + +By expanding corresponding lines, you may see what commands/functions run +at the given parallelism level: + +----------------------------------- + Latency Overhead Parallelism / Command / Symbol +- 56.98% 2.29% 1 + 32.80% 1.32% gzip + 4.46% 0.18% cc1 + 2.81% 0.11% objtool + 2.43% 0.10% dpkg-source + 2.22% 0.09% ld + 2.10% 0.08% dpkg-genchanges +----------------------------------- + +To see the normal function-level profile for particular parallelism levels +(number of threads actively running on CPUs), you may use '--parallelism' +filter. For example, to see the profile only for low parallelism phases +of a workload use '--latency --parallelism=3D1-2' flags. diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Document= ation/perf-report.txt index 87f8645194062..7e0ba990d71e8 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt @@ -44,7 +44,7 @@ OPTIONS --comms=3D:: Only consider symbols in these comms. CSV that understands file://filename entries. This option will affect the percentage of - the overhead column. See --percentage for more info. + the overhead and latency columns. See --percentage for more info. --pid=3D:: Only show events for given process ID (comma separated list). =20 @@ -54,12 +54,12 @@ OPTIONS --dsos=3D:: Only consider symbols in these dsos. CSV that understands file://filename entries. This option will affect the percentage of - the overhead column. See --percentage for more info. + the overhead and latency columns. See --percentage for more info. -S:: --symbols=3D:: Only consider these symbols. CSV that understands file://filename entries. This option will affect the percentage of - the overhead column. See --percentage for more info. + the overhead and latency columns. See --percentage for more info. =20 --symbol-filter=3D:: Only show symbols that match (partially) with this filter. @@ -68,6 +68,16 @@ OPTIONS --hide-unresolved:: Only display entries resolved to a symbol. =20 +--parallelism:: + Only consider these parallelism levels. Parallelism level is the n= umber + of threads that actively run on CPUs at the time of sample. The fl= ag + accepts single number, comma-separated list, and ranges (for examp= le: + "1", "7,8", "1,64-128"). This is useful in understanding what a pr= ogram + is doing during sequential/low-parallelism phases as compared to + high-parallelism phases. This option will affect the percentage of + the overhead and latency columns. See --percentage for more info. + Also see the `CPU and latency overheads' section for more details. + -s:: --sort=3D:: Sort histogram entries by given key(s) - multiple keys can be specified @@ -87,6 +97,7 @@ OPTIONS entries are displayed as "[other]". - cpu: cpu number the task ran at the time of sample - socket: processor socket number the task ran at the time of sample + - parallelism: number of running threads at the time of sample - srcline: filename and line number executed at the time of sample. The DWARF debugging info must be provided. - srcfile: file name of the source file of the samples. Requires dwarf @@ -97,12 +108,14 @@ OPTIONS - cgroup_id: ID derived from cgroup namespace device and inode numbers. - cgroup: cgroup pathname in the cgroupfs. - transaction: Transaction abort flags. - - overhead: Overhead percentage of sample - - overhead_sys: Overhead percentage of sample running in system mode - - overhead_us: Overhead percentage of sample running in user mode - - overhead_guest_sys: Overhead percentage of sample running in system mode + - overhead: CPU overhead percentage of sample. + - latency: latency (wall-clock) overhead percentage of sample. + See the `CPU and latency overheads' section for more details. + - overhead_sys: CPU overhead percentage of sample running in system mode + - overhead_us: CPU overhead percentage of sample running in user mode + - overhead_guest_sys: CPU overhead percentage of sample running in system= mode on guest machine - - overhead_guest_us: Overhead percentage of sample running in user mode on + - overhead_guest_us: CPU overhead percentage of sample running in user mo= de on guest machine - sample: Number of sample - period: Raw number of event count of sample @@ -125,8 +138,8 @@ OPTIONS - weight2: Average value of event specific weight (2nd field of weight_st= ruct). - weight3: Average value of event specific weight (3rd field of weight_st= ruct). =20 - By default, comm, dso and symbol keys are used. - (i.e. --sort comm,dso,symbol) + By default, overhead, comm, dso and symbol keys are used. + (i.e. --sort overhead,comm,dso,symbol). =20 If --branch-stack option is used, following sort keys are also available: @@ -201,9 +214,9 @@ OPTIONS --fields=3D:: Specify output field - multiple keys can be specified in CSV format. Following fields are available: - overhead, overhead_sys, overhead_us, overhead_children, sample, period, - weight1, weight2, weight3, ins_lat, p_stage_cyc and retire_lat. The - last 3 names are alias for the corresponding weights. When the weight + overhead, latency, overhead_sys, overhead_us, overhead_children, sample, + period, weight1, weight2, weight3, ins_lat, p_stage_cyc and retire_lat. + The last 3 names are alias for the corresponding weights. When the weight fields are used, they will show the average value of the weight. =20 Also it can contain any sort key(s). @@ -289,7 +302,7 @@ OPTIONS Accumulate callchain of children to parent entry so that then can show up in the output. The output will have a new "Children" column and will be sorted on the data. It requires callchains are recorded. - See the `overhead calculation' section for more details. Enabled by + See the `Overhead calculation' section for more details. Enabled by default, disable with --no-children. =20 --max-stack:: @@ -442,9 +455,9 @@ OPTIONS --call-graph option for details. =20 --percentage:: - Determine how to display the overhead percentage of filtered entries. - Filters can be applied by --comms, --dsos and/or --symbols options and - Zoom operations on the TUI (thread, dso, etc). + Determine how to display the CPU and latency overhead percentage + of filtered entries. Filters can be applied by --comms, --dsos, --symbols + and/or --parallelism options and Zoom operations on the TUI (thread, dso,= etc). =20 "relative" means it's relative to filtered entries only so that the sum of shown entries will be always 100%. "absolute" means it retains @@ -627,6 +640,8 @@ include::itrace.txt[] --skip-empty:: Do not print 0 results in the --stat output. =20 +include::cpu-and-latency-overheads.txt[] + include::callchain-overhead-calculation.txt[] =20 SEE ALSO diff --git a/tools/perf/Documentation/tips.txt b/tools/perf/Documentation/t= ips.txt index 67b326ba00407..f6f71e70ff2cb 100644 --- a/tools/perf/Documentation/tips.txt +++ b/tools/perf/Documentation/tips.txt @@ -62,3 +62,6 @@ To show context switches in perf report sample context ad= d --switch-events to pe To show time in nanoseconds in record/report add --ns To compare hot regions in two workloads use perf record -b -o file ... ; p= erf diff --stream file1 file2 To compare scalability of two workload samples use perf diff -c ratio file= 1 file2 +For latency profiling, try: perf record/report --latency +For parallelism histogram, try: perf report --hierarchy --sort latency,par= allelism,comm,symbol +To analyze particular parallelism levels, try: perf report --latency --par= allelism=3D32-64 --=20 2.48.1.262.g85cc9f2d1e-goog