Re: Lockless uidinfo.



On Wed, Aug 22, 2007 at 09:02:53PM +0200, Attilio Rao wrote:
2007/8/21, Pawel Jakub Dawidek <pjd@xxxxxxxxxxx>:

New patch is here:

http://people.freebsd.org/~pjd/patches/uidinfo_waitfree.patch

--- sys/ia64/include/atomic.h.orig
+++ sys/ia64/include/atomic.h
@@ -370,4 +370,15 @@

#define atomic_fetchadd_int atomic_fetchadd_32

+static __inline u_long
+atomic_fetchadd_long(volatile u_long *p, u_long v)
+{
+ u_long value;
+
+ do {
+ value = *p;
+ } while (!atomic_cmpset_64(p, value, value + v));
+ return (value);
+}
+

In cycles like those, as you get spinning, I would arrange things in
order to do a cpu_spinwait(). Like this:

for (;;) {
value = *p;
if (atomic_cmpset_64(p, value, value + v))
break;
cpu_spinwait();
}

In this case there is no difference as this is MI ia64 code and
cpu_spinwait() is defined as /* nothing */ there. As a general rule,
this might be a good idea.

--
Pawel Jakub Dawidek http://www.wheel.pl
pjd@xxxxxxxxxxx http://www.FreeBSD.org
FreeBSD committer Am I Evil? Yes, I Am!

Attachment: pgpRls5SGUoeM.pgp
Description: PGP signature



Relevant Pages

  • Re: Lockless uidinfo.
    ... New patch is here: ... In cycles like those, as you get spinning, I would arrange things in ... Peace can only be achieved by understanding - A. Einstein ...
    (freebsd-arch)
  • Re: Lockless uidinfo.
    ... New patch is here: ... In cycles like those, as you get spinning, I would arrange things in ... In this case there is no difference as this is MI ia64 code and ...
    (freebsd-arch)
  • Re: [PATCH 06/23 -v8] handle accurate time keeping over long delays
    ... accumulated clock cycles. ... which is the same as the underlying hardware counter. ... dealing properly with the clocksource wrap issue (ACPI PM ... get_monotonic_cyclespatch. ...
    (Linux-Kernel)
  • Re: iwi leaks memory?
    ... cycles to trigger it, but it might be worth trying it. ... The patch is attached. ... The driver did not complain after 100 down/up cycles. ...
    (freebsd-net)
  • Re: [CRYPTO] is it really optimized ?
    ... So the gain is 16000 cycles which seems to worth the change, ... It would help of course if you posted the patch:) ...
    (Linux-Kernel)