brintos

brintos / linux-shallow public Read only

0
0
Text · 841 B · 1249a94 Raw
39 lines · c
1// SPDX-License-Identifier: GPL-2.02// Copyright (c) 2020 Facebook3#include <linux/bpf.h>4#include <bpf/bpf_helpers.h>5#include <bpf/bpf_tracing.h>6 7struct {8	__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);9	__uint(max_entries, 1);10	__type(key, int);11	__type(value, int);12} array_1 SEC(".maps");13 14struct {15	__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);16	__uint(max_entries, 1);17	__type(key, int);18	__type(value, int);19	__uint(map_flags, BPF_F_PRESERVE_ELEMS);20} array_2 SEC(".maps");21 22SEC("raw_tp/sched_switch")23int BPF_PROG(read_array_1)24{25	struct bpf_perf_event_value val;26 27	return bpf_perf_event_read_value(&array_1, 0, &val, sizeof(val));28}29 30SEC("raw_tp/task_rename")31int BPF_PROG(read_array_2)32{33	struct bpf_perf_event_value val;34 35	return bpf_perf_event_read_value(&array_2, 0, &val, sizeof(val));36}37 38char LICENSE[] SEC("license") = "GPL";39