tools/testing/selftests/bpf/progs/test_wakeup_source.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/test_wakeup_source.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/progs/test_wakeup_source.c
Extension
.c
Size
2427 bytes
Lines
93
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

if (active) {
			s64 curr_time = bpf_ktime_get_ns();
			s64 prevent_time = ws->start_prevent_time;

			if (curr_time > last_time)
				active_time = curr_time - last_time;

			total_time += active_time;
			if (active_time > max_time)
				max_time = active_time;
			if (autosleep_enable && curr_time > prevent_time)
				prevent_sleep_time += curr_time - prevent_time;
		}

		e->active_count = ws->active_count;
		e->active_time_ns = active_time;
		e->event_count = ws->event_count;
		e->expire_count = ws->expire_count;
		e->last_time_ns = last_time;
		e->max_time_ns = max_time;
		e->prevent_sleep_time_ns = prevent_sleep_time;
		e->total_time_ns = total_time;
		e->wakeup_count = ws->wakeup_count;

		if (bpf_probe_read_kernel_str(
				e->name, WAKEUP_NAME_LEN, ws->name) < 0)
			e->name[0] = '\0';

		bpf_ringbuf_submit(e, 0);
	}

	bpf_wakeup_sources_read_unlock(lock);
	return 0;
}

char _license[] SEC("license") = "GPL";

Annotation

Implementation Notes