From: Claudio Fontana <claudio.font...@gmail.com> commit f3cef7a99469 ("[PATCH] csa: basic accounting over taskstats") introduced accounting fields over taskstats,
however the ac_pid field has been filled in with the Linux pid (the tid), instead of the POSIX pid (the tgid) like for acct.c This change aligns the ac_pid field in tsacct with the ac_pid field in acct.c Signed-off-by: Claudio Fontana <claudio.font...@gmail.com> --- kernel/tsacct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Hello all, this is just to spark some responses regarding the current status of tsacct field ac_pid, which currently is filled up with pid, where I would expect a tgid, like for acct.c. in acct.c: ac.ac_pid = task_tgid_nr_ns(current, ns); in tsacct.c: stats->ac_pid = task_pid_nr_ns(tsk, pid_ns); I am trying to have a low overhead way from a C userspace program to get the tgid given a single pid. I have tried using the tgid map provided by ftrace, however parsing and reparsing the text of the whole map is quite expensive. Reading from /proc/PID/ is of higher overhead, with multiple opens, reads and close calls necessary. I have experimented with previous work by Andrey Vagin on task_diag (the old and the new method), but neither is currently upstream; one of the comments at the time mentioned that the functionality should instead be merged into netlink taskstats. https://criu.org/Task-diag https://lwn.net/Articles/683371/ I think that for backward compatibility reasons, this particular change in this RFC cannot be applied as such. Maybe adding a new field ac_tgid would be preferable? Maybe the information could be carried inside the NETLINK taskstat response as an unconditional additional TASKSTATS_TYPE_TGID field, even when the TASKSTATS_CMD_GET requests a TASKSTATS_CMD_ATTR_PID? Thank you and looking forward for your comments, Claudio diff --git a/kernel/tsacct.c b/kernel/tsacct.c index 370724b..28ecedb 100644 --- a/kernel/tsacct.c +++ b/kernel/tsacct.c @@ -59,7 +59,7 @@ void bacct_add_tsk(struct user_namespace *user_ns, stats->ac_flag |= AXSIG; stats->ac_nice = task_nice(tsk); stats->ac_sched = tsk->policy; - stats->ac_pid = task_pid_nr_ns(tsk, pid_ns); + stats->ac_pid = task_tgid_nr_ns(tsk, pid_ns); rcu_read_lock(); tcred = __task_cred(tsk); stats->ac_uid = from_kuid_munged(user_ns, tcred->uid); -- 2.7.4