From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f201.google.com (mail-dy1-f201.google.com [74.125.82.201]) (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 B9A273328E2 for ; Thu, 8 Jan 2026 22:56:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767913002; cv=none; b=bwViF9P+7U2LkJ+ORZKnwK4mv/gx6Q4bspFAGIpwsxm9LgExdNIkfmN1oOV+Jo6BvhA4tsCD0xs0j6elGv4F+W7JIIr0VELFxu243RsjCy/z4PwzAhGo9Nni4HkfVc/zK0dKHPFjp5DR+zoJOZpdENKWPKCWWFg7rdoxjK2Izq0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767913002; c=relaxed/simple; bh=F5rLUx30ihLzNCsKKK+9lJkThou5C7DJgWMvbfY/DVU=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=jTNCRVCQUsiahh0dY700LJSgniEFXwYiZMN+bEqhvuLqwnXZZIkwsnG8ynSAF5gIXTSRITti0zAkZq3BcrRgmRplbj1QZI1O6pgS0StZJbFh5xLCCe1ZSCZ/x+CuNLAkya1idPgWWjBL7VRYgvRGFVdPql5rtl13oavKeUaGFl0= 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=nuML2+Cz; arc=none smtp.client-ip=74.125.82.201 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="nuML2+Cz" Received: by mail-dy1-f201.google.com with SMTP id 5a478bee46e88-2b062c1aa44so4893525eec.0 for ; Thu, 08 Jan 2026 14:56:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1767912999; x=1768517799; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=c2rtpYcP3DAOdbt732zx7+jr91irIrA8WZ/Xzq8bqJI=; b=nuML2+CzD8lZ59v+NlefqhkF62fgQVTjiCsFeX4C+04Q8OkeijSkXubPps9St/hUJL PdtqY4NKyzFDeffPq+OgkxVVBDIhgRElu57RCO0Q81IJahkjg0hyWu2lqeIcn4MvALpW I73O5vBe3Hwdk1gDISo5gPVBz+FcV8rJseyZZSvcmkh8gssRA11JhPbE331n91L3pn3N 4SaponmL8zC7racmgAeKOIquQCHJWSSS8bzGGvRbOQatztvIyPKmSJFFQY9K7xY5Ruzj oKfCGq71t5evjS6AVWtTAPMwIH/PuODp8waf/iFMnm3BAr+E56xtx8yAezW8f36n52wv 420g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767912999; x=1768517799; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=c2rtpYcP3DAOdbt732zx7+jr91irIrA8WZ/Xzq8bqJI=; b=JPaqyOIN50JXvbM/5utcie3mpnLeZzPBc5MwpZ8O8svJ5ULNkqkJNSprbF3K8ZKPIY /qMytUtIXG1kU4HkiKzbEjvM1kSOzuwaa7FHkzR7plLoFmYaZm9tLAULODcGbbQTYlvp E5G2h/cfx/BnU/aBJ0U6hQ2kXczbSOKGPWufpKNwGjkoOGSA5Ieqx2LK275O+cm2gJ8d tPMY97EHU1mmNZeOLVVf0JVpsMNblNk/qBYCJxzEEHTJEpL/bHh9OFBCM0kczcu6NF9o wbD/t9eqv63GgeZp7AqFC1+fIirK8eqQC+dYilVvMeEZRCloOMhfuMGJ45o1dyCOJ2qJ 0N6g== X-Forwarded-Encrypted: i=1; AJvYcCXB9PK6mYHqUql7vfAGuKdWFQsHYVAtyOfPh9S/XaPisDJwHyowLu9BSrgKib4baeNORnc/NkETRk0nTLY=@vger.kernel.org X-Gm-Message-State: AOJu0YybE2oOJ7gOW4IAL8Q+w7NURsGheNUIceLjyO0Eel23NK/LOtYb MTFFvYs4ZZfrjH+8eGxWKo9Ik7tuPoH//Zy5zQc2Hb3yWrbsSIFDalTZwfRILMbMQk1bvRV3vTt TprOk/zrLy6P1rA== X-Google-Smtp-Source: AGHT+IEPMqVeidF/HQfzF5blhVJjcK7ooy1GXBw2OmQH8gfNq2+feiN8Uwq5zuBT5zWfoWRHgipKuLoi2G0jtA== X-Received: from dyew16.prod.google.com ([2002:a05:7300:4350:b0:2b0:4f93:391f]) (user=wusamuel job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:2093:b0:2b0:52ac:92fe with SMTP id 5a478bee46e88-2b17d2ba856mr5980637eec.21.1767912998679; Thu, 08 Jan 2026 14:56:38 -0800 (PST) Date: Thu, 8 Jan 2026 14:55:17 -0800 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.52.0.457.g6b5491de43-goog Message-ID: <20260108225523.3268383-1-wusamuel@google.com> Subject: [PATCH bpf-next v2 0/4] Add wakeup_source iterators From: Samuel Wu To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: Samuel Wu , kernel-team@android.com, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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. This series implements two types of iterators: 1. Standard BPF Iterator: Allows creating a BPF link to iterate over wakeup sources 2. Open-coded Iterator: Enables the use of wakeup_source iterators directly within BPF programs Both iterators utilize pre-existing APIs wakeup_sources_walk_* to traverse over the SRCU that backs the list of wakeup_sources. 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 (4): bpf: Add wakeup_source iterator bpf: Open coded BPF for wakeup_sources selftests/bpf: Add tests for wakeup_sources selftests/bpf: Open coded BPF wakeup_sources test kernel/bpf/Makefile | 3 + kernel/bpf/helpers.c | 3 + kernel/bpf/wakeup_source_iter.c | 137 ++++++++ .../testing/selftests/bpf/bpf_experimental.h | 5 + tools/testing/selftests/bpf/config | 1 + .../bpf/prog_tests/wakeup_source_iter.c | 323 ++++++++++++++++++ .../selftests/bpf/progs/wakeup_source_iter.c | 117 +++++++ 7 files changed, 589 insertions(+) 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