From: David Laight <david.laight.linux@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: "André Almeida" <andrealmeid@igalia.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Juri Lelli" <juri.lelli@redhat.com>,
"Vincent Guittot" <vincent.guittot@linaro.org>,
"Christian Brauner" <brauner@kernel.org>,
"Kees Cook" <kees@kernel.org>, "Shuah Khan" <shuah@kernel.org>,
willy@infradead.org, mathieu.desnoyers@efficios.com,
"Linus Torvalds" <torvalds@linux-foundation.org>,
akpm@linux-foundation.org, "Yafang Shao" <laoar.shao@gmail.com>,
andrii.nakryiko@gmail.com, arnaldo.melo@gmail.com,
"Petr Mladek" <pmladek@suse.com>,
linux-kernel@vger.kernel.org, kernel-dev@igalia.com,
linux-mm@kvack.org, linux-api@vger.kernel.org
Subject: Re: [PATCH v2 3/6] treewide: Replace memcpy(..., current->comm) with strscpy()
Date: Wed, 27 May 2026 10:18:42 +0100 [thread overview]
Message-ID: <20260527101842.376d567f@pumpkin> (raw)
In-Reply-To: <20260526190625.3f4aca0a@gandalf.local.home>
On Tue, 26 May 2026 19:06:25 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> On Sun, 24 May 2026 19:38:53 -0300
> André Almeida <andrealmeid@igalia.com> wrote:
>
> > In order to increase the size of current->comm[] and to avoid breaking any
> > existing code, replace memcpy() with strscpy(). The later function makes
> > sure that the copy is NUL terminated. This is crucial given that the
> > source buffer might be larger than the destination buffer and could
> > truncate the NUL character out of it.
...
> As tracing now slows it down by 3.9% which is a significant increase from 2.7%
>
> I really rather keep memcpy() here.
I suspect the copies could/should be replaced by a copy_task_comm()
function that can perform optimisations that strscpy[_pad]() can't
do because it can (for example) assume that the source is terminated.
When the src and dst are the same size it can also degenerate to
memcpy() - which should get inlined.
The cost of copying 64 bytes might still be rather more than copying
just 16.
A compromise of 32 may be better.
-- David
>
> -- Steve
next prev parent reply other threads:[~2026-05-27 9:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-24 22:38 [PATCH v2 0/6] sched: Add support for long task name André Almeida
2026-05-24 22:38 ` [PATCH v2 1/6] sched: Update get_task_comm() comment André Almeida
2026-05-24 22:38 ` [PATCH v2 2/6] treewide: Get rid of get_task_comm() André Almeida
2026-05-25 10:34 ` David Laight
2026-05-24 22:38 ` [PATCH v2 3/6] treewide: Replace memcpy(..., current->comm) with strscpy() André Almeida
2026-05-26 23:06 ` Steven Rostedt
2026-05-27 9:18 ` David Laight [this message]
2026-05-29 16:46 ` André Almeida
2026-05-24 22:38 ` [PATCH v2 4/6] sched: Extend task command name to 64 bytes André Almeida
2026-05-25 10:41 ` David Laight
2026-05-25 10:42 ` David Laight
2026-05-26 16:31 ` Steven Rostedt
2026-05-27 8:42 ` David Laight
2026-05-29 16:43 ` André Almeida
2026-05-24 22:38 ` [PATCH v2 5/6] prctl: Add support for long user thread names André Almeida
2026-05-24 22:38 ` [PATCH v2 6/6] selftests: prctl: Add test for long " André Almeida
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=20260527101842.376d567f@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andrealmeid@igalia.com \
--cc=andrii.nakryiko@gmail.com \
--cc=arnaldo.melo@gmail.com \
--cc=brauner@kernel.org \
--cc=juri.lelli@redhat.com \
--cc=kees@kernel.org \
--cc=kernel-dev@igalia.com \
--cc=laoar.shao@gmail.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=peterz@infradead.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=shuah@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=vincent.guittot@linaro.org \
--cc=willy@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.