Message ID | 20211025083315.4752-1-laoar.shao@gmail.com (mailing list archive) |
---|---|
Headers | show |
Series | extend task comm from 16 to 24 | expand |
On Mon, Oct 25, 2021 at 1:33 AM Yafang Shao <laoar.shao@gmail.com> wrote: > > There're many truncated kthreads in the kernel, which may make trouble > for the user, for example, the user can't get detailed device > information from the task comm. > > This patchset tries to improve this problem fundamentally by extending > the task comm size from 16 to 24. In order to do that, we have to do > some cleanups first. It looks like a churn that doesn't really address the problem. If we were to allow long names then make it into a pointer and use 16 byte as an optimized storage for short names. Any longer name would be a pointer. In other words make it similar to dentry->d_iname.
On Mon, 25 Oct 2021 11:10:09 -0700 Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote: > It looks like a churn that doesn't really address the problem. > If we were to allow long names then make it into a pointer and use 16 byte > as an optimized storage for short names. Any longer name would be a pointer. > In other words make it similar to dentry->d_iname. That would be quite a bigger undertaking too, as it is assumed throughout the kernel that the task->comm is TASK_COMM_LEN and is nul terminated. And most locations that save the comm simply use a fixed size string of TASK_COMM_LEN. Not saying its not feasible, but it would require a lot more analysis of the impact by changing such a fundamental part of task struct from a static to something requiring allocation. Unless you are suggesting that we truncate like normal the 16 byte names (to a max of 15 characters), and add a way to hold the entire name for those locations that understand it. -- Steve
On Mon, Oct 25, 2021 at 05:05:03PM -0400, Steven Rostedt wrote: > On Mon, 25 Oct 2021 11:10:09 -0700 > Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote: > > > It looks like a churn that doesn't really address the problem. > > If we were to allow long names then make it into a pointer and use 16 byte > > as an optimized storage for short names. Any longer name would be a pointer. > > In other words make it similar to dentry->d_iname. > > That would be quite a bigger undertaking too, as it is assumed throughout > the kernel that the task->comm is TASK_COMM_LEN and is nul terminated. And > most locations that save the comm simply use a fixed size string of > TASK_COMM_LEN. Not saying its not feasible, but it would require a lot more > analysis of the impact by changing such a fundamental part of task struct > from a static to something requiring allocation. > > Unless you are suggesting that we truncate like normal the 16 byte names > (to a max of 15 characters), and add a way to hold the entire name for > those locations that understand it. Agreed -- this is a small change for what is already an "uncommon" corner case. I don't think this needs to suddenly become an unbounded string. :)
On Mon 2021-10-25 17:05:03, Steven Rostedt wrote: > On Mon, 25 Oct 2021 11:10:09 -0700 > Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote: > > > It looks like a churn that doesn't really address the problem. > > If we were to allow long names then make it into a pointer and use 16 byte > > as an optimized storage for short names. Any longer name would be a pointer. > > In other words make it similar to dentry->d_iname. > > That would be quite a bigger undertaking too, as it is assumed throughout > the kernel that the task->comm is TASK_COMM_LEN and is nul terminated. And > most locations that save the comm simply use a fixed size string of > TASK_COMM_LEN. Not saying its not feasible, but it would require a lot more > analysis of the impact by changing such a fundamental part of task struct > from a static to something requiring allocation. I fully agree. The evolution of this patchset clearly shows how many code paths depend on the existing behavior. > Unless you are suggesting that we truncate like normal the 16 byte names > (to a max of 15 characters), and add a way to hold the entire name for > those locations that understand it. Yup. If the problem is only with kthreads, it might be possible to store the pointer into "struct kthread" and update proc_task_name(). It would generalize the solution already used by workqueues. I think that something like this was mentioned in the discussion about v1. Best Regards, Petr