xref: /linux/tools/tracing/rtla/tests/bpf/bpf_action_map.c (revision 582a1ef360a05bff4350bbf6e383f61d26b804f0)
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/bpf.h>
3 #include <bpf/bpf_tracing.h>
4 
5 char LICENSE[] SEC("license") = "GPL";
6 
7 struct {
8 	__uint(type, BPF_MAP_TYPE_ARRAY);
9 	__uint(max_entries, 1);
10 	__type(key, unsigned int);
11 	__type(value, unsigned long long);
12 } rtla_test_map SEC(".maps");
13 
14 struct trace_event_raw_timerlat_sample;
15 
16 SEC("tp/timerlat_action")
17 int action_handler(struct trace_event_raw_timerlat_sample *tp_args)
18 {
19 	unsigned int key = 0;
20 	unsigned long long value = 42;
21 
22 	bpf_map_update_elem(&rtla_test_map, &key, &value, BPF_ANY);
23 
24 	return 0;
25 }
26