Skip to content

SLUB: Lockless freelists for objects V5

Christoph Lameter linux-mm 1 version Applied

Status from this message: Applied, with fixed changelog. Thanks!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest25 patches 28 repliesApplied

V2->V3 from the cover letter

- Provide statistics
- Fallback logic to page lock if cmpxchg16b is not available.
- Better counter support
- More cleanups and clarifications

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/25slub: Avoid warning for !CONFIG_SLUB_DEBUGmm/slub.c+1 -10 replies
2/25slub: Fix control flow in slab_allocmm/slub.c+3 -30 replies
3/25slub: Make CONFIG_PAGE_ALLOC work with new fastpathmm/slub.c+13 -13 replies
4/25slub: Push irq disable into allocate_slab()mm/slub.c+11 -100 replies
5/25slub: Do not use frozen page flag but a bit in the page countersinclude/linux/mm_types.h include/linux/page-flags.h mm/slub.c+9 -100 replies
6/25slub: Move page->frozen handling near where the page->freelist handling occursmm/slub.c+6 -20 replies
7/25x86: Add support for cmpxchg_doublearch/x86/Kconfig.cpu arch/x86/include/asm/cmpxchg_32.h arch/x86/include/asm/cmpxchg_64.h +1 more+95 -025 replies
8/25mm: Rearrange struct pageinclude/linux/mm_types.h+60 -290 replies
9/25slub: Add cmpxchg_double_slab()include/linux/slub_def.h mm/slub.c+46 -00 replies
10/25slub: explicit list_lock takingmm/slub.c+36 -380 replies
11/25slub: Pass kmem_cache struct to lock and freeze slabmm/slub.c+7 -60 replies
12/25slub: Rework allocator fastpathsmm/slub.c+282 -1310 replies
13/25slub: Invert locking and avoid slab lockmm/slub.c+53 -780 replies
14/25slub: Disable interrupts in free_debug processingmm/slub.c+10 -40 replies
15/25slub: Avoid disabling interrupts in free slowpathmm/slub.c+5 -110 replies
16/25slub: Get rid of the another_slab labelmm/slub.c+5 -60 replies
17/25slub: Add statistics for the case that the current slab does not match the nodeinclude/linux/slub_def.h mm/slub.c+4 -00 replies
18/25slub: fast release on full slabinclude/linux/slub_def.h mm/slub.c+20 -20 replies
19/25slub: Not necessary to check for empty slab on load_freelistmm/slub.c+2 -30 replies
20/25slub: slabinfo update for cmpxchg handlingtools/slub/slabinfo.c+39 -180 replies
21/25slub: Prepare inuse field in new_slab()mm/slub.c+2 -30 replies
22/25slub: pass kmem_cache_cpu pointer to get_partial()mm/slub.c+15 -150 replies
23/25slub: return object pointer from get_partial() / new_slab().mm/slub.c+73 -570 replies
24/25slub: Remove gotos from __slab_free()mm/slub.c+23 -230 replies
25/25slub: Remove gotos from __slab_alloc()mm/slub.c+87 -680 replies

Reviews trailers per patch

None of the 25 patches has a Reviewed-by or Acked-by.

PatchH. Peter Anvin
1/25
2/25
3/25
4/25
5/25
6/25
7/25Nacked-by
8/25
9/25
10/25
11/25
12/25
13/25
14/25
15/25
16/25
17/25
18/25
19/25
20/25
21/25
22/25
23/25
24/25
25/25

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [slubllv5 00/25] SLUB: Lockless freelists for objects V5

V4->V5 - More cleanup. Remove gotos from __slab_alloc and __slab_free
- Some structural changes to alloc and free to clean up the code
- Statistics modifications folded in other patches.
- Fixes to patches already in Pekka's slabnext.
- Include missing upstream fixes

V3->V4 - Diffed against Pekka's slab/next tree.
- Numerous cleanups in particular as a result of the removal of the #ifdef CMPXCHG_LOCAL stuff.
- Smaller cleanups whereever I saw something.

V2->V3
- Provide statistics
- Fallback logic to page lock if cmpxchg16b is not available.
- Better counter support
- More cleanups and clarifications

Well here is another result of my obsession with SLAB allocators. There must be some way to get an allocator done that is faster without queueing and I hope that we are now there (maybe only almost...). Any help with cleaning up the rough edges would be appreciated.

This patchset implement wider lockless operations in slub affecting most of the slowpaths. In particular the patch decreases the overhead in the performance critical section of __slab_free.

One test that I ran was "hackbench 200 process 200" on 2.6.29-rc3 under KVM

Run SLAB SLUB SLUB LL
1st 35.2 35.9 31.9
2nd 34.6 30.8 27.9
3rd 33.8 29.9 28.8

Note that the SLUB version in 2.6.29-rc1 already has an optimized allocation and free path using this_cpu_cmpxchg_double(). SLUB LL takes it to new heights by also using cmpxchg_double() in the slowpaths (especially in the kfree() case where we frequently cannot use the fastpath because there is no queue).

The patch uses a cmpxchg_double (also introduced here) to do an atomic change on the state of a slab page that includes the following pieces of information:

1. Freelist pointer
2. Number of objects inuse
3. Frozen state of a slab

Disabling of interrupts (which is a significant latency in the allocator paths) is avoided in the __slab_free case.

There are some concerns with this patch. The use of cmpxchg_double on fields of the page struct requires alignment of the fields to double word boundaries. That can only be accomplished by adding some padding to struct page which blows it up to 64 byte (on x86_64). Comments in the source describe these things in more detail.

The cmpxchg_double() operation introduced here could also be used to update other doublewords in the page struct in a lockless fashion. One can envision page state changes that involved flags and mappings or maybe do list operations locklessly (but with the current scheme we would need to update two other words elsewhere at the same time too, so another scheme would be needed).

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>