[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 0/5] use mask operations instead of test_bit()



On Fri, 2015-10-02 at 06:40 +0200, Juergen Gross wrote:
> Instead of using test_bit() which is an atomic operation and limits
> the compiler's choices to do optimization, use logical ANDs with
> bitmasks where possible.
> 
That's a good idea, I think.

> The possible candidates have been detected by searching definitions
> of bitmasks in the form:
> 
> #define MASK  1 << _MASK
> 
Right.

> On x86 the resulting code is slightly smaller (about 2 bytes for each
> case, checked via disassembly in few examples).
> 
> I'm quite sure I didn't replace a test_bit() call required to be
> atomic, but I'd be grateful for a thorough review especially in the
> scheduler.
> 
I'll have a deep look.

One question, can we introduce a __test_bit() macro/inline function,
like Jan did with __set_bit?

I've quickly-&-dirtily tested this:

#define __test_bit(nr, addr) ({  \
    unsigned _flags = 1 << nr;   \
    addr & _flags; \
})

and the result (I've checked a couple of cases) seems the same to me.

Regards,
Dario
-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.