mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Mike Kravetz <kravetz@us.ibm.com>
Cc: viro@math.psu.edu, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] task name handling in proc fs
Date: Wed, 7 Jul 2004 15:11:34 -0700	[thread overview]
Message-ID: <20040707151134.05fc1e07.akpm@osdl.org> (raw)
In-Reply-To: <20040707215246.GB4314@w-mikek2.beaverton.ibm.com>

Mike Kravetz <kravetz@us.ibm.com> wrote:
>
> +void set_task_comm(struct task_struct *tsk, char *name)
> +{
> +	int i, ch;
> +
> +	task_lock(tsk);
> +	for (i=0; (ch = *(name++)) != '\0';) {
> +		if (ch == '/')
> +			i = 0;
> +		else
> +			if (i < (sizeof(tsk->comm) - 1))
> +				tsk->comm[i++] = ch;
> +	}
> +	tsk->comm[i] = '\0';
> +	task_unlock(tsk);
> +}

I don't think the basename logic should be in this function.  Only one
caller needs it, and if we later try to use this function to set
current->comm for per-cpu kernel threads, it will mangle the text.

root         2  0.0  0.0     0    0 ?        SW   Jul06   0:00 [migration/0]
root         3  0.0  0.0     0    0 ?        SWN  Jul06   0:00 [ksoftirqd/0]
root         4  0.0  0.0     0    0 ?        SW   Jul06   0:00 [migration/1]
root         5  0.0  0.0     0    0 ?        SWN  Jul06   0:00 [ksoftirqd/1]
root         6  0.0  0.0     0    0 ?        SW   Jul06   0:00 [migration/2]
root         7  0.0  0.0     0    0 ?        SWN  Jul06   0:00 [ksoftirqd/2]
root         8  0.0  0.0     0    0 ?        SW   Jul06   0:00 [migration/3]
root         9  0.0  0.0     0    0 ?        SWN  Jul06   0:00 [ksoftirqd/3]

We probably won't actually _do_ that, since kthread_create() uses vsnprintf(),
but pushing code which is specific to one caller into a library function
seems wrong...

  reply	other threads:[~2004-07-07 22:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-01 22:05 Mike Kravetz
2004-07-01 22:19 ` Andrew Morton
2004-07-01 22:42   ` Mike Kravetz
2004-07-01 23:03     ` Andrew Morton
2004-07-01 23:38       ` Mike Kravetz
2004-07-07 21:52       ` Mike Kravetz
2004-07-07 22:11         ` Andrew Morton [this message]
2004-07-07 23:35           ` Mike Kravetz
2004-07-08  2:32             ` Paul Jackson
2004-07-08 17:01               ` Mike Kravetz
2004-07-02  1:27     ` Andrew Rodland

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=20040707151134.05fc1e07.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=kravetz@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@math.psu.edu \
    /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®