32 lines · c
1// SPDX-License-Identifier: GPL-2.02/* Copyright (c) 2020 Facebook */3 4#include "vmlinux.h"5 6#include <bpf/bpf_helpers.h>7 8extern const struct rq runqueues __ksym; /* struct type global var. */9extern const int bpf_prog_active __ksym; /* int type global var. */10 11SEC("raw_tp/sys_enter")12int handler(const void *ctx)13{14 struct rq *rq;15 int *active;16 __u32 cpu;17 18 cpu = bpf_get_smp_processor_id();19 rq = (struct rq *)bpf_per_cpu_ptr(&runqueues, cpu);20 active = (int *)bpf_per_cpu_ptr(&bpf_prog_active, cpu);21 if (active) {22 /* READ_ONCE */23 *(volatile int *)active;24 /* !rq has not been tested, so verifier should reject. */25 *(volatile int *)(&rq->cpu);26 }27 28 return 0;29}30 31char _license[] SEC("license") = "GPL";32