diff options
author | Christoph Lameter <clameter@sgi.com> | 2008-02-14 17:21:32 -0500 |
---|---|---|
committer | Christoph Lameter <christoph@stapp.engr.sgi.com> | 2008-02-14 18:30:01 -0500 |
commit | b7a49f0d4c34166ae84089d9f145cfaae1b0eec5 (patch) | |
tree | 716bd20c8b920511f032a42be78c0a523a17565d | |
parent | dada123d99c241d1a45798a7c77bcf99c4968704 (diff) |
slub: Determine gfpflags once and not every time a slab is allocated
Currently we determine the gfp flags to pass to the page allocator
each time a slab is being allocated.
Determine the bits to be set at the time the slab is created. Store
in a new allocflags field and add the flags in allocate_slab().
Acked-by: Mel Gorman <mel@csn.ul.ie>
Reviewed-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Christoph Lameter <clameter@sgi.com>
-rw-r--r-- | include/linux/slub_def.h | 1 | ||||
-rw-r--r-- | mm/slub.c | 19 |
2 files changed, 12 insertions, 8 deletions
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h index a849c472b845..98be113cf935 100644 --- a/include/linux/slub_def.h +++ b/include/linux/slub_def.h | |||
@@ -71,6 +71,7 @@ struct kmem_cache { | |||
71 | 71 | ||
72 | /* Allocation and freeing of slabs */ | 72 | /* Allocation and freeing of slabs */ |
73 | int objects; /* Number of objects in slab */ | 73 | int objects; /* Number of objects in slab */ |
74 | gfp_t allocflags; /* gfp flags to use on each alloc */ | ||
74 | int refcount; /* Refcount for slab cache destroy */ | 75 | int refcount; /* Refcount for slab cache destroy */ |
75 | void (*ctor)(struct kmem_cache *, void *); | 76 | void (*ctor)(struct kmem_cache *, void *); |
76 | int inuse; /* Offset to metadata */ | 77 | int inuse; /* Offset to metadata */ |
@@ -1078,14 +1078,7 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node) | |||
1078 | struct page *page; | 1078 | struct page *page; |
1079 | int pages = 1 << s->order; | 1079 | int pages = 1 << s->order; |
1080 | 1080 | ||
1081 | if (s->order) | 1081 | flags |= s->allocflags; |
1082 | flags |= __GFP_COMP; | ||
1083 | |||
1084 | if (s->flags & SLAB_CACHE_DMA) | ||
1085 | flags |= SLUB_DMA; | ||
1086 | |||
1087 | if (s->flags & SLAB_RECLAIM_ACCOUNT) | ||
1088 | flags |= __GFP_RECLAIMABLE; | ||
1089 | 1082 | ||
1090 | if (node == -1) | 1083 | if (node == -1) |
1091 | page = alloc_pages(flags, s->order); | 1084 | page = alloc_pages(flags, s->order); |
@@ -2333,6 +2326,16 @@ static int calculate_sizes(struct kmem_cache *s) | |||
2333 | if (s->order < 0) | 2326 | if (s->order < 0) |
2334 | return 0; | 2327 | return 0; |
2335 | 2328 | ||
2329 | s->allocflags = 0; | ||
2330 | if (s->order) | ||
2331 | s->allocflags |= __GFP_COMP; | ||
2332 | |||
2333 | if (s->flags & SLAB_CACHE_DMA) | ||
2334 | s->allocflags |= SLUB_DMA; | ||
2335 | |||
2336 | if (s->flags & SLAB_RECLAIM_ACCOUNT) | ||
2337 | s->allocflags |= __GFP_RECLAIMABLE; | ||
2338 | |||
2336 | /* | 2339 | /* |
2337 | * Determine the number of objects per slab | 2340 | * Determine the number of objects per slab |
2338 | */ | 2341 | */ |