All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] perf tool_pmu: Add procfs memory, network and schedstat events
@ 2026-11-13 23:37 Ian Rogers
  2026-11-13 23:37 ` [PATCH v2 1/4] perf tool_pmu: Add memory events Ian Rogers
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Ian Rogers @ 2026-11-13 23:37 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Jiri Olsa, Ian Rogers, Adrian Hunter, James Clark,
	Thomas Falcon, Thomas Richter, linux-perf-users, linux-kernel
  Cc: Andi Kleen

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


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-11-14  0:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13 23:37 [PATCH v2 0/4] perf tool_pmu: Add procfs memory, network and schedstat events Ian Rogers
2026-11-13 23:37 ` [PATCH v2 1/4] perf tool_pmu: Add memory events Ian Rogers
2026-11-14  0:05   ` sashiko-bot
2026-11-13 23:37 ` [PATCH v2 2/4] perf tool_pmu: Add network events Ian Rogers
2026-11-13 23:59   ` sashiko-bot
2026-11-13 23:37 ` [PATCH v2 3/4] perf tool_pmu: Add schedstat events Ian Rogers
2026-11-13 23:51   ` sashiko-bot
2026-11-13 23:37 ` [PATCH v2 4/4] perf test tool_pmu: Add memory, network and schedstat tests Ian Rogers
2026-11-13 23:45   ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.