Hello everyone, I was wondering if I can obtain the PID/TGID of some userland process that originally caused a RPC request to be transmitted from within the RPC request itself. Here is what I did to find out: With a BPF program I collect the following metrics from a tracepoint inside “xprt_request_transmit()” function defined in /net/sunrpc/xprt.c: 1. current task name 2. current PID/TGID as a return value of bpf_get_current_pid_tgid() 3. The TGID assigned in the tk_owner field of struct rpc_task. From the sources I know that the TGID from 3. is assigned in “rpc_init_task() function” defined in /net/sunrpc/sched.c: task->tk_owner = current->tgid; In the output of the BPF program I see records with the following entries for the above metrics: 1. "kworker/u389:3” 2. "PID": 455045, "TGID": 455045 3. “TGID of tk_owner": 3989219 Here, I presume, the thread (kworker) that executed the "xprt_request_transmit()” routine differs from the one that assigned its TGID to the tk_owner field in “rpc_init_task()”. But there are also records like this: 1. "kworker/u128:4" 2. "PID": 1457360, "TGID": 1457360 3. "TGID of tk_owner": 1457360 Here, the kworker did both the jobs. Now to my questions: 1. What determines which thread (kernel or userland thread) executes rpc_init_task()? 2. How can I, with certainty, obtain the PID/TGID of the userland process from inside rpc_init_task() ? Thank you for your answers. Best regards, Sandro |
Attachment:
smime.p7s
Description: S/MIME cryptographic signature