From: Al Viro <viro@ZenIV.linux.org.uk>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: linux-alpha@vger.kernel.org,
Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
Jan-Benedict Glaw <jbglaw@lug-owl.de>,
Matt Turner <mattst88@gmail.com>,
Nicolas Pitre <nicolas.pitre@linaro.org>,
Richard Cochran <richardcochran@gmail.com>,
Richard Henderson <rth@twiddle.net>,
Thomas Gleixner <tglx@linutronix.de>,
LKML <linux-kernel@vger.kernel.org>,
kernel-janitors@vger.kernel.org
Subject: Re: alpha: Checking source code positions for the setting of error codes
Date: Wed, 18 Jan 2017 17:43:20 +0000 [thread overview]
Message-ID: <20170118174320.GE1555@ZenIV.linux.org.uk> (raw)
In-Reply-To: <a8237856-6926-57d3-69ba-cff4006406b3@users.sourceforge.net>
On Wed, Jan 18, 2017 at 04:41:10PM +0100, SF Markus Elfring wrote:
> >> A local variable was set to an error code in two cases before a concrete
> >> error situation was detected. Thus move the corresponding assignment into
> >> an if branch to indicate a software failure there.
> >>
> >> This issue was detected by using the Coccinelle software.
> >
> > Why the hell is that an issue?
>
> * Can misplaced variable assignments result in unwanted run time consequences
> because of the previous approach for a control flow specification?
More like the opposite.
load constant to register
test
branch usually not taken
is considerably cheaper than
test
branch usually taken
Something like
if (unlikely(foo)) {
err = -ESOMETHING;
goto sod_off;
}
would be more or less on par (and quite possibly would be compiled into
the same code - depends upon the scheduling details for processor,
but speculative load of constant can be an optimization). However, that
has an effect of splattering the source with tons of those unlikely() *and*
visually cluttering the common path.
> * How do you think about to achieve that error codes will only be set
> after a specific software failure was detected?
Sounds like an arbitrary requirement, TBH...
Again, loading a constant into register tends to be cheap and easy to
combine with other instructions at CPU pipeline level. If anything, this
pattern is a microoptimization, often in spots that are not on hotpaths
by any stretch of imagination. But estimating whether a given place is
on a hot path takes a lot more delicate analysis than feasible for
cocci scripts. And visual cluttering of the common execution path remains -
it doesn't matter for compiler, but it can matter a lot for human readers.
next prev parent reply other threads:[~2017-01-18 17:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-18 11:40 [PATCH 0/4] alpha: Fine-tuning for five function implementations SF Markus Elfring
2017-01-18 11:45 ` [PATCH 1/4] alpha: Return an error code only as a constant in osf_sigstack() SF Markus Elfring
2017-01-18 11:46 ` [PATCH 2/4] alpha: Move two assignments for the variable "error" in osf_utsname() SF Markus Elfring
2017-01-18 11:47 ` [PATCH 3/4] alpha: Return directly after a failed copy_from_user() or getname() in two functions SF Markus Elfring
2017-01-18 11:50 ` [PATCH 4/4] alpha: Move two assignments for the variable "res" in srm_env_proc_write() SF Markus Elfring
2017-01-18 13:14 ` Jan-Benedict Glaw
2017-01-18 14:27 ` SF Markus Elfring
2017-01-18 14:11 ` Al Viro
2017-01-18 15:41 ` alpha: Checking source code positions for the setting of error codes SF Markus Elfring
2017-01-18 17:43 ` Al Viro [this message]
2017-01-19 0:45 ` [PATCH 4/4] alpha: Move two assignments for the variable "res" in srm_env_proc_write() kbuild test robot
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=20170118174320.GE1555@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=elfring@users.sourceforge.net \
--cc=ink@jurassic.park.msu.ru \
--cc=jbglaw@lug-owl.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mattst88@gmail.com \
--cc=nicolas.pitre@linaro.org \
--cc=richardcochran@gmail.com \
--cc=rth@twiddle.net \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).