[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALOAHbD3HUqUnjMYKX7NGwVWiS4K7OvS6uPNWucnOA5Cy3pn9w@mail.gmail.com>
Date: Thu, 30 Sep 2021 20:53:27 +0800
From: Yafang Shao <laoar.shao@...il.com>
To: Kees Cook <keescook@...omium.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Petr Mladek <pmladek@...e.com>,
Peter Zijlstra <peterz@...radead.org>,
Valentin Schneider <valentin.schneider@....com>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
qiang.zhang@...driver.com, robdclark@...omium.org,
Al Viro <viro@...iv.linux.org.uk>, christian@...uner.io,
Dietmar Eggemann <dietmar.eggemann@....com>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 4/5] kernel: increase the size of kthread's comm
On Thu, Sep 30, 2021 at 2:20 AM Kees Cook <keescook@...omium.org> wrote:
>
> On Wed, Sep 29, 2021 at 11:50:35AM +0000, Yafang Shao wrote:
> > This patch increases the size of ktread's comm from 16 to 24, which is
> > the same with workqueue's, to improve this situation. After this cahnge,
> > [...]
> > Because there're only a few of kthreads, so it won't increase too much
> > memory.
>
> Even without the performance impact changes, the math here doesn't hold
> either, since using kmalloc means there are slabs being allocated to hold
> the task "comm"s now (which comes with overhead), and every task added
> a pointer to those 16 bytes (i.e. 8 more bytes on 64-bit systems). So
> this change, even if there was 0 overhead in using slabs, would be
> identical to having just raised TASK_COMM_LEN to 24. 8 byte pointer,
> 16 byte allocation == 24 bytes.
>
Right, thanks for the explanation. I missed the pointer before.
What about reusing the kthread_data() to store the the comm if the
kthread is not a kworker?
struct kthread {
...
void *data; // reuse this pointer
...
}
The logic will be something as follows,
if (kthread_is_kworker) {
store_worker_desc_into_kthread_data(); // already did in the kernel
} else {
store_comm_into_kthread_data(); // that is what we should change
}
And then we modify the proc_task_name() correspondingly.
--
Thanks
Yafang
Powered by blists - more mailing lists