mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: michael.christie@oracle.com
To: Christian Brauner <brauner@kernel.org>
Cc: hch@infradead.org, stefanha@redhat.com, jasowang@redhat.com,
	mst@redhat.com, sgarzare@redhat.com,
	virtualization@lists.linux-foundation.org, ebiederm@xmission.com,
	torvalds@linux-foundation.org, konrad.wilk@oracle.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 03/11] kthread: Pass in the thread's name during creation
Date: Sat, 11 Mar 2023 10:11:26 -0600	[thread overview]
Message-ID: <74a17cb6-9dcd-749b-5d06-b2c364d36ae2@oracle.com> (raw)
In-Reply-To: <20230311085326.m7aub5duy76hnnam@wittgenstein>

On 3/11/23 2:53 AM, Christian Brauner wrote:
> On Fri, Mar 10, 2023 at 04:03:24PM -0600, Mike Christie wrote:
>> This has us pass in the thread's name during creation in kernel_thread.
>>
>> Signed-off-by: Mike Christie <michael.christie@oracle.com>
>> ---
>>  kernel/kthread.c | 35 ++++++++++++++---------------------
>>  1 file changed, 14 insertions(+), 21 deletions(-)
>>
>> diff --git a/kernel/kthread.c b/kernel/kthread.c
>> index 63574cee925e..831a55b406d8 100644
>> --- a/kernel/kthread.c
>> +++ b/kernel/kthread.c
>> @@ -38,6 +38,7 @@ struct task_struct *kthreadd_task;
>>  struct kthread_create_info
>>  {
>>  	/* Information passed to kthread() from kthreadd. */
>> +	char *full_name;
>>  	int (*threadfn)(void *data);
>>  	void *data;
>>  	int node;
>> @@ -343,10 +344,15 @@ static int kthread(void *_create)
>>  	/* Release the structure when caller killed by a fatal signal. */
>>  	done = xchg(&create->done, NULL);
>>  	if (!done) {
>> +		kfree(create->full_name);
>>  		kfree(create);
>>  		kthread_exit(-EINTR);
>>  	}
>>  
>> +	if (strlen(create->full_name) >= TASK_COMM_LEN)
>> +		self->full_name = create->full_name;
>> +	else
>> +		kfree(create->full_name);
> 
> This is monir but wwiw, this looks suspicious when reading it without
> more context. It took me a while to see that kthread->full_name is
> intended to store the untruncated name only if truncation actually needs
> to happen. So either we should always initialize this or we should add a
> comment. You can just send a tiny patch that I can fold into this one so
> you don't have to resend the whole series...
Ok. Thanks. I think always initializing it would make the code a lot easier
to understand and be nicer.

I don't think it would be too much extra memory used, and we don't have
to worry about some random userspace app breaking because it wanted to
configure the thread but the name got truncated.

  reply	other threads:[~2023-03-11 16:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10 22:03 [PATCH 00/11] Use copy_process in vhost layer Mike Christie
2023-03-10 22:03 ` [PATCH 01/11] csky: Remove kernel_thread declaration Mike Christie
2023-03-10 22:03 ` [PATCH 02/11] kernel: Allow a kernel thread's name to be set in copy_process Mike Christie
2023-03-10 22:03 ` [PATCH 03/11] kthread: Pass in the thread's name during creation Mike Christie
2023-03-11  8:53   ` Christian Brauner
2023-03-11 16:11     ` michael.christie [this message]
2023-03-12  1:48       ` Mike Christie
2023-03-10 22:03 ` [PATCH 04/11] kernel: Make io_thread and kthread bit fields Mike Christie
2023-03-10 22:03 ` [PATCH 05/11] fork/vm: Move common PF_IO_WORKER behavior to new flag Mike Christie
2023-03-10 22:03 ` [PATCH 06/11] fork: add kernel_clone_args flag to not dup/clone files Mike Christie
2023-03-10 22:03 ` [PATCH 07/11] fork: Add kernel_clone_args flag to ignore signals Mike Christie
2023-03-10 22:03 ` [PATCH 08/11] fork: allow kernel code to call copy_process Mike Christie
2023-03-10 22:03 ` [PATCH 09/11] vhost_task: Allow vhost layer to use copy_process Mike Christie
2023-03-10 22:03 ` [PATCH 10/11] vhost: move worker thread fields to new struct Mike Christie
2023-03-10 22:03 ` [PATCH 11/11] vhost: use vhost_tasks for worker threads Mike Christie
2023-03-11 17:21 ` [PATCH 00/11] Use copy_process in vhost layer Linus Torvalds
2023-03-11 17:49   ` Mike Christie
2023-03-11 19:15   ` Michael S. Tsirkin
2023-03-12 10:07 ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=74a17cb6-9dcd-749b-5d06-b2c364d36ae2@oracle.com \
    --to=michael.christie@oracle.com \
    --cc=brauner@kernel.org \
    --cc=ebiederm@xmission.com \
    --cc=hch@infradead.org \
    --cc=jasowang@redhat.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®