WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] code question?

To: Jerone Young <jyoung5@xxxxxxxxxx>
Subject: Re: [Xen-devel] code question?
From: "M.A. Williamson" <maw48@xxxxxxxxx>
Date: 11 Aug 2005 18:03:20 +0100
Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Thu, 11 Aug 2005 17:02:03 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1123775716.3043.15.camel@thinkpad>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1123775716.3043.15.camel@thinkpad>
Reply-to: mark.williamson@xxxxxxxxxxxx
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Doing some janitorial (you cleaning the flooded toilets and such) work
today. I have come across this line of code that really I'm not sure
what the intent was..in xen/include/sched.h

#define hypercall_preempt_check() (unlikely(            \
       softirq_pending(smp_processor_id()) |           \
       (!!current->vcpu_info->evtchn_upcall_pending &  \
         !current->vcpu_info->evtchn_upcall_mask)      \
   ))

the part where we have !!current->vcpu_info_evtchen_upcall pending
should this be..should the "!! just be "!"?

I think that:
!!a & !b === (a != 0 ) && ( b == 0 )

It's just more efficient to do it directly using bitwise ops than to use the full logical operators (can gcc really not optimise this sort of thing???).

Cheers,
Mark

And if so shouldn't this just be changed to
#define hypercall_preempt_check() (unlikely( \
        softirq_pending(smp_processor_id()) |           \
        (!(current->vcpu_info->evtchn_upcall_pending & \
          current->vcpu_info->evtchn_upcall_mask)) \
        ))
        

In a lot of the code in Xen we are using the "!" operator with bitwise
operations..this is one of those examples.





_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>