[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240115065440.GF1674809@ZenIV>
Date: Mon, 15 Jan 2024 06:54:40 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: Li kunyu <kunyu@...china.com>
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH] utsname: Optimize clone_uts_ns()
On Mon, Jan 15, 2024 at 02:11:27PM +0800, Li kunyu wrote:
> Optimize the err variable assignment location so that the err variable
> is manually modified when an error occurs.
First of all, this is *not* an optimization in any meaningful sense -
compiler is perfectly capable to shift those assignments (from either
form) and choose whatever it prefers.
Incidentally, it might end up lifting the store out of if - it's
entirely possible that
r1 = v
flag = (r2 == 0)
if flag goto fail
is better than
flag = (r2 == 0)
if flag goto l
...
l:
r1 = v
goto fail
provided that assignment to r1 and checking r2 can be done in parallel
and that's assuming that it will figure out that branch is unlikely.
Readability might be a good reason; optimization... no. Leave that to
compiler; it will override your choice here anyway.
Powered by blists - more mailing lists