Re: [PATCH v2] kthread: dynamically allocate memory to store kthread's full name

From: Petr Mladek
Date: Thu Nov 25 2021 - 04:20:14 EST


On Sat 2021-11-20 11:28:50, Yafang Shao wrote:
> When I was implementing a new per-cpu kthread cfs_migration, I found the
> comm of it "cfs_migration/%u" is truncated due to the limitation of
> TASK_COMM_LEN.
>
> One possible way to fix this issue is extending the task comm size, but
> as task->comm is used in lots of places, that may cause some potential
> buffer overflows. Another more conservative approach is introducing a new
> pointer to store kthread's full name if it is truncated, which won't
> introduce too much overhead as it is in the non-critical path. Finally we
> make a dicision to use the second approach. See also the discussions in
> this thread:
> https://lore.kernel.org/lkml/20211101060419.4682-1-laoar.shao@xxxxxxxxx/
>
> After this change, the full name of these truncated kthreads will be
> displayed via /proc/[pid]/comm:

> Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx>

Looks good to me:

Reviewed-by: Petr Mladek <pmladek@xxxxxxxx>

Best Regards,
Petr