Commit d7b13541 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: Remove memory accounting in memalloc helper

It's almost superfluous, and doesn't help much for real uses.
Let's reduce the layer size.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 75dcbe4d
...@@ -63,18 +63,6 @@ struct snd_mem_list { ...@@ -63,18 +63,6 @@ struct snd_mem_list {
* *
*/ */
static long snd_allocated_pages; /* holding the number of allocated pages */
static inline void inc_snd_pages(int order)
{
snd_allocated_pages += 1 << order;
}
static inline void dec_snd_pages(int order)
{
snd_allocated_pages -= 1 << order;
}
/** /**
* snd_malloc_pages - allocate pages with the given size * snd_malloc_pages - allocate pages with the given size
* @size: the size to allocate in bytes * @size: the size to allocate in bytes
...@@ -87,7 +75,6 @@ static inline void dec_snd_pages(int order) ...@@ -87,7 +75,6 @@ static inline void dec_snd_pages(int order)
void *snd_malloc_pages(size_t size, gfp_t gfp_flags) void *snd_malloc_pages(size_t size, gfp_t gfp_flags)
{ {
int pg; int pg;
void *res;
if (WARN_ON(!size)) if (WARN_ON(!size))
return NULL; return NULL;
...@@ -95,9 +82,7 @@ void *snd_malloc_pages(size_t size, gfp_t gfp_flags) ...@@ -95,9 +82,7 @@ void *snd_malloc_pages(size_t size, gfp_t gfp_flags)
return NULL; return NULL;
gfp_flags |= __GFP_COMP; /* compound page lets parts be mapped */ gfp_flags |= __GFP_COMP; /* compound page lets parts be mapped */
pg = get_order(size); pg = get_order(size);
if ((res = (void *) __get_free_pages(gfp_flags, pg)) != NULL) return (void *) __get_free_pages(gfp_flags, pg);
inc_snd_pages(pg);
return res;
} }
/** /**
...@@ -114,7 +99,6 @@ void snd_free_pages(void *ptr, size_t size) ...@@ -114,7 +99,6 @@ void snd_free_pages(void *ptr, size_t size)
if (ptr == NULL) if (ptr == NULL)
return; return;
pg = get_order(size); pg = get_order(size);
dec_snd_pages(pg);
free_pages((unsigned long) ptr, pg); free_pages((unsigned long) ptr, pg);
} }
...@@ -129,7 +113,6 @@ void snd_free_pages(void *ptr, size_t size) ...@@ -129,7 +113,6 @@ void snd_free_pages(void *ptr, size_t size)
static void *snd_malloc_dev_pages(struct device *dev, size_t size, dma_addr_t *dma) static void *snd_malloc_dev_pages(struct device *dev, size_t size, dma_addr_t *dma)
{ {
int pg; int pg;
void *res;
gfp_t gfp_flags; gfp_t gfp_flags;
if (WARN_ON(!dma)) if (WARN_ON(!dma))
...@@ -139,11 +122,7 @@ static void *snd_malloc_dev_pages(struct device *dev, size_t size, dma_addr_t *d ...@@ -139,11 +122,7 @@ static void *snd_malloc_dev_pages(struct device *dev, size_t size, dma_addr_t *d
| __GFP_COMP /* compound page lets parts be mapped */ | __GFP_COMP /* compound page lets parts be mapped */
| __GFP_NORETRY /* don't trigger OOM-killer */ | __GFP_NORETRY /* don't trigger OOM-killer */
| __GFP_NOWARN; /* no stack trace print - this call is non-critical */ | __GFP_NOWARN; /* no stack trace print - this call is non-critical */
res = dma_alloc_coherent(dev, PAGE_SIZE << pg, dma, gfp_flags); return dma_alloc_coherent(dev, PAGE_SIZE << pg, dma, gfp_flags);
if (res != NULL)
inc_snd_pages(pg);
return res;
} }
/* free the coherent DMA pages */ /* free the coherent DMA pages */
...@@ -155,7 +134,6 @@ static void snd_free_dev_pages(struct device *dev, size_t size, void *ptr, ...@@ -155,7 +134,6 @@ static void snd_free_dev_pages(struct device *dev, size_t size, void *ptr,
if (ptr == NULL) if (ptr == NULL)
return; return;
pg = get_order(size); pg = get_order(size);
dec_snd_pages(pg);
dma_free_coherent(dev, PAGE_SIZE << pg, ptr, dma); dma_free_coherent(dev, PAGE_SIZE << pg, ptr, dma);
} }
...@@ -432,14 +410,11 @@ static struct proc_dir_entry *snd_mem_proc; ...@@ -432,14 +410,11 @@ static struct proc_dir_entry *snd_mem_proc;
static int snd_mem_proc_read(struct seq_file *seq, void *offset) static int snd_mem_proc_read(struct seq_file *seq, void *offset)
{ {
long pages = snd_allocated_pages >> (PAGE_SHIFT-12);
struct snd_mem_list *mem; struct snd_mem_list *mem;
int devno; int devno;
static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG" }; static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG" };
mutex_lock(&list_mutex); mutex_lock(&list_mutex);
seq_printf(seq, "pages : %li bytes (%li pages per %likB)\n",
pages * PAGE_SIZE, pages, PAGE_SIZE / 1024);
devno = 0; devno = 0;
list_for_each_entry(mem, &mem_list_head, list) { list_for_each_entry(mem, &mem_list_head, list) {
devno++; devno++;
...@@ -581,8 +556,6 @@ static void __exit snd_mem_exit(void) ...@@ -581,8 +556,6 @@ static void __exit snd_mem_exit(void)
{ {
remove_proc_entry(SND_MEM_PROC_FILE, NULL); remove_proc_entry(SND_MEM_PROC_FILE, NULL);
free_all_reserved_pages(); free_all_reserved_pages();
if (snd_allocated_pages > 0)
printk(KERN_ERR "snd-malloc: Memory leak? pages not freed = %li\n", snd_allocated_pages);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment