public inbox for driver-core@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH v1 0/2] *** Support BPF traversal of wakeup sources ***
@ 2026-03-20 16:00 Samuel Wu
  2026-03-20 16:00 ` [PATCH v1 1/2] PM: wakeup: Add kfuncs to lock/unlock wakeup_sources Samuel Wu
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Samuel Wu @ 2026-03-20 16:00 UTC (permalink / raw)
  To: Rafael J. Wysocki, Pavel Machek, Len Brown, Greg Kroah-Hartman,
	Danilo Krummrich
  Cc: andrii, memxor, bpf, Samuel Wu, kernel-team, linux-pm,
	driver-core, linux-kernel

This patchset adds requisite kfuncs for BPF programs to safely traverse
wakeup_sources, and puts a config flag around the sysfs interface.

Currently, a traversal of wakeup sources require going through
/sys/class/wakeup/* or /d/wakeup_sources/*. The repeated syscalls to query
sysfs is inefficient, as there can be hundreds of wakeup_sources, with each
wakeup source also having multiple attributes. debugfs is unstable and
insecure.

Adding kfuncs to lock/unlock wakeup sources allows BPF program to safely
traverse the wakeup sources list. The head address of wakeup_sources can
safely be resolved through BPF helper functions or variable attributes.

On a quiescent Pixel 6 traversing 150 wakeup_sources, I am seeing ~34x
speedup (sampled 75 times in table below). For a device under load, the
speedup is greater.
+-------+----+----------+----------+
|       | n  | AVG (ms) | STD (ms) |
+-------+----+----------+----------+
| sysfs | 75 | 44.9     | 12.6     |
+-------+----+----------+----------+
| BPF   | 75 | 1.3      | 0.7      |
+-------+----+----------+----------+

On the memory side, between kernfs, dentry, and kmalloc, each wakeup source
removed from sysfs saves at least 10kB.

The initial attempts for BPF traversal of wakeup_sources was with BPF
iterators [1]. However, BPF already allows for traversing of a simple list
with bpf_for(), and this current patchset has the added benefit of being
~2-3x more performant than BPF iterators.

[1]: https://lore.kernel.org/all/20260225210820.177674-1-wusamuel@google.com/

Samuel Wu (2):
  PM: wakeup: Add kfuncs to lock/unlock wakeup_sources
  PM: Add config flag to gate sysfs wakeup_sources

 drivers/base/power/Makefile |  3 +-
 drivers/base/power/power.h  | 14 +++++++++
 drivers/base/power/wakeup.c | 63 +++++++++++++++++++++++++++++++++++--
 kernel/power/Kconfig        | 13 ++++++++
 4 files changed, 90 insertions(+), 3 deletions(-)

-- 
2.53.0.959.g497ff81fa9-goog


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

end of thread, other threads:[~2026-03-23 16:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-20 16:00 [PATCH v1 0/2] *** Support BPF traversal of wakeup sources *** Samuel Wu
2026-03-20 16:00 ` [PATCH v1 1/2] PM: wakeup: Add kfuncs to lock/unlock wakeup_sources Samuel Wu
2026-03-23 12:33   ` kernel test robot
2026-03-20 16:00 ` [PATCH v1 2/2] PM: Add config flag to gate sysfs wakeup_sources Samuel Wu
2026-03-20 16:09   ` Rafael J. Wysocki
2026-03-21  0:46     ` Samuel Wu
2026-03-21 17:51 ` [PATCH v1 0/2] *** Support BPF traversal of wakeup sources *** Kumar Kartikeya Dwivedi
2026-03-23 16:20   ` Samuel Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox