Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 56518
b: refs/heads/master
c: 0aa817f
h: refs/heads/master
v: v3
  • Loading branch information
Christoph Lameter authored and Linus Torvalds committed May 17, 2007
1 parent 6213b61 commit 811d936
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 72 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3ec0974210fe1b7c0618ad6e39a882a4237d7de2
refs/heads/master: 0aa817f078b655d0ae36669169d73a5c8a388016
8 changes: 0 additions & 8 deletions trunk/arch/blackfin/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -560,14 +560,6 @@ endchoice

source "mm/Kconfig"

config LARGE_ALLOCS
bool "Allow allocating large blocks (> 1MB) of memory"
help
Allow the slab memory allocator to keep chains for very large
memory sizes - upto 32MB. You may need this if your system has
a lot of RAM, and you need to able to allocate very large
contiguous chunks. If unsure, say N.

config BFIN_DMA_5XX
bool "Enable DMA Support"
depends on (BF533 || BF532 || BF531 || BF537 || BF536 || BF534 || BF561)
Expand Down
8 changes: 0 additions & 8 deletions trunk/arch/frv/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,6 @@ config HIGHPTE
with a lot of RAM, this can be wasteful of precious low memory.
Setting this option will put user-space page tables in high memory.

config LARGE_ALLOCS
bool "Allow allocating large blocks (> 1MB) of memory"
help
Allow the slab memory allocator to keep chains for very large memory
sizes - up to 32MB. You may need this if your system has a lot of
RAM, and you need to able to allocate very large contiguous chunks.
If unsure, say N.

source "mm/Kconfig"

choice
Expand Down
8 changes: 0 additions & 8 deletions trunk/arch/m68knommu/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -470,14 +470,6 @@ config AVNET
default y
depends on (AVNET5282)

config LARGE_ALLOCS
bool "Allow allocating large blocks (> 1MB) of memory"
help
Allow the slab memory allocator to keep chains for very large
memory sizes - upto 32MB. You may need this if your system has
a lot of RAM, and you need to able to allocate very large
contiguous chunks. If unsure, say N.

config 4KSTACKS
bool "Use 4Kb for kernel stacks instead of 8Kb"
default y
Expand Down
8 changes: 0 additions & 8 deletions trunk/arch/v850/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,6 @@ menu "Processor type and features"
config RESET_GUARD
bool "Reset Guard"

config LARGE_ALLOCS
bool "Allow allocating large blocks (> 1MB) of memory"
help
Allow the slab memory allocator to keep chains for very large
memory sizes - upto 32MB. You may need this if your system has
a lot of RAM, and you need to able to allocate very large
contiguous chunks. If unsure, say N.

source "mm/Kconfig"

endmenu
Expand Down
20 changes: 15 additions & 5 deletions trunk/include/linux/kmalloc_sizes.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,27 @@
CACHE(32768)
CACHE(65536)
CACHE(131072)
#if (NR_CPUS > 512) || (MAX_NUMNODES > 256) || !defined(CONFIG_MMU)
#if KMALLOC_MAX_SIZE >= 262144
CACHE(262144)
#endif
#ifndef CONFIG_MMU
#if KMALLOC_MAX_SIZE >= 524288
CACHE(524288)
#endif
#if KMALLOC_MAX_SIZE >= 1048576
CACHE(1048576)
#ifdef CONFIG_LARGE_ALLOCS
#endif
#if KMALLOC_MAX_SIZE >= 2097152
CACHE(2097152)
#endif
#if KMALLOC_MAX_SIZE >= 4194304
CACHE(4194304)
#endif
#if KMALLOC_MAX_SIZE >= 8388608
CACHE(8388608)
#endif
#if KMALLOC_MAX_SIZE >= 16777216
CACHE(16777216)
#endif
#if KMALLOC_MAX_SIZE >= 33554432
CACHE(33554432)
#endif /* CONFIG_LARGE_ALLOCS */
#endif /* CONFIG_MMU */
#endif
15 changes: 15 additions & 0 deletions trunk/include/linux/slab.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
}
#endif

/*
* The largest kmalloc size supported by the slab allocators is
* 32 megabyte (2^25) or the maximum allocatable page order if that is
* less than 32 MB.
*
* WARNING: Its not easy to increase this value since the allocators have
* to do various tricks to work around compiler limitations in order to
* ensure proper constant folding.
*/
#define KMALLOC_SHIFT_HIGH ((MAX_ORDER + PAGE_SHIFT) <= 25 ? \
(MAX_ORDER + PAGE_SHIFT) : 25)

#define KMALLOC_MAX_SIZE (1UL << KMALLOC_SHIFT_HIGH)
#define KMALLOC_MAX_ORDER (KMALLOC_SHIFT_HIGH - PAGE_SHIFT)

/*
* Common kmalloc functions provided by all allocators
*/
Expand Down
19 changes: 2 additions & 17 deletions trunk/include/linux/slub_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,6 @@ struct kmem_cache {
*/
#define KMALLOC_SHIFT_LOW 3

#ifdef CONFIG_LARGE_ALLOCS
#define KMALLOC_SHIFT_HIGH ((MAX_ORDER + PAGE_SHIFT) =< 25 ? \
(MAX_ORDER + PAGE_SHIFT - 1) : 25)
#else
#if !defined(CONFIG_MMU) || NR_CPUS > 512 || MAX_NUMNODES > 256
#define KMALLOC_SHIFT_HIGH 20
#else
#define KMALLOC_SHIFT_HIGH 18
#endif
#endif

/*
* We keep the general caches in an array of slab caches that are used for
* 2^x bytes of allocations.
Expand All @@ -79,15 +68,15 @@ extern struct kmem_cache kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
* Sorry that the following has to be that ugly but some versions of GCC
* have trouble with constant propagation and loops.
*/
static inline int kmalloc_index(int size)
static inline int kmalloc_index(size_t size)
{
/*
* We should return 0 if size == 0 but we use the smallest object
* here for SLAB legacy reasons.
*/
WARN_ON_ONCE(size == 0);

if (size > (1 << KMALLOC_SHIFT_HIGH))
if (size > KMALLOC_MAX_SIZE)
return -1;

if (size > 64 && size <= 96)
Expand All @@ -110,17 +99,13 @@ static inline int kmalloc_index(int size)
if (size <= 64 * 1024) return 16;
if (size <= 128 * 1024) return 17;
if (size <= 256 * 1024) return 18;
#if KMALLOC_SHIFT_HIGH > 18
if (size <= 512 * 1024) return 19;
if (size <= 1024 * 1024) return 20;
#endif
#if KMALLOC_SHIFT_HIGH > 20
if (size <= 2 * 1024 * 1024) return 21;
if (size <= 4 * 1024 * 1024) return 22;
if (size <= 8 * 1024 * 1024) return 23;
if (size <= 16 * 1024 * 1024) return 24;
if (size <= 32 * 1024 * 1024) return 25;
#endif
return -1;

/*
Expand Down
19 changes: 2 additions & 17 deletions trunk/mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,21 +568,6 @@ static void **dbg_userword(struct kmem_cache *cachep, void *objp)

#endif

/*
* Maximum size of an obj (in 2^order pages) and absolute limit for the gfp
* order.
*/
#if defined(CONFIG_LARGE_ALLOCS)
#define MAX_OBJ_ORDER 13 /* up to 32Mb */
#define MAX_GFP_ORDER 13 /* up to 32Mb */
#elif defined(CONFIG_MMU)
#define MAX_OBJ_ORDER 5 /* 32 pages */
#define MAX_GFP_ORDER 5 /* 32 pages */
#else
#define MAX_OBJ_ORDER 8 /* up to 1Mb */
#define MAX_GFP_ORDER 8 /* up to 1Mb */
#endif

/*
* Do not go above this order unless 0 objects fit into the slab.
*/
Expand Down Expand Up @@ -2002,7 +1987,7 @@ static size_t calculate_slab_order(struct kmem_cache *cachep,
size_t left_over = 0;
int gfporder;

for (gfporder = 0; gfporder <= MAX_GFP_ORDER; gfporder++) {
for (gfporder = 0; gfporder <= KMALLOC_MAX_ORDER; gfporder++) {
unsigned int num;
size_t remainder;

Expand Down Expand Up @@ -2148,7 +2133,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
* Sanity checks... these are all serious usage bugs.
*/
if (!name || in_interrupt() || (size < BYTES_PER_WORD) ||
(size > (1 << MAX_OBJ_ORDER) * PAGE_SIZE) || dtor) {
size > KMALLOC_MAX_SIZE || dtor) {
printk(KERN_ERR "%s: Early error in slab %s\n", __FUNCTION__,
name);
BUG();
Expand Down

0 comments on commit 811d936

Please sign in to comment.