From: Ingo Molnar <mingo@kernel.org>
To: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Andy Lutomirski <luto@kernel.org>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Juergen Gross <jgross@suse.com>, X86 ML <x86@kernel.org>,
Borislav Petkov <bp@alien8.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: xen_exit_mmap() questions
Date: Thu, 27 Apr 2017 08:27:31 +0200 [thread overview]
Message-ID: <20170427062731.3r5bovikjgjolmew@gmail.com> (raw)
In-Reply-To: <d3be0f11-5699-bc90-c1f0-b770bc7da596@oracle.com>
* Boris Ostrovsky <boris.ostrovsky@oracle.com> wrote:
> > xen_mc_issue() does:
> >
> > if ((paravirt_get_lazy_mode() & mode) == 0)
> > xen_mc_flush();
> >
> > I assume the load_cr3() is intended to deal with the case where we're
> > in lazy mode, but we'll still be in lazy mode, right? Or does it
> > serve some other purpose?
>
> Of course. I can't read (I ignored the "== 0" part).
Ha, ob'sidenote: the preferred form to write this is:
if (!(paravirt_get_lazy_mode() & mode))
xen_mc_flush();
... exactly due to the readability problem you ran into: a 'pre' negation is much
easier to read, plus '==' tends to trigger 'equal to' attributes in the brain,
which is the opposite of negation. So it's very easy to mis-read such syntactic
constructs even if they are technically correct.
I think '== 0' should be forbidden in all cases where the purpose is a logic
operation and should be used strictly only in cases where we do explicit integer
arithmetics.
(Bools and '== false' are suboptimal for similar reasons.)
... but I digress!
Ingo
next prev parent reply other threads:[~2017-04-27 6:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-26 20:52 Andy Lutomirski
2017-04-26 22:45 ` Boris Ostrovsky
2017-04-26 22:49 ` Andy Lutomirski
2017-04-27 0:55 ` Boris Ostrovsky
2017-04-27 1:08 ` Andy Lutomirski
2017-04-27 13:21 ` Boris Ostrovsky
2017-04-27 16:46 ` Andy Lutomirski
2017-04-27 20:00 ` Boris Ostrovsky
2017-04-27 21:22 ` Andy Lutomirski
2017-04-27 6:27 ` Ingo Molnar [this message]
2017-04-27 7:40 ` [Xen-devel] " Jan Beulich
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=20170427062731.3r5bovikjgjolmew@gmail.com \
--to=mingo@kernel.org \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=x86@kernel.org \
--cc=xen-devel@lists.xenproject.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 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®