mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ian Rogers <irogers@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	 Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
	 Ian Rogers <irogers@google.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	 James Clark <james.clark@linaro.org>,
	Thomas Falcon <thomas.falcon@intel.com>,
	 Thomas Richter <tmricht@linux.ibm.com>,
	linux-perf-users@vger.kernel.org,  linux-kernel@vger.kernel.org
Cc: Andi Kleen <ak@linux.intel.com>
Subject: [PATCH v2 0/4] perf tool_pmu: Add procfs memory, network and schedstat events
Date: Fri, 13 Nov 2026 15:37:35 -0800	[thread overview]
Message-ID: <20261113233739.3626499-1-irogers@google.com> (raw)

Add tool PMU events for memory usage, network activity, and scheduler
runqueue statistics based on procfs data in /proc/<pid>/statm,
/proc/<pid>/smaps_rollup, /proc/net/dev, and /proc/schedstat:

- Patch 1 adds 26 memory_* events (such as memory_rss, memory_pss,
  memory_uss, memory_size, memory_swap) aggregated across processes in
  system-wide mode or read per-process. Per-process mode holds a
  /proc/<pid> directory descriptor and opens statm/smaps_rollup on each
  read (observing post-exec address spaces without PID-reuse races),
  deduplicates sibling threads sharing a Tgid, and falls back to wait4
  rusage ru_maxrss for memory_rss when a forked workload has already
  exited.
- Patch 2 adds 16 system-wide net_rx_* and net_tx_* events from
  /proc/net/dev, tracking deltas across enable/disable transitions and
  handling mixed CPU-map event groups safely. Per-process and cgroup
  modes are rejected with -EINVAL since /proc/<pid>/net/dev reports
  statistics for the entire network namespace rather than an individual
  process.
- Patch 3 adds 8 per-CPU schedstat_* events from /proc/schedstat,
  tracking per-CPU deltas across enable/disable transitions.
- Patch 4 extends the 'Tool PMU' unit test suite with tests for memory
  events (including multi-threaded Tgid deduplication), network events,
  schedstat events, and mixed CPU-map tool groups.

Because these events are exposed on tool_pmu with JSON descriptions,
they can be used in metrics, listed via 'perf list', and inspected in
the Python ilist application.

This series was developed and reviewed with assistance from an AI coding
agent (Gemini 3.1 Pro) and reviewed with Sashiko.

v2:
  - Rebase onto perf-tools-next (adapting to reads_only_on_cpu_idx0 and
    tool_pmu enable/disable support).
  - Restrict net_* events to system-wide mode (-EINVAL on per-process or
    cgroup open) and report deltas over the enabled interval rather than
    cumulative boot totals (Namhyung Kim).
  - Fix unpadded /proc/net/dev column parsing after ':' and fix memory
    unit scaling and statm field offsets.
  - Open /proc/<pid> with O_DIRECTORY for per-process memory_* events so
    post-exec mm_struct changes are observed, deduplicate threads sharing
    a Tgid, and refine the wait4 ru_maxrss fallback for memory_rss.
  - Handle non-leader attr.disabled and mismatched CPU maps when single-
    CPU and per-CPU tool events are grouped.
  - Add per-CPU schedstat_* tool PMU events and 'Tool PMU' unit tests.

v1: https://lore.kernel.org/linux-perf-users/20260104011738.475680-1-irogers@google.com/

Ian Rogers (4):
  perf tool_pmu: Add memory events
  perf tool_pmu: Add network events
  perf tool_pmu: Add schedstat events
  perf test tool_pmu: Add memory, network and schedstat tests

 tools/perf/builtin-stat.c                     |  81 +-
 .../pmu-events/arch/common/common/tool.json   | 300 ++++++
 tools/perf/pmu-events/empty-pmu-events.c      | 422 +++++---
 tools/perf/tests/tool_pmu.c                   | 689 +++++++++++++
 tools/perf/util/evsel.c                       |  53 +-
 tools/perf/util/pmu.c                         |   4 +-
 tools/perf/util/stat-display.c                |   8 +-
 tools/perf/util/tool_pmu.c                    | 916 ++++++++++++++++--
 tools/perf/util/tool_pmu.h                    |  52 +
 9 files changed, 2316 insertions(+), 209 deletions(-)

-- 
2.56.1.703.gf848ed807c-goog


             reply	other threads:[~2026-11-13 23:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 23:37 Ian Rogers [this message]
2026-11-13 23:37 ` [PATCH v2 1/4] perf tool_pmu: Add memory events Ian Rogers
2026-11-13 23:37 ` [PATCH v2 2/4] perf tool_pmu: Add network events Ian Rogers
2026-11-13 23:37 ` [PATCH v2 3/4] perf tool_pmu: Add schedstat events Ian Rogers
2026-11-13 23:37 ` [PATCH v2 4/4] perf test tool_pmu: Add memory, network and schedstat tests Ian Rogers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261113233739.3626499-1-irogers@google.com \
    --to=irogers@google.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=thomas.falcon@intel.com \
    --cc=tmricht@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®