From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f202.google.com (mail-dy1-f202.google.com [74.125.82.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CED752D0610 for ; Fri, 20 Mar 2026 16:01:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774022476; cv=none; b=TrII5c89X/yS7RCHA+9Pf/K6EvkYPQm+jNnLxz67D1QXIlphSdLMfpgRNvIxipZMv8eaz1S43s5BsOSRtVlm5d8ni0MKM9JW457Q6L2KL/zYMSA9I/4iOuW/cigINN9JjW+acZLpmZjjFkNRMaZdPiNYGG/ZVvVyhHMI6VCVKFo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774022476; c=relaxed/simple; bh=VvDq6lbA0+MBNpru3nhz56fcZsBSYOu1Jq1hxe+kZqk=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=HfnMgkQEJtaAFH7pCD/xvtTSRs1MO9a9TBIHDCIzPpXWTo+qG1XjPmmeZo+MrTWkgnvUDMP77mRIRYjJRfqjpOdL81z/wE7E2lBD3ew/ZW9ycg7OBsC8uRuDjRYcTeQ6Ms0k5bFhQcrE48qYtBtpWy7SJ+Hjts9Q7ifAMxFKwFM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--wusamuel.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=p5ZA8cTc; arc=none smtp.client-ip=74.125.82.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--wusamuel.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="p5ZA8cTc" Received: by mail-dy1-f202.google.com with SMTP id 5a478bee46e88-2c109ba1296so19854446eec.1 for ; Fri, 20 Mar 2026 09:01:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1774022474; x=1774627274; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=mMm4wBnmSeubt2uXZ01V3PsbZvesaIurFwFXvpVAv2s=; b=p5ZA8cTcBkGTqaSrKbX00Vv7Esrp8U1C7LIgV/4rKgpvLbrNolt39ZWtQ/dHnrwK7i /xwY2RqfoBDDx3RMOgI3x1oROAteWPnzPNeqTpwcAOaIiMMAHuDdqItU4FgAkYcHCOzk p36i1D8JLQGNlRu7z08GNm1oV2R6MGltjuQ7NZmxL1wniqGD+LckzVog0f0jaQJ+HGeW wZ5ULKAT5flTAuQoi3e4T8kSPlx2XQC6E0WvHkTOvK7IfRm5kLhV92CS4vcZEc45CGoD 5lDd9pBMZYLbdoAuiSnL43BekYoqfHTaI6e6nR/ISouk4dv3ua/n4HDnWXuOs8/vvXp6 /P1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774022474; x=1774627274; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=mMm4wBnmSeubt2uXZ01V3PsbZvesaIurFwFXvpVAv2s=; b=SkI9/vOUrvZl47Ar6jQPdUhP1D4TBELN33dx8pNH0Wg5rqlHY84yqTiMLWeKCnys1f B8gCOpNYV9iUAfZVpd9CeLqM8OZKj+oB/EC4DRdm4M3Us6UxlXkdKe1ryMfi4JppE8pB qebhkj1jIfauJ5fIv6wZzYxuoMNIKDIyvPm+86c6df2zNqaSyvACf4RVM3y4WrxDyhm7 XQfmN9U8SLYdcVmA/EMwmurG8Cvr21FwZPvvwOfF4KoU9rUh3wab46xTvviEuN7WiwPh 5b5ESrVuyTzRJMt1uNfXoI2QbyDRvJ/NjJ6SI7J60ALLfdXD1gFCk2AMjlhlhhrjwS95 RYfw== X-Forwarded-Encrypted: i=1; AJvYcCVAwaHtslwnJzHJ3wG5DR2+7HWXmMd0Al24OcS0D0ng9gX3qT1c52d38/n6wKVhFqe4FeXTdv1mjhJZiMo=@vger.kernel.org X-Gm-Message-State: AOJu0Yzw/Pin/odOAIncbixJ3PgnXccdEoTcD55SrwcJY6bwpIlxCRol QfU9HF3LT7Iv4TQiVBr4Hzdhc63D6M/eKscYo4kV1Su1rgQLSFmYOx52uHVmkmrg6IMvPCa/OeH mSyLnUfElAUEWig== X-Received: from dybia20.prod.google.com ([2002:a05:7301:314:b0:2c0:f494:8a43]) (user=wusamuel job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:9f0c:b0:2b8:4c95:365d with SMTP id 5a478bee46e88-2c1095f54afmr1848097eec.10.1774022473627; Fri, 20 Mar 2026 09:01:13 -0700 (PDT) Date: Fri, 20 Mar 2026 09:00:52 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.53.0.959.g497ff81fa9-goog Message-ID: <20260320160055.4114055-1-wusamuel@google.com> Subject: [PATCH v1 0/2] *** Support BPF traversal of wakeup sources *** From: Samuel Wu To: "Rafael J. Wysocki" , Pavel Machek , Len Brown , Greg Kroah-Hartman , Danilo Krummrich Cc: andrii@kernel.org, memxor@gmail.com, bpf@vger.kernel.org, Samuel Wu , kernel-team@android.com, linux-pm@vger.kernel.org, driver-core@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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