Group short-lived and reclaimable kernel allocations
This patch marks a number of allocations that are either short-lived such as network buffers or are reclaimable such as inode allocations. When something like updatedb is called, long-lived and unmovable kernel allocations tend to be spread throughout the address space which increases fragmentation. This patch groups these allocations together as much as possible by adding a new MIGRATE_TYPE. The MIGRATE_RECLAIMABLE type is for allocations that can be reclaimed on demand, but not moved. i.e. they can be migrated by deleting them and re-reading the information from elsewhere. Signed-off-by: Mel Gorman <mel@csn.ul.ie> Cc: Andy Whitcroft <apw@shadowen.org> Cc: Christoph Lameter <clameter@sgi.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
c361be55b3
commit
e12ba74d8f
@@ -48,9 +48,10 @@ struct vm_area_struct;
|
||||
#define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u) /* Don't use emergency reserves */
|
||||
#define __GFP_HARDWALL ((__force gfp_t)0x20000u) /* Enforce hardwall cpuset memory allocs */
|
||||
#define __GFP_THISNODE ((__force gfp_t)0x40000u)/* No fallback, no policies */
|
||||
#define __GFP_MOVABLE ((__force gfp_t)0x80000u) /* Page is movable */
|
||||
#define __GFP_RECLAIMABLE ((__force gfp_t)0x80000u) /* Page is reclaimable */
|
||||
#define __GFP_MOVABLE ((__force gfp_t)0x100000u) /* Page is movable */
|
||||
|
||||
#define __GFP_BITS_SHIFT 20 /* Room for 20 __GFP_FOO bits */
|
||||
#define __GFP_BITS_SHIFT 21 /* Room for 21 __GFP_FOO bits */
|
||||
#define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
|
||||
|
||||
/* This equals 0, but use constants in case they ever change */
|
||||
@@ -60,6 +61,8 @@ struct vm_area_struct;
|
||||
#define GFP_NOIO (__GFP_WAIT)
|
||||
#define GFP_NOFS (__GFP_WAIT | __GFP_IO)
|
||||
#define GFP_KERNEL (__GFP_WAIT | __GFP_IO | __GFP_FS)
|
||||
#define GFP_TEMPORARY (__GFP_WAIT | __GFP_IO | __GFP_FS | \
|
||||
__GFP_RECLAIMABLE)
|
||||
#define GFP_USER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL)
|
||||
#define GFP_HIGHUSER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL | \
|
||||
__GFP_HIGHMEM)
|
||||
@@ -80,7 +83,7 @@ struct vm_area_struct;
|
||||
#endif
|
||||
|
||||
/* This mask makes up all the page movable related flags */
|
||||
#define GFP_MOVABLE_MASK (__GFP_MOVABLE)
|
||||
#define GFP_MOVABLE_MASK (__GFP_RECLAIMABLE|__GFP_MOVABLE)
|
||||
|
||||
/* Control page allocator reclaim behavior */
|
||||
#define GFP_RECLAIM_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS|\
|
||||
@@ -129,6 +132,12 @@ static inline enum zone_type gfp_zone(gfp_t flags)
|
||||
return base + ZONE_NORMAL;
|
||||
}
|
||||
|
||||
static inline gfp_t set_migrateflags(gfp_t gfp, gfp_t migrate_flags)
|
||||
{
|
||||
BUG_ON((gfp & GFP_MOVABLE_MASK) == GFP_MOVABLE_MASK);
|
||||
return (gfp & ~(GFP_MOVABLE_MASK)) | migrate_flags;
|
||||
}
|
||||
|
||||
/*
|
||||
* There is only one page-allocator function, and two main namespaces to
|
||||
* it. The alloc_page*() variants return 'struct page *' and as such
|
||||
|
||||
@@ -35,10 +35,12 @@
|
||||
|
||||
#ifdef CONFIG_PAGE_GROUP_BY_MOBILITY
|
||||
#define MIGRATE_UNMOVABLE 0
|
||||
#define MIGRATE_MOVABLE 1
|
||||
#define MIGRATE_TYPES 2
|
||||
#define MIGRATE_RECLAIMABLE 1
|
||||
#define MIGRATE_MOVABLE 2
|
||||
#define MIGRATE_TYPES 3
|
||||
#else
|
||||
#define MIGRATE_UNMOVABLE 0
|
||||
#define MIGRATE_UNRECLAIMABLE 0
|
||||
#define MIGRATE_MOVABLE 0
|
||||
#define MIGRATE_TYPES 1
|
||||
#endif
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
/* Bit indices that affect a whole block of pages */
|
||||
enum pageblock_bits {
|
||||
PB_range(PB_migrate, 1), /* 1 bit required for migrate types */
|
||||
PB_range(PB_migrate, 2), /* 2 bits required for migrate types */
|
||||
NR_PAGEBLOCK_BITS
|
||||
};
|
||||
|
||||
|
||||
@@ -24,12 +24,14 @@
|
||||
#define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
|
||||
#define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
|
||||
#define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
|
||||
#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are reclaimable */
|
||||
#define SLAB_PANIC 0x00040000UL /* Panic if kmem_cache_create() fails */
|
||||
#define SLAB_DESTROY_BY_RCU 0x00080000UL /* Defer freeing slabs to RCU */
|
||||
#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */
|
||||
#define SLAB_TRACE 0x00200000UL /* Trace allocations and frees */
|
||||
|
||||
/* The following flags affect the page allocator grouping pages by mobility */
|
||||
#define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Objects are reclaimable */
|
||||
#define SLAB_TEMPORARY SLAB_RECLAIM_ACCOUNT /* Objects are short-lived */
|
||||
/*
|
||||
* ZERO_SIZE_PTR will be returned for zero sized kmalloc requests.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user