Commit e5e9b1f5 authored by Teng Qin's avatar Teng Qin

Add basic support of Cgroup Array

parent 18a2f2f8
...@@ -103,6 +103,17 @@ struct _name##_table_t { \ ...@@ -103,6 +103,17 @@ struct _name##_table_t { \
__attribute__((section("maps/perf_array"))) \ __attribute__((section("maps/perf_array"))) \
struct _name##_table_t _name = { .max_entries = (_max_entries) } struct _name##_table_t _name = { .max_entries = (_max_entries) }
// Table for cgroup file descriptors
#define BPF_CGROUP_ARRAY(_name, _max_entries) \
struct _name##_table_t { \
int key; \
u32 leaf; \
int (*check_current_task) (int); \
u32 max_entries; \
}; \
__attribute__((section("maps/cgroup_array"))) \
struct _name##_table_t _name = { .max_entries = (_max_entries) }
#define BPF_HASH1(_name) \ #define BPF_HASH1(_name) \
BPF_TABLE("hash", u64, u64, _name, 10240) BPF_TABLE("hash", u64, u64, _name, 10240)
#define BPF_HASH2(_name, _key_type) \ #define BPF_HASH2(_name, _key_type) \
......
...@@ -459,6 +459,9 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) { ...@@ -459,6 +459,9 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) {
} else if (memb_name == "perf_counter_value") { } else if (memb_name == "perf_counter_value") {
prefix = "bpf_perf_event_read_value"; prefix = "bpf_perf_event_read_value";
suffix = ")"; suffix = ")";
} else if (memb_name == "check_current_task") {
prefix = "bpf_current_task_under_cgroup";
suffix = ")";
} else { } else {
error(Call->getLocStart(), "invalid bpf_table operation %0") << memb_name; error(Call->getLocStart(), "invalid bpf_table operation %0") << memb_name;
return false; return false;
...@@ -762,6 +765,8 @@ bool BTypeVisitor::VisitVarDecl(VarDecl *Decl) { ...@@ -762,6 +765,8 @@ bool BTypeVisitor::VisitVarDecl(VarDecl *Decl) {
table.max_entries = numcpu; table.max_entries = numcpu;
} else if (A->getName() == "maps/perf_array") { } else if (A->getName() == "maps/perf_array") {
map_type = BPF_MAP_TYPE_PERF_EVENT_ARRAY; map_type = BPF_MAP_TYPE_PERF_EVENT_ARRAY;
} else if (A->getName() == "maps/cgroup_array") {
map_type = BPF_MAP_TYPE_CGROUP_ARRAY;
} else if (A->getName() == "maps/stacktrace") { } else if (A->getName() == "maps/stacktrace") {
map_type = BPF_MAP_TYPE_STACK_TRACE; map_type = BPF_MAP_TYPE_STACK_TRACE;
} else if (A->getName() == "maps/extern") { } else if (A->getName() == "maps/extern") {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment