1*12bb6ca4SYonghong Song // SPDX-License-Identifier: GPL-2.0
2*12bb6ca4SYonghong Song /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */
3*12bb6ca4SYonghong Song 
4*12bb6ca4SYonghong Song #include "vmlinux.h"
5*12bb6ca4SYonghong Song #include <bpf/bpf_helpers.h>
6*12bb6ca4SYonghong Song #include <bpf/bpf_tracing.h>
7*12bb6ca4SYonghong Song 
8*12bb6ca4SYonghong Song char _license[] SEC("license") = "GPL";
9*12bb6ca4SYonghong Song 
10*12bb6ca4SYonghong Song struct {
11*12bb6ca4SYonghong Song 	__uint(type, BPF_MAP_TYPE_CGRP_STORAGE);
12*12bb6ca4SYonghong Song 	__uint(map_flags, BPF_F_NO_PREALLOC);
13*12bb6ca4SYonghong Song 	__type(key, int);
14*12bb6ca4SYonghong Song 	__type(value, long);
15*12bb6ca4SYonghong Song } map_a SEC(".maps");
16*12bb6ca4SYonghong Song 
17*12bb6ca4SYonghong Song SEC("tp_btf/sys_enter")
BPF_PROG(on_enter,struct pt_regs * regs,long id)18*12bb6ca4SYonghong Song int BPF_PROG(on_enter, struct pt_regs *regs, long id)
19*12bb6ca4SYonghong Song {
20*12bb6ca4SYonghong Song 	struct task_struct *task;
21*12bb6ca4SYonghong Song 
22*12bb6ca4SYonghong Song 	task = bpf_get_current_task_btf();
23*12bb6ca4SYonghong Song 	(void)bpf_cgrp_storage_get(&map_a, (struct cgroup *)task, 0,
24*12bb6ca4SYonghong Song 				   BPF_LOCAL_STORAGE_GET_F_CREATE);
25*12bb6ca4SYonghong Song 	return 0;
26*12bb6ca4SYonghong Song }
27