Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 60738
b: refs/heads/master
c: 2e443fd
h: refs/heads/master
v: v3
  • Loading branch information
Christoph Lameter authored and Linus Torvalds committed Jul 17, 2007
1 parent 3fc8425 commit cb690df
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 31 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: 0c710013200e72b5e0bc680ff4ec6bdac53c5ce8
refs/heads/master: 2e443fd003d76394a8ceb78f079260478aa10710
66 changes: 36 additions & 30 deletions trunk/mm/slub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2272,6 +2272,40 @@ static struct kmem_cache *create_kmalloc_cache(struct kmem_cache *s,
panic("Creation of kmalloc slab %s size=%d failed.\n", name, size);
}

#ifdef CONFIG_ZONE_DMA
static noinline struct kmem_cache *dma_kmalloc_cache(int index, gfp_t flags)
{
struct kmem_cache *s;
struct kmem_cache *x;
char *text;
size_t realsize;

s = kmalloc_caches_dma[index];
if (s)
return s;

/* Dynamically create dma cache */
x = kmalloc(kmem_size, flags & ~SLUB_DMA);
if (!x)
panic("Unable to allocate memory for dma cache\n");

if (index <= KMALLOC_SHIFT_HIGH)
realsize = 1 << index;
else {
if (index == 1)
realsize = 96;
else
realsize = 192;
}

text = kasprintf(flags & ~SLUB_DMA, "kmalloc_dma-%d",
(unsigned int)realsize);
s = create_kmalloc_cache(x, text, realsize, flags);
kmalloc_caches_dma[index] = s;
return s;
}
#endif

static struct kmem_cache *get_slab(size_t size, gfp_t flags)
{
int index = kmalloc_index(size);
Expand All @@ -2284,36 +2318,8 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
return NULL;

#ifdef CONFIG_ZONE_DMA
if ((flags & SLUB_DMA)) {
struct kmem_cache *s;
struct kmem_cache *x;
char *text;
size_t realsize;

s = kmalloc_caches_dma[index];
if (s)
return s;

/* Dynamically create dma cache */
x = kmalloc(kmem_size, flags & ~SLUB_DMA);
if (!x)
panic("Unable to allocate memory for dma cache\n");

if (index <= KMALLOC_SHIFT_HIGH)
realsize = 1 << index;
else {
if (index == 1)
realsize = 96;
else
realsize = 192;
}

text = kasprintf(flags & ~SLUB_DMA, "kmalloc_dma-%d",
(unsigned int)realsize);
s = create_kmalloc_cache(x, text, realsize, flags);
kmalloc_caches_dma[index] = s;
return s;
}
if ((flags & SLUB_DMA))
return dma_kmalloc_cache(index, flags);
#endif
return &kmalloc_caches[index];
}
Expand Down

0 comments on commit cb690df

Please sign in to comment.