@@ -243,7 +243,10 @@ static ino_t get_inode_from_kernfs(struct kernfs_node* node)
243
243
}
244
244
}
245
245
246
- int pids_cgrp_id = 1 ;
246
+ extern bool CONFIG_CGROUP_PIDS __kconfig __weak ;
247
+ enum cgroup_subsys_id___local {
248
+ pids_cgrp_id___local = 123 , /* value doesn't matter */
249
+ };
247
250
248
251
static INLINE void * populate_cgroup_info (struct cgroup_data_t * cgroup_data ,
249
252
struct task_struct * task ,
@@ -253,7 +256,9 @@ static INLINE void* populate_cgroup_info(struct cgroup_data_t* cgroup_data,
253
256
BPF_CORE_READ (task , nsproxy , cgroup_ns , root_cset , dfl_cgrp , kn );
254
257
struct kernfs_node * proc_kernfs = BPF_CORE_READ (task , cgroups , dfl_cgrp , kn );
255
258
256
- if (ENABLE_CGROUP_V1_RESOLVER ) {
259
+ if (ENABLE_CGROUP_V1_RESOLVER && CONFIG_CGROUP_PIDS ) {
260
+ int cgrp_id = bpf_core_enum_value (enum cgroup_subsys_id___local ,
261
+ pids_cgrp_id___local );
257
262
#ifdef UNROLL
258
263
#pragma unroll
259
264
#endif
@@ -262,7 +267,7 @@ static INLINE void* populate_cgroup_info(struct cgroup_data_t* cgroup_data,
262
267
BPF_CORE_READ (task , cgroups , subsys [i ]);
263
268
if (subsys != NULL ) {
264
269
int subsys_id = BPF_CORE_READ (subsys , ss , id );
265
- if (subsys_id == pids_cgrp_id ) {
270
+ if (subsys_id == cgrp_id ) {
266
271
proc_kernfs = BPF_CORE_READ (subsys , cgroup , kn );
267
272
root_kernfs = BPF_CORE_READ (subsys , ss , root , kf_root , kn );
268
273
break ;
0 commit comments