[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202504030923.1FE7874F@keescook>
Date: Thu, 3 Apr 2025 09:24:13 -0700
From: Kees Cook <kees@...nel.org>
To: Bhupesh <bhupesh@...lia.com>
Cc: akpm@...ux-foundation.org, kernel-dev@...lia.com,
linux-kernel@...r.kernel.org, bpf@...r.kernel.org,
linux-perf-users@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-mm@...ck.org, oliver.sang@...el.com, lkp@...el.com,
laoar.shao@...il.com, pmladek@...e.com, rostedt@...dmis.org,
mathieu.desnoyers@...icios.com, arnaldo.melo@...il.com,
alexei.starovoitov@...il.com, andrii.nakryiko@...il.com,
mirq-linux@...e.qmqm.pl, peterz@...radead.org, willy@...radead.org,
david@...hat.com, viro@...iv.linux.org.uk, ebiederm@...ssion.com,
brauner@...nel.org, jack@...e.cz, mingo@...hat.com,
juri.lelli@...hat.com, bsegall@...gle.com, mgorman@...e.de,
vschneid@...hat.com
Subject: Re: [PATCH v2 3/3] kthread: Use 'task_struct->full_name' to store
kthread's full name
On Mon, Mar 31, 2025 at 05:48:20PM +0530, Bhupesh wrote:
> Commit 6986ce24fc00 ("kthread: dynamically allocate memory to store
> kthread's full name"), added 'full_name' in parallel to 'comm' for
> kthread names.
>
> Now that we have added 'full_name' added to 'task_struct' itself,
> drop the additional 'full_name' entry from 'struct kthread' and also
> its usage.
>
> Signed-off-by: Bhupesh <bhupesh@...lia.com>
I'd like to see this patch be the first patch in the series. This show
the existing use for "full_name". (And as such it'll probably need bits
from patch 1.)
-Kees
> ---
> kernel/kthread.c | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/kernel/kthread.c b/kernel/kthread.c
> index 5dc5b0d7238e..46fe19b7ef76 100644
> --- a/kernel/kthread.c
> +++ b/kernel/kthread.c
> @@ -66,8 +66,6 @@ struct kthread {
> #ifdef CONFIG_BLK_CGROUP
> struct cgroup_subsys_state *blkcg_css;
> #endif
> - /* To store the full name if task comm is truncated. */
> - char *full_name;
> struct task_struct *task;
> struct list_head hotplug_node;
> struct cpumask *preferred_affinity;
> @@ -108,12 +106,12 @@ void get_kthread_comm(char *buf, size_t buf_size, struct task_struct *tsk)
> {
> struct kthread *kthread = to_kthread(tsk);
>
> - if (!kthread || !kthread->full_name) {
> + if (!kthread || !tsk->full_name) {
> strscpy(buf, tsk->comm, buf_size);
> return;
> }
>
> - strscpy_pad(buf, kthread->full_name, buf_size);
> + strscpy_pad(buf, tsk->full_name, buf_size);
> }
>
> bool set_kthread_struct(struct task_struct *p)
> @@ -153,7 +151,6 @@ void free_kthread_struct(struct task_struct *k)
> WARN_ON_ONCE(kthread->blkcg_css);
> #endif
> k->worker_private = NULL;
> - kfree(kthread->full_name);
> kfree(kthread);
> }
>
> @@ -430,7 +427,7 @@ static int kthread(void *_create)
> kthread_exit(-EINTR);
> }
>
> - self->full_name = create->full_name;
> + self->task->full_name = create->full_name;
> self->threadfn = threadfn;
> self->data = data;
>
> --
> 2.38.1
>
--
Kees Cook
Powered by blists - more mailing lists