Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1631889

Re: xen_exit_mmap() questions

From Ingo Molnar <mingo@kernel.org>
Newsgroups linux.kernel
Subject Re: xen_exit_mmap() questions
Date 2017-04-27 08:30 +0200
Message-ID <tAL69-56M-3@gated-at.bofh.it> (permalink)
References <tACcy-7k3-5@gated-at.bofh.it> <tADV0-jp-17@gated-at.bofh.it> <tAE4F-mI-11@gated-at.bofh.it> <tAFWN-1s3-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


* 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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

xen_exit_mmap() questions Andy Lutomirski <luto@kernel.org> - 2017-04-26 23:00 +0200
  Re: xen_exit_mmap() questions Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2017-04-27 00:50 +0200
    Re: xen_exit_mmap() questions Andy Lutomirski <luto@kernel.org> - 2017-04-27 01:00 +0200
      Re: xen_exit_mmap() questions Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2017-04-27 03:00 +0200
        Re: xen_exit_mmap() questions Andy Lutomirski <luto@kernel.org> - 2017-04-27 03:10 +0200
          Re: xen_exit_mmap() questions Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2017-04-27 15:30 +0200
            Re: xen_exit_mmap() questions Andy Lutomirski <luto@kernel.org> - 2017-04-27 18:50 +0200
              Re: xen_exit_mmap() questions Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2017-04-27 22:10 +0200
                Re: xen_exit_mmap() questions Andy Lutomirski <luto@amacapital.net> - 2017-04-27 23:30 +0200
        Re: xen_exit_mmap() questions Ingo Molnar <mingo@kernel.org> - 2017-04-27 08:30 +0200
        Re: [Xen-devel] xen_exit_mmap() questions "Jan Beulich" <JBeulich@suse.com> - 2017-04-27 09:50 +0200

csiph-web