WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / progs / test_map_init.c
blobc89d28ead67370bb0bd498114e36fca68f85001a
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2020 Tessares SA <http://www.tessares.net> */
4 #include "vmlinux.h"
5 #include <bpf/bpf_helpers.h>
7 __u64 inKey = 0;
8 __u64 inValue = 0;
9 __u32 inPid = 0;
11 struct {
12 __uint(type, BPF_MAP_TYPE_PERCPU_HASH);
13 __uint(max_entries, 2);
14 __type(key, __u64);
15 __type(value, __u64);
16 } hashmap1 SEC(".maps");
19 SEC("tp/syscalls/sys_enter_getpgid")
20 int sysenter_getpgid(const void *ctx)
22 /* Just do it for once, when called from our own test prog. This
23 * ensures the map value is only updated for a single CPU.
25 int cur_pid = bpf_get_current_pid_tgid() >> 32;
27 if (cur_pid == inPid)
28 bpf_map_update_elem(&hashmap1, &inKey, &inValue, BPF_NOEXIST);
30 return 0;
33 char _license[] SEC("license") = "GPL";