Skip to content

Slab defragmentation V6

Christoph Lameter linux-mm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest23 patches 55 repliesIn review

V5->V6 from the cover letter

- Rediff against 2.6.24-rc2 + mm slub patches.
- Add reviewed by lines.
- Take out the experimental code to make slab pages movable. That has to wait until this has been considered by Mel.

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/23SLUB: Move count_partial()mm/slub.c+13 -130 replies
2/23SLUB: Rename NUMA defrag_ratio to remote_node_defrag_ratioinclude/linux/slub_def.h mm/slub.c+13 -910 replies
3/23bufferhead: Revert constructor removalfs/buffer.c+15 -40 replies
4/23dentries: Extract common code to remove dentry from lrufs/dcache.c+14 -286 replies
5/23VM: Allow get_page_unless_zero on compound pagesinclude/linux/mm.h+1 -10 replies
6/23SLUB: Extend slabinfo to support -D and -C optionsDocumentation/vm/slabinfo.c+44 -81 reply
7/23SLUB: Add defrag_ratio field and sysfs support.include/linux/slub_def.h mm/slub.c+25 -04 replies
8/23SLUB: Replace ctor field with ops field in /sys/slab/:0000008 /sys/slab/:0000016 /sys/slab/:0000024 /sys/slab/:0000032 /sys/slab/:0000040 /sys/slab/:0000048 /sys/slab/:0000056 /sys/slab/:0000064 /sys/slab/:0000072 /sys/slab/:0000080 /sys/slab/:0000088 /sys/slab/:0000096 /sys/slab/:0000104 /sys/slab/:0000128 /sys/slab/:0000144 /sys/slab/:0000184 /sys/slab/:0000192 /sys/slab/:0000216 /sys/slab/:0000256 /sys/slab/:0000344 /sys/slab/:0000384 /sys/slab/:0000448 /sys/slab/:0000512 /sys/slab/:0000768 /sys/slab/:0000968 /sys/slab/:0001024 /sys/slab/:0001152 /sys/slab/:0001312 /sys/slab/:0001536 /sys/slab/:0002048 /sys/slab/:0003072 /sys/slab/:0004096 /sys/slab/:a-0000016 /sys/slab/:a-0000024 /sys/slab/:a-0000056 /sys/slab/:a-0000080 /sys/slab/:a-0000128 /sys/slab/Acpi-Namespace /sys/slab/Acpi-Operand /sys/slab/Acpi-Parse /sys/slab/Acpi-ParseExt /sys/slab/Acpi-State /sys/slab/RAW /sys/slab/TCP /sys/slab/UDP /sys/slab/UDP-Lite /sys/slab/UNIX /sys/slab/anon_vma /s ys/slab/arp_cache /sys/slab/bdev_cache /sys/slab/bio /sys/slab/biovec-1 /sys/slab/biovec-128 /sys/slab/biovec-16 /sys/slab/biovec-256 /sys/slab/biovec-4 /sys/slab/biovec-64 /sys/slab/blkdev_ioc /sys/slab/blkdev_queue /sys/slab/blkdev_requests /sys/slab/buffer_head /sys/slab/cfq_io_context /sys/slab/cfq_queue /sys/slab/dentry /sys/slab/eventpoll_epi /sys/slab/eventpoll_pwq /sys/slab/ext2_inode_cache /sys/slab/ext3_inode_cache /sys/slab/fasync_cache /sys/slab/file_lock_cache /sys/slab/files_cache /sys/slab/filp /sys/slab/flow_cache /sys/slab/fs_cache /sys/slab/idr_layer_cache /sys/slab/inet_peer_cache /sys/slab/inode_cache /sys/slab/inotify_event_cache /sys/slab/inotify_watch_cache /sys/slab/ip_dst_cache /sys/slab/ip_fib_alias /sys/slab/ip_fib_hash /sys/slab/jbd_1k /sys/slab/jbd_4k /sys/slab/journal_handle /sys/slab/journal_head /sys/slab/kiocb /sys/slab/kioctx /sys/slab/kmalloc-1024 /sys/slab/kmalloc-128 /sys/slab/kmalloc-16 /sys/slab/kmalloc-192 /sys/slab/kmalloc-2048 /sys/s lab/kmalloc-256 /sys/slab/kmalloc-32 /sys/slab/kmalloc-512 /sys/slab/kmalloc-64 /sys/slab/kmalloc-8 /sys/slab/kmalloc-96 /sys/slab/mm_struct /sys/slab/mnt_cache /sys/slab/mqueue_inode_cache /sys/slab/names_cache /sys/slab/net_namespace /sys/slab/nfs_direct_cache /sys/slab/nfs_inode_cache /sys/slab/nfs_page /sys/slab/nfs_read_data /sys/slab/nfs_write_data /sys/slab/nfsd4_delegations /sys/slab/nfsd4_files /sys/slab/nfsd4_stateids /sys/slab/nfsd4_stateowners /sys/slab/nsproxy /sys/slab/pid /sys/slab/posix_timers_cache /sys/slab/proc_inode_cache /sys/slab/radix_tree_node /sys/slab/request_sock_TCP /sys/slab/revoke_record /sys/slab/revoke_table /sys/slab/rpc_buffers /sys/slab/rpc_inode_cache /sys/slab/rpc_tasks /sys/slab/scsi_cmd_cache /sys/slab/scsi_io_context /sys/slab/secpath_cache /sys/slab/sgpool-128 /sys/slab/sgpool-16 /sys/slab/sgpool-32 /sys/slab/sgpool-64 /sys/slab/sgpool-8 /sys/slab/shmem_inode_cache /sys/slab/sighand_cache /sys/slab/signal_cache /sys/slab/sigqueue /sys /slab/skbuff_fclone_cache /sys/slab/skbuff_head_cache /sys/slab/sock_inode_cache /sys/slab/sysfs_dir_cache /sys/slab/task_struct /sys/slab/tcp_bind_bucket /sys/slab/tw_sock_TCP /sys/slab/uhci_urb_priv /sys/slab/uid_cache /sys/slab/vm_area_struct /sys/slab/xfrm_dst_cachemm/slub.c+9 -70 replies
9/23SLUB: Add get() and kick() methodsinclude/linux/slab.h include/linux/slub_def.h mm/slub.c+64 -23 replies
10/23SLUB: Sort slab cache list and establish maximum objects for defrag slabsmm/slub.c+17 -20 replies
11/23SLUB: Slab defrag coremm/slab.c mm/slub.c+222 -581 reply
12/23SLUB: Trigger defragmentation from memory reclaimfs/drop_caches.c include/linux/mm.h include/linux/slab.h +1 more+22 -94 replies
13/23Buffer heads: Support slab defragfs/buffer.c+102 -10 replies
14/23inodes: Support generic defragmentationfs/inode.c include/linux/fs.h+102 -07 replies
15/23FS: ExtX filesystem defragfs/ext2/super.c fs/ext3/super.c fs/ext4/super.c+25 -00 replies
16/23FS: XFS slab defragmentationfs/xfs/linux-2.6/xfs_super.c+1 -00 replies
17/23FS: Proc filesystem support for slab defragfs/proc/inode.c+8 -00 replies
18/23FS: Slab defrag: Reiserfs supportfs/reiserfs/super.c+8 -00 replies
19/23FS: Socket inode defragmentationnet/socket.c+8 -00 replies
20/23dentries: Add constructorfs/dcache.c+14 -122 replies
21/23dentries: dentry defragmentationfs/dcache.c+100 -10 replies
22/23SLUB: Slab reclaim through Lumpy reclaiminclude/linux/slab.h mm/slab.c mm/slub.c +1 more+123 -70 replies
23/23SLUB: Add SlabReclaimable() to avoid repeated reclaim attemptsmm/slub.c+17 -30 replies

Reviews trailers per patch

All 23 patches have a Reviewed-by or Acked-by.

PatchRik van RielJoern Engel
1/23R-b
2/23R-b
3/23R-b
4/23R-b A-b A-b
5/23R-b
6/23R-b
7/23R-b
8/23R-b
9/23R-b
10/23R-b
11/23R-b
12/23R-b
13/23R-b
14/23R-b
15/23R-b
16/23R-b
17/23R-b
18/23R-b
19/23R-b
20/23R-b
21/23R-b
22/23R-b
23/23R-b

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

Read the v1 thread

Cover letter [patch 00/23] Slab defragmentation V6

Slab defragmentation is mainly an issue if Linux is used as a fileserver and large amounts of dentries, inodes and buffer heads accumulate. In some load situations the slabs become very sparsely populated so that a lot of memory is wasted by slabs that only contain one or a few objects. In extreme cases the performance of a machine will become sluggish since we are continually running reclaim. Slab defragmentation adds the capability to recover wasted memory.

With lumpy reclaim slab defragmentation can be used to enhance the ability to recover larger contiguous areas of memory. Lumpy reclaim currently cannot do anything if a slab page is encountered. With slab defragmentation that slab page can be removed and a large contiguous page freed. It may be possible to have slab pages also part of ZONE_MOVABLE (Mel's defrag scheme in 2.6.23) or the MOVABLE areas (antifrag patches in mm).

The patchset is also available via git

git pull git://git.kernel.org/pub/scm/linux/kernel/git/christoph/slab.git defrag

Currently memory reclaim from the following slab caches is possible:

1. dentry cache
2. inode cache (with a generic interface to allow easy setup of more filesystems than the currently supported ext2/3/4 reiserfs, XFS and proc)
3. buffer_heads

One typical mechanism that triggers slab defragmentation on my systems is the daily run of

updatedb

Updatedb scans all files on the system which causes a high inode and dentry use. After updatedb is complete we need to go back to the regular use patterns (typical on my machine: kernel compiles). Those need the memory now for different purposes. The inodes and dentries used for updatedb will gradually be aged by the dentry/inode reclaim algorithm which will free up the dentries and inode entries randomly through the slabs that were allocated. As a result the slabs will become sparsely populated. If they become empty then they can be freed but a lot of them will remain sparsely populated. That is where slab defrag comes in: It removes the slabs with just a few entries reclaiming more memory for other uses.

V5->V6
- Rediff against 2.6.24-rc2 + mm slub patches.
- Add reviewed by lines.
- Take out the experimental code to make slab pages movable. That has to wait until this has been considered by Mel.

V4->V5:
- Support lumpy reclaim for slabs
- Support reclaim via slab_shrink()
- Add constructors to insure a consistent object state at all times.

V3->V4:
- Optimize scan for slabs that need defragmentation
- Add /sys/slab/*/defrag_ratio to allow setting defrag limits per slab.
- Add support for buffer heads.
- Describe how the cleanup after the daily updatedb can be improved by slab defragmentation.

V2->V3
- Support directory reclaim
- Add infrastructure to trigger defragmentation after slab shrinking if we have slabs with a high degree of fragmentation.

V1->V2
- Clean up control flow using a state variable. Simplify API. Back to 2 functions that now take arrays of objects.
- Inode defrag support for a set of filesystems
- Fix up dentry defrag support to work on negative dentries by adding a new dentry flag that indicates that a dentry is not in the process of being freed or allocated.