[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260124012133.2451708-1-wusamuel@google.com>
Date: Fri, 23 Jan 2026 17:21:28 -0800
From: Samuel Wu <wusamuel@...gle.com>
To: "Rafael J. Wysocki" <rafael@...nel.org>, Len Brown <lenb@...nel.org>, Pavel Machek <pavel@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Danilo Krummrich <dakr@...nel.org>,
Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>, Martin KaFai Lau <martin.lau@...ux.dev>,
Eduard Zingerman <eddyz87@...il.com>, Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>, John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>, Shuah Khan <shuah@...nel.org>
Cc: Samuel Wu <wusamuel@...gle.com>, kernel-team@...roid.com,
linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org, bpf@...r.kernel.org,
linux-kselftest@...r.kernel.org
Subject: [PATCH bpf-next v3 0/3] Add wakeup_source iterators
This patch series introduces BPF iterators for wakeup_source, enabling
BPF programs to efficiently traverse a device's wakeup sources.
Currently, inspecting wakeup sources typically involves reading interfaces
like /sys/class/wakeup/* or debugfs. The repeated syscalls to query the
sysfs nodes is inefficient, as there can be hundreds of wakeup_sources, and
each wakeup source have multiple stats, with one sysfs node per stat.
debugfs is unstable and insecure.
The iterators utilize pre-existing wakeup_sources_walk_* functions to
traverse over the SRCU that backs the list of wakeup_sources.
Changes in v3:
- Update wakeup_sources_walk_start() to handle an empty list per bpf-ci
- Simplify read of a struct's field in BPF program selftest per Andrii
- Drop open coded iterators for wakeup_sources
- Fix condition from !get_ws_iter_stream to get_ws_iter_stream in selftest
- Read event_count instead of wakeup_count in selftest
- v2 link: https://lore.kernel.org/all/20260108225523.3268383-1-wusamuel@google.com/
Changes in v2:
- Guard BPF Makefile with CONFIG_PM_SLEEP to fix build errors
- Update copyright from 2025 to 2026
- v1 link: https://lore.kernel.org/all/20251204025003.3162056-1-wusamuel@google.com/
Samuel Wu (3):
PM: wakeup: Handle empty list in wakeup_sources_walk
bpf: Add wakeup_source iterator
selftests/bpf: Add tests for wakeup_sources
drivers/base/power/wakeup.c | 4 +-
kernel/bpf/Makefile | 3 +
kernel/bpf/wakeup_source_iter.c | 103 +++++++
tools/testing/selftests/bpf/config | 1 +
.../bpf/prog_tests/wakeup_source_iter.c | 281 ++++++++++++++++++
.../selftests/bpf/progs/wakeup_source_iter.c | 60 ++++
6 files changed, 449 insertions(+), 3 deletions(-)
create mode 100644 kernel/bpf/wakeup_source_iter.c
create mode 100644 tools/testing/selftests/bpf/prog_tests/wakeup_source_iter.c
create mode 100644 tools/testing/selftests/bpf/progs/wakeup_source_iter.c
--
2.52.0.457.g6b5491de43-goog
Powered by blists - more mailing lists