Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /* Copyright (c) 2020 Facebook */
0003 
0004 #include "vmlinux.h"
0005 
0006 #include <bpf/bpf_helpers.h>
0007 
0008 extern const struct rq runqueues __ksym; /* struct type global var. */
0009 extern const int bpf_prog_active __ksym; /* int type global var. */
0010 
0011 SEC("raw_tp/sys_enter")
0012 int handler(const void *ctx)
0013 {
0014     struct rq *rq;
0015     int *active;
0016     __u32 cpu;
0017 
0018     cpu = bpf_get_smp_processor_id();
0019     rq = (struct rq *)bpf_per_cpu_ptr(&runqueues, cpu);
0020     active = (int *)bpf_per_cpu_ptr(&bpf_prog_active, cpu);
0021     if (active) {
0022         /* READ_ONCE */
0023         *(volatile int *)active;
0024         /* !rq has not been tested, so verifier should reject. */
0025         *(volatile int *)(&rq->cpu);
0026     }
0027 
0028     return 0;
0029 }
0030 
0031 char _license[] SEC("license") = "GPL";