From: Samuel Wu <wusamuel@google.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Pavel Machek <pavel@kernel.org>, Len Brown <lenb@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Danilo Krummrich <dakr@kernel.org>
Cc: andrii@kernel.org, memxor@gmail.com, bpf@vger.kernel.org,
Samuel Wu <wusamuel@google.com>,
kernel-team@android.com, linux-pm@vger.kernel.org,
driver-core@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH v1 2/2] PM: Add config flag to gate sysfs wakeup_sources
Date: Fri, 20 Mar 2026 09:00:54 -0700 [thread overview]
Message-ID: <20260320160055.4114055-3-wusamuel@google.com> (raw)
In-Reply-To: <20260320160055.4114055-1-wusamuel@google.com>
Add a config flag that gates the creation of
/sys/class/wakeup_sources/*. This has the benefit of eliminating the
work needed to create the nodes and corresponding attributes; and
between kernfs, dentry, and malloc, there are some memory savings
depending on the number of wakeup sources.
Signed-off-by: Samuel Wu <wusamuel@google.com>
---
drivers/base/power/Makefile | 3 ++-
drivers/base/power/power.h | 14 ++++++++++++++
kernel/power/Kconfig | 13 +++++++++++++
3 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/drivers/base/power/Makefile b/drivers/base/power/Makefile
index 2989e42d0161..5933dadc0dd9 100644
--- a/drivers/base/power/Makefile
+++ b/drivers/base/power/Makefile
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_PM) += sysfs.o generic_ops.o common.o qos.o runtime.o wakeirq.o
-obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o wakeup_stats.o
+obj-$(CONFIG_PM_SLEEP) += main.o wakeup.o
+obj-$(CONFIG_PM_WAKEUP_STATS_SYSFS) += wakeup_stats.o
obj-$(CONFIG_PM_TRACE_RTC) += trace.o
obj-$(CONFIG_HAVE_CLK) += clock_ops.o
obj-$(CONFIG_PM_QOS_KUNIT_TEST) += qos-test.o
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index 922ed457db19..364ca5512b4f 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -125,11 +125,25 @@ static inline bool device_pm_initialized(struct device *dev)
}
/* drivers/base/power/wakeup_stats.c */
+#ifdef CONFIG_PM_WAKEUP_STATS_SYSFS
extern int wakeup_source_sysfs_add(struct device *parent,
struct wakeup_source *ws);
extern void wakeup_source_sysfs_remove(struct wakeup_source *ws);
extern int pm_wakeup_source_sysfs_add(struct device *parent);
+#else /* !CONFIG_PM_WAKEUP_STATS_SYSFS */
+static inline int wakeup_source_sysfs_add(struct device *parent,
+ struct wakeup_source *ws)
+{
+ return 0;
+}
+static inline void wakeup_source_sysfs_remove(struct wakeup_source *ws) {}
+
+static inline int pm_wakeup_source_sysfs_add(struct device *parent)
+{
+ return 0;
+}
+#endif /* !CONFIG_PM_WAKEUP_STATS_SYSFS */
#else /* !CONFIG_PM_SLEEP */
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index 05337f437cca..6945083ab053 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -202,6 +202,19 @@ config PM_WAKELOCKS_GC
depends on PM_WAKELOCKS
default y
+config PM_WAKEUP_STATS_SYSFS
+ bool "Sysfs wakeup statistics"
+ depends on PM_SLEEP
+ default y
+ help
+ Enable this for wakeup statistics in sysfs under /sys/class/wakeup/
+
+ Disabling this option eliminates the work of creating the wakeup
+ sources and each of their attributes in sysfs. Depending on the
+ number of wakeup sources, this can also have a non-negligible memory
+ impact. Regardless of this config option's value, wakeup statistics
+ are still available via debugfs and BPF.
+
config PM_QOS_CPU_SYSTEM_WAKEUP
bool "User space interface for CPU system wakeup QoS"
depends on CPU_IDLE
--
2.53.0.959.g497ff81fa9-goog
next prev parent reply other threads:[~2026-03-20 16:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Samuel Wu [this message]
2026-03-20 16:09 ` [PATCH v1 2/2] PM: Add config flag to gate sysfs wakeup_sources 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
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=20260320160055.4114055-3-wusamuel@google.com \
--to=wusamuel@google.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-team@android.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=memxor@gmail.com \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
/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