Re: atomic RAM ?

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Alan Cox
Date: Thursday, April 8, 2010 - 3:45 am

>  - no normal processor "read-modify-write" instructions that by design

Take a look at sparc 32bit. That only has a single meaningful atomic
instruction (swap byte with 0xFF). It provides all the kernel atomic_t
operations via this: arch/sparc/lib/atomic32.c. That bitops are done a
similar way, which leaves spinlocks and the like.

More importantly if your true locks in the FPGA are really fast in CPU
terms then you can think of every other atomic instructions as being
implemented using

		lock(cpu_atomic_instruction_lock)
		do bits
		unlock(cpu_atomic_instruction_lock)

(its just this is normally done in hardware/microcode)

Doing it per instruction might be a bit naïve but I think you can
reasonably do it so that things like spinlocks use a single (or a hashed
set) of non kernel locks to implement "atomic" instructions, and as
sparc32 shows you only need a tiny subset of them to implement the rest
in their terms.

So I don't actually think you need any kernel core changes to get going,
and given the kernel dynamically allocates a lot of locks I suspect
trying to dynamically manage atomic ram allocations is going to cost more
than executing a few instructions here and there under a single very fast
hardware assisted lock.

Alan
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
atomic RAM ?, Michael Schnell, (Thu Apr 8, 12:32 am)
Re: atomic RAM ?, Michael Schnell, (Thu Apr 8, 2:52 am)
Re: atomic RAM ?, Michael Schnell, (Thu Apr 8, 3:12 am)
Re: atomic RAM ?, Alan Cox, (Thu Apr 8, 3:45 am)
Re: atomic RAM ?, Michael Schnell, (Thu Apr 8, 5:11 am)
Re: atomic RAM ?, David Miller, (Thu Apr 8, 5:14 am)
Re: atomic RAM ?, Michael Schnell, (Thu Apr 8, 5:30 am)
Re: atomic RAM ?, Alan Cox, (Thu Apr 8, 6:37 am)
Re: atomic RAM ?, Arnd Bergmann, (Thu Apr 8, 7:15 am)
Re: atomic RAM ?, Mike Frysinger, (Thu Apr 8, 6:36 pm)
Re: atomic RAM ?, Michael Schnell, (Fri Apr 9, 2:23 am)
Re: atomic RAM ?, Michael Schnell, (Fri Apr 9, 3:54 am)
Re: atomic RAM ?, Michael Schnell, (Fri Apr 9, 3:55 am)
Re: atomic RAM ?, Alan Cox, (Fri Apr 9, 4:54 am)
Re: atomic RAM ?, Michael Schnell, (Fri Apr 9, 5:53 am)
Re: atomic RAM ?, Michael Schnell, (Fri Apr 9, 6:14 am)
Re: atomic RAM ?, Alan Cox, (Fri Apr 9, 6:15 am)
Re: atomic RAM ?, Michael Schnell, (Fri Apr 9, 6:32 am)
Re: atomic RAM ?, Michael Schnell, (Mon Apr 12, 2:58 am)
Re: atomic RAM ?, Pavel Machek, (Mon Apr 12, 5:54 am)
Re: atomic RAM ?, Arnd Bergmann, (Mon Apr 12, 8:02 am)
Re: [Nios2-dev] atomic RAM ?, Michael Schnell, (Tue Apr 13, 1:39 am)
Re: atomic RAM ?, Michael Schnell, (Tue Apr 13, 3:11 am)
Re: atomic RAM ?, Michael Schnell, (Wed Apr 14, 1:42 am)
Re: atomic RAM ?, Michael Schnell, (Wed Apr 14, 5:46 am)
Re: atomic RAM ?, Alan Cox, (Wed Apr 14, 5:57 am)
Re: atomic RAM ?, Michael Schnell, (Wed Apr 14, 7:38 am)