bpf: use a unified macro definition COMPAT_CPU_NUM

use a unified macro definition to avoid code redundancy

Signed-off-by: Tonghao Zhang <tonghao@bamaicloud.com>
This commit is contained in:
Tonghao Zhang 2025-07-25 05:18:23 -04:00
parent 17522020ec
commit 9ba36d2707
5 changed files with 5 additions and 8 deletions

View File

@ -9,8 +9,7 @@
char __license[] SEC("license") = "Dual MIT/GPL";
#define CPU_NUM 128
BPF_RATELIMIT_IN_MAP(rate, 1, CPU_NUM * 10000, 0);
BPF_RATELIMIT_IN_MAP(rate, 1, COMPAT_CPU_NUM * 10000, 0);
struct {
__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);

View File

@ -10,6 +10,7 @@
#define COMPAT_TASK_COMM_LEN 16
#define PATH_MAX 4096 /* # chars in a path name including nul */
#define COMPAT_CPU_NUM 128
/* include/uapi/linux/perf_event.h */
#define PERF_MAX_STACK_DEPTH 127

View File

@ -9,8 +9,7 @@
char __license[] SEC("license") = "Dual MIT/GPL";
#define CPU_NUM 128
BPF_RATELIMIT_IN_MAP(rate, 1, CPU_NUM * 10000, 0);
BPF_RATELIMIT_IN_MAP(rate, 1, COMPAT_CPU_NUM * 10000, 0);
struct {
__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);

View File

@ -15,9 +15,8 @@ char __license[] SEC("license") = "Dual MIT/GPL";
volatile const u64 softirq_thresh = SOFTIRQ_THRESH;
#define CPU_NUM 128
#define TICK 1000
BPF_RATELIMIT(rate, 1, CPU_NUM *TICK * 1000);
BPF_RATELIMIT(rate, 1, COMPAT_CPU_NUM *TICK * 1000);
struct timer_softirq_run_ts {
u32 start_trace;

View File

@ -9,8 +9,7 @@
char __license[] SEC("license") = "Dual MIT/GPL";
#define CPU_NUM 128
BPF_RATELIMIT_IN_MAP(rate, 1, CPU_NUM * 10000, 0);
BPF_RATELIMIT_IN_MAP(rate, 1, COMPAT_CPU_NUM * 10000, 0);
struct {
__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);