From mboxrd@z Thu Jan 1 00:00:00 1970 From: compudj@krystal.dyndns.org (Mathieu Desnoyers) Date: Fri, 12 Nov 2010 07:29:39 -0500 Subject: [ltt-dev] [PATCH 2/2] introduce uatomic_and and uatomic_or In-Reply-To: <4CDD31E7.1050500@redhat.com> References: <1289552247-18130-1-git-send-email-pbonzini@redhat.com> <1289552247-18130-3-git-send-email-pbonzini@redhat.com> <20101112120846.GB27929@Krystal> <4CDD2F69.7020407@redhat.com> <20101112121900.GA29642@Krystal> <4CDD31E7.1050500@redhat.com> Message-ID: <20101112122939.GA30826@Krystal> * Paolo Bonzini (pbonzini at redhat.com) wrote: > On 11/12/2010 01:19 PM, Mathieu Desnoyers wrote: >> * Paolo Bonzini (pbonzini at redhat.com) wrote: >>> Return nothing can be useful because it can be optimized on x86 as "lock >>> orl (mem), reg/imm". However, there are no other return-nothing atomic >>> ops in uatomic_*.h so I decided not to provide this. >>> >> >> How about we start by implementing uatomic_and/uatomic_or that return >> void, and if we ever need uatomic_return_and/uatomic_return_or (see my >> other mail), we add them ? > > I am using uatomic_or's return value in my call_rcu-with-futex, but I > don't need atomic-or-and-exchange really, I can even change it to a load > followed by an atomic or (it introduces a race but it is benign). If the race does not matter, why do we need the new atomic op in the first place ? ;) > Or I > can certainly use cmpxchg too. Updated patches will come. > > Should I rename uatomic_add to uatomic_xchg_add too (I prefer this name > to uatomic_return_add)? Renaming uatomic_add ? I don't understand what you are trying to achieve here. uatomic_add returns void, doesn't it ? (generally speaking, I agree that uatomic_xchg_op is nicer than uatomic_return_op) Thanks, Mathieu -- Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com