On Fri, 27 Mar 2026 at 15:49, David Laight <[email protected]> wrote:
>
> I've not measured strnlen(), but it wouldn't surprise me if argv[]
> processing wouldn't be faster with something like the strlen() in this
> patch.
> After all arguments are usually relatively short.
No, we used to do those a byte at a time. It was not great. execve()
strings are often actually long because of filenames and environment
variables.
The trivial cases don't even matter, because all the cost of execve()
are elsewhere for those cases.
But the cases where the strings *do* matter, they are many and long.
Again - where did you actually see costs in real profiles? We really
don't tend to have strings in the kernel. The strings we do have are
from user space, and by the time they are in the kernel they typically
aren't C strings any more (or, with pathnames, have other termination
than just the NUL character).
Linus