All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <srostedt@redhat.com>
To: Keir Fraser <Keir.Fraser@cl.cam.ac.uk>
Cc: xen-devel <xen-devel@lists.xensource.com>, rostedt@goodmis.org
Subject: Re: [PATCH] binary or instead of logical in timer sync
Date: Thu, 03 Aug 2006 09:09:21 -0400	[thread overview]
Message-ID: <44D1F581.5080402@redhat.com> (raw)
In-Reply-To: <59affcc6c4073a1a72f5cd3b511fa006@cl.cam.ac.uk>

Keir Fraser wrote:
>
> On 3 Aug 2006, at 04:17, Steven Rostedt wrote:
>
>> The reading of a timer is determined if 1. the hypervisor is not 
>> currently updating it (where it sets the LSB of the version) or 2. 
>> the kernel didn't finish reading it before the hypervisor updated it 
>> (the kernel version doesn't match the hypervisor version).
>>
>> But the current code doesn't test the above case. Instead, by using a 
>> binary or instead of a logical one, it would only repeat if the 
>> hypervisor was updating  __and__ we read the version before it 
>> started updating (or we read it before we started updating, but the 
>> hypervisor finished updating between the first part of the or and the 
>> second check).
>
> I don't believe there is a bug here. Are you suggesting that the 
> binary or, used within a logical predicate, behaves as a logical and? 
> That doesn't make sense.

Crap, you're right.  I was debugging a problem with a bad timer, and saw 
that a binary or was being used for a logical case and just assumed that 
it was a bug.  Since it is common to see bugs like this using  & instead 
of &&.  So being late (and very hot here) I jumped the gun and posted 
the patch.

>
> The only reason for using binary operators in those predicates is to 
> avoid extra branches in the generated code which would probably be 
> generated to follow the short-circuiting semantics of the logical 
> operators. In fact, I think a smart optimising compiler would generate 
> the *same* object code regardless of whether we use binary/logical or 
> (but I don't believe gcc is that smart yet!).
>  

With some sleep behind me I see your point.  You're using the binary or 
to let the math determine the branch instead of logical jumps.

Makes sense,  sorry for the noise.

Hmm, perhaps a comment there is in order so another tired, hot and 
sticky programmer doesn't make the same mistake as I did :(


-- Steve

  reply	other threads:[~2006-08-03 13:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-03  3:17 [PATCH] binary or instead of logical in timer sync Steven Rostedt
2006-08-03 12:15 ` Keir Fraser
2006-08-03 13:09   ` Steven Rostedt [this message]
2006-08-04  4:27   ` Markus Armbruster

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=44D1F581.5080402@redhat.com \
    --to=srostedt@redhat.com \
    --cc=Keir.Fraser@cl.cam.ac.uk \
    --cc=rostedt@goodmis.org \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.