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