Re: [PATCH V2] bpf: task_group_seq_get_next: cleanup the usage of get/put_task_struct

From: Daniel Borkmann
Date: Fri Aug 25 2023 - 10:29:23 EST


Hi Oleg,

On 8/22/23 2:05 PM, Oleg Nesterov wrote:
get_pid_task() makes no sense, the code does put_task_struct() soon after.
Use find_task_by_pid_ns() instead of find_pid_ns + get_pid_task and kill
put_task_struct(), this allows to do get_task_struct() only once before
return.

While at it, kill the unnecessary "if (!pid)" check in the "if (!*tid)"
block, this matches the next usage of find_pid_ns() + get_pid_task() in
this function.

Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx>
Acked-by: Yonghong Song <yonghong.song@xxxxxxxxx>

Could you rebase this against bpf-next tree so this can run through our BPF
CI? Right now the CI cannot pick the patch up due to merge conflict [0].

Thanks,
Daniel

[0] https://patchwork.kernel.org/project/netdevbpf/patch/20230822120549.GA22091@xxxxxxxxxx/