[openib-general] Re: [PATCH] opensm: make cl_atomic functions atomic

Michael S. Tsirkin mst at mellanox.co.il
Mon Mar 6 09:29:07 PST 2006


Quoting r. Sasha Khapyorsky <sashak at voltaire.com>:
> Subject: Re: [PATCH] opensm: make cl_atomic functions atomic
> 
> On 16:23 Sun 05 Mar     , Fabian Tillier wrote:
> > 
> > Why aren't we using atomic operations here?  Does Linux not support
> > atomic increment/decrement in user-mode?
> 
> Do you mean 'asm/atomic.h' from linux kernel? If so it is kernel's code
> (many systems export it as /usr/include/asm/atomic.h however).
> 
> Also I'm not sure about licensing - how kernel's GPL is compatible with
> OpenSM's dual license?
> 
> Sasha.

Sasha, from experience, do not go this way - don't use directly or copy
asm/atomic.h.

It will break in enexpected ways, e.g. on my system I have
sm/atomic.h pulling in asm-x86_64/atomic.h, and that pulls in
#include <linux/config.h> which is typically not safe.

The right thing to do is to look at the implementation
and write your own for architectures that matter.
Use lock for others.

You will find kernel uses lots of tricks to make the code the most
generic, you dont need that.


-- 
Michael S. Tsirkin
Staff Engineer, Mellanox Technologies



More information about the general mailing list