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. -- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
- Follow-Ups:
- Re: [patch 00/23] Slab defragmentation V6
- From: Mel Gorman <[email protected]>
- Re: [patch 00/23] Slab defragmentation V6
- From: Peter Zijlstra <[email protected]>
- [patch 23/23] SLUB: Add SlabReclaimable() to avoid repeated reclaim attempts
- From: Christoph Lameter <[email protected]>
- [patch 22/23] SLUB: Slab reclaim through Lumpy reclaim
- From: Christoph Lameter <[email protected]>
- [patch 20/23] dentries: Add constructor
- From: Christoph Lameter <[email protected]>
- [patch 21/23] dentries: dentry defragmentation
- From: Christoph Lameter <[email protected]>
- [patch 17/23] FS: Proc filesystem support for slab defrag
- From: Christoph Lameter <[email protected]>
- [patch 19/23] FS: Socket inode defragmentation
- From: Christoph Lameter <[email protected]>
- [patch 18/23] FS: Slab defrag: Reiserfs support
- From: Christoph Lameter <[email protected]>
- [patch 15/23] FS: ExtX filesystem defrag
- From: Christoph Lameter <[email protected]>
- [patch 16/23] FS: XFS slab defragmentation
- From: Christoph Lameter <[email protected]>
- [patch 14/23] inodes: Support generic defragmentation
- From: Christoph Lameter <[email protected]>
- [patch 13/23] Buffer heads: Support slab defrag
- From: Christoph Lameter <[email protected]>
- [patch 12/23] SLUB: Trigger defragmentation from memory reclaim
- From: Christoph Lameter <[email protected]>
- [patch 11/23] SLUB: Slab defrag core
- From: Christoph Lameter <[email protected]>
- [patch 10/23] SLUB: Sort slab cache list and establish maximum objects for defrag slabs
- From: Christoph Lameter <[email protected]>
- [patch 09/23] SLUB: Add get() and kick() methods
- From: Christoph Lameter <[email protected]>
- [patch 08/23] SLUB: 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_cache
- From: Christoph Lameter <[email protected]>
- [patch 07/23] SLUB: Add defrag_ratio field and sysfs support.
- From: Christoph Lameter <[email protected]>
- [patch 06/23] SLUB: Extend slabinfo to support -D and -C options
- From: Christoph Lameter <[email protected]>
- [patch 05/23] VM: Allow get_page_unless_zero on compound pages
- From: Christoph Lameter <[email protected]>
- [patch 04/23] dentries: Extract common code to remove dentry from lru
- From: Christoph Lameter <[email protected]>
- [patch 03/23] bufferhead: Revert constructor removal
- From: Christoph Lameter <[email protected]>
- [patch 02/23] SLUB: Rename NUMA defrag_ratio to remote_node_defrag_ratio
- From: Christoph Lameter <[email protected]>
- [patch 01/23] SLUB: Move count_partial()
- From: Christoph Lameter <[email protected]>
- Re: [patch 00/23] Slab defragmentation V6
- Prev by Date: Re: [PATCH] NetLabel: Introduce a new kernel configuration API for NetLabel - For 2.6.24-rc-git11 - Smack Version 10
- Next by Date: [patch 01/23] SLUB: Move count_partial()
- Previous by thread: [PATCH] fix up perfmon to build on -mm
- Next by thread: [patch 01/23] SLUB: Move count_partial()
- Index(es):