On Sat, Dec 23, 2023 at 1:51 AM Tejun Heo <tj@xxxxxxxxxx> wrote: > > Hello, > > On Fri, Dec 22, 2023 at 11:31:01AM +0000, Yafang Shao wrote: > > Introducing a new kfunc: bpf_cpumask_set_from_pid. This function serves the > > purpose of retrieving the cpumask associated with a specific PID. Its > > utility is particularly evident within container environments. For > > instance, it allows for extracting the cpuset of a container using the > > init task within it. > > > > Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx> > ... > > +__bpf_kfunc bool bpf_cpumask_set_from_pid(struct cpumask *cpumask, u32 pid) > > +{ > > + struct task_struct *task; > > + > > + if (!cpumask) > > + return false; > > + > > + task = get_pid_task(find_vpid(pid), PIDTYPE_PID); > > + if (!task) > > + return false; > > + > > + cpumask_copy(cpumask, task->cpus_ptr); > > + put_task_struct(task); > > + return true; > > +} > > This seems awfully specific. Why is this necessary? Shouldn't the BPF prog > get the task and bpf_cpumask_copy() its ->cpus_ptr instead? Good point. I missed the bpf_cpumask_copy(). Will use it instead. -- Regards Yafang