Files
linux-stable-mirror/tools/testing/selftests/bpf/progs/wakeup_source.h
T
Samuel WuandAlexei Starovoitov 9ef6471142 selftests/bpf: Add tests for wakeup_sources kfuncs
Introduce a set of BPF selftests to verify the safety and functionality
of wakeup_source kfuncs.

The suite includes:
1. A functional test (test_wakeup_source.c) that iterates over the
   global wakeup_sources list. It uses CO-RE to read timing statistics
   and validates them in user-space via the BPF ring buffer.
2. A negative test suite (wakeup_source_fail.c) ensuring the BPF
   verifier correctly enforces reference tracking and type safety.
3. Enable CONFIG_PM_WAKELOCKS in the test config, allowing creation of
   wakeup sources via /sys/power/wake_lock.

A shared header (wakeup_source.h) is introduced to ensure consistent
memory layout for the Ring Buffer data between BPF and user-space.

Signed-off-by: Samuel Wu <wusamuel@google.com>
Link: https://lore.kernel.org/r/20260511174559.659782-3-wusamuel@google.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2026-05-14 16:04:54 -07:00

23 lines
499 B
C

/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright 2026 Google LLC */
#ifndef __WAKEUP_SOURCE_H__
#define __WAKEUP_SOURCE_H__
#define WAKEUP_NAME_LEN 128
struct wakeup_event_t {
unsigned long active_count;
long long active_time_ns;
unsigned long event_count;
unsigned long expire_count;
long long last_time_ns;
long long max_time_ns;
long long prevent_sleep_time_ns;
long long total_time_ns;
unsigned long wakeup_count;
char name[WAKEUP_NAME_LEN];
};
#endif /* __WAKEUP_SOURCE_H__ */