Re: [PATCH -v3 2/8] lib, Make gen_pool memory allocator lock-less

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Andi Kleen
Date: Wednesday, October 27, 2010 - 2:17 am

> --- a/lib/genalloc.c

I think we need some more description here about the locklessness:

How about adding to the comment:

This version of the allocator supports lockless operation.

This makes it safe to use in NMI handlers and other special unblockable
contexts that could otherwise deadlock on locks.  This is implemented by 
using atomic operations and retries on any conflicts. 
The disadvantage is that there may be livelocks in extreme cases.  

The lockless operation only works if there is enough memory
available. If new memory is added to the pool a lock has to 
be still taken. So any user relying on locklessness has to ensure
that sufficient memory is preallocated.

The basic atomic operation of this allocator is cmpxchg on long. 
On architectures that don't support cmpxchg natively a fallback
is used. If the fallback uses locks it may not be safe to use
it in NMI contexts on these architectures.


I believe that's not safe in a lockless context right?
Should note that.


-Andi

-- 
ak@linux.intel.com -- Speaking for myself only.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH -v3 0/8] ACPI, APEI patches for 2.6.37, Huang Ying, (Tue Oct 26, 10:28 pm)
[PATCH -v3 1/8] ACPI, APEI, Add ERST record ID cache, Huang Ying, (Tue Oct 26, 10:28 pm)
[PATCH -v3 4/8] Hardware error device core, Huang Ying, (Tue Oct 26, 10:28 pm)
Re: [PATCH -v3 2/8] lib, Make gen_pool memory allocator lo ..., Andi Kleen, (Wed Oct 27, 2:17 am)
Re: [PATCH -v3 0/8] ACPI, APEI patches for 2.6.37, Peter Zijlstra, (Wed Oct 27, 3:07 am)
Re: [PATCH -v3 0/8] ACPI, APEI patches for 2.6.37, Randy Dunlap, (Wed Oct 27, 8:27 am)
Re: [PATCH -v3 0/8] ACPI, APEI patches for 2.6.37, Andi Kleen, (Wed Oct 27, 10:23 am)
Re: [PATCH -v3 0/8] ACPI, APEI patches for 2.6.37, Ingo Molnar, (Thu Oct 28, 9:01 am)
Re: [PATCH -v3 0/8] ACPI, APEI patches for 2.6.37, huang ying, (Sun Oct 31, 4:36 am)