diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-01-08 10:09:31 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-01-09 01:32:05 -0500 |
commit | d7b135410e1b2f5ad64e56df09d133a23aa9fbcb (patch) | |
tree | f971bb79bb83945c0cfeed8e1ec8aa526b07e0ed /sound/core/memalloc.c | |
parent | 75dcbe4dc251ebc28cdf0797b85774cdf53a4d29 (diff) |
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: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/memalloc.c')
-rw-r--r-- | sound/core/memalloc.c | 31 |
1 files changed, 2 insertions, 29 deletions
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index 5e1c7bc73b29..bfaf4f04d91d 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c | |||
@@ -63,18 +63,6 @@ struct snd_mem_list { | |||
63 | * | 63 | * |
64 | */ | 64 | */ |
65 | 65 | ||
66 | static long snd_allocated_pages; /* holding the number of allocated pages */ | ||
67 | |||
68 | static inline void inc_snd_pages(int order) | ||
69 | { | ||
70 | snd_allocated_pages += 1 << order; | ||
71 | } | ||
72 | |||
73 | static inline void dec_snd_pages(int order) | ||
74 | { | ||
75 | snd_allocated_pages -= 1 << order; | ||
76 | } | ||
77 | |||
78 | /** | 66 | /** |
79 | * snd_malloc_pages - allocate pages with the given size | 67 | * snd_malloc_pages - allocate pages with the given size |
80 | * @size: the size to allocate in bytes | 68 | * @size: the size to allocate in bytes |
@@ -87,7 +75,6 @@ static inline void dec_snd_pages(int order) | |||
87 | void *snd_malloc_pages(size_t size, gfp_t gfp_flags) | 75 | void *snd_malloc_pages(size_t size, gfp_t gfp_flags) |
88 | { | 76 | { |
89 | int pg; | 77 | int pg; |
90 | void *res; | ||
91 | 78 | ||
92 | if (WARN_ON(!size)) | 79 | if (WARN_ON(!size)) |
93 | return NULL; | 80 | return NULL; |
@@ -95,9 +82,7 @@ void *snd_malloc_pages(size_t size, gfp_t gfp_flags) | |||
95 | return NULL; | 82 | return NULL; |
96 | gfp_flags |= __GFP_COMP; /* compound page lets parts be mapped */ | 83 | gfp_flags |= __GFP_COMP; /* compound page lets parts be mapped */ |
97 | pg = get_order(size); | 84 | pg = get_order(size); |
98 | if ((res = (void *) __get_free_pages(gfp_flags, pg)) != NULL) | 85 | return (void *) __get_free_pages(gfp_flags, pg); |
99 | inc_snd_pages(pg); | ||
100 | return res; | ||
101 | } | 86 | } |
102 | 87 | ||
103 | /** | 88 | /** |
@@ -114,7 +99,6 @@ void snd_free_pages(void *ptr, size_t size) | |||
114 | if (ptr == NULL) | 99 | if (ptr == NULL) |
115 | return; | 100 | return; |
116 | pg = get_order(size); | 101 | pg = get_order(size); |
117 | dec_snd_pages(pg); | ||
118 | free_pages((unsigned long) ptr, pg); | 102 | free_pages((unsigned long) ptr, pg); |
119 | } | 103 | } |
120 | 104 | ||
@@ -129,7 +113,6 @@ void snd_free_pages(void *ptr, size_t size) | |||
129 | static void *snd_malloc_dev_pages(struct device *dev, size_t size, dma_addr_t *dma) | 113 | static void *snd_malloc_dev_pages(struct device *dev, size_t size, dma_addr_t *dma) |
130 | { | 114 | { |
131 | int pg; | 115 | int pg; |
132 | void *res; | ||
133 | gfp_t gfp_flags; | 116 | gfp_t gfp_flags; |
134 | 117 | ||
135 | if (WARN_ON(!dma)) | 118 | 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 | | __GFP_COMP /* compound page lets parts be mapped */ | 122 | | __GFP_COMP /* compound page lets parts be mapped */ |
140 | | __GFP_NORETRY /* don't trigger OOM-killer */ | 123 | | __GFP_NORETRY /* don't trigger OOM-killer */ |
141 | | __GFP_NOWARN; /* no stack trace print - this call is non-critical */ | 124 | | __GFP_NOWARN; /* no stack trace print - this call is non-critical */ |
142 | res = dma_alloc_coherent(dev, PAGE_SIZE << pg, dma, gfp_flags); | 125 | return dma_alloc_coherent(dev, PAGE_SIZE << pg, dma, gfp_flags); |
143 | if (res != NULL) | ||
144 | inc_snd_pages(pg); | ||
145 | |||
146 | return res; | ||
147 | } | 126 | } |
148 | 127 | ||
149 | /* free the coherent DMA pages */ | 128 | /* free the coherent DMA pages */ |
@@ -155,7 +134,6 @@ static void snd_free_dev_pages(struct device *dev, size_t size, void *ptr, | |||
155 | if (ptr == NULL) | 134 | if (ptr == NULL) |
156 | return; | 135 | return; |
157 | pg = get_order(size); | 136 | pg = get_order(size); |
158 | dec_snd_pages(pg); | ||
159 | dma_free_coherent(dev, PAGE_SIZE << pg, ptr, dma); | 137 | dma_free_coherent(dev, PAGE_SIZE << pg, ptr, dma); |
160 | } | 138 | } |
161 | 139 | ||
@@ -432,14 +410,11 @@ static struct proc_dir_entry *snd_mem_proc; | |||
432 | 410 | ||
433 | static int snd_mem_proc_read(struct seq_file *seq, void *offset) | 411 | static int snd_mem_proc_read(struct seq_file *seq, void *offset) |
434 | { | 412 | { |
435 | long pages = snd_allocated_pages >> (PAGE_SHIFT-12); | ||
436 | struct snd_mem_list *mem; | 413 | struct snd_mem_list *mem; |
437 | int devno; | 414 | int devno; |
438 | static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG" }; | 415 | static char *types[] = { "UNKNOWN", "CONT", "DEV", "DEV-SG" }; |
439 | 416 | ||
440 | mutex_lock(&list_mutex); | 417 | mutex_lock(&list_mutex); |
441 | seq_printf(seq, "pages : %li bytes (%li pages per %likB)\n", | ||
442 | pages * PAGE_SIZE, pages, PAGE_SIZE / 1024); | ||
443 | devno = 0; | 418 | devno = 0; |
444 | list_for_each_entry(mem, &mem_list_head, list) { | 419 | list_for_each_entry(mem, &mem_list_head, list) { |
445 | devno++; | 420 | devno++; |
@@ -581,8 +556,6 @@ static void __exit snd_mem_exit(void) | |||
581 | { | 556 | { |
582 | remove_proc_entry(SND_MEM_PROC_FILE, NULL); | 557 | remove_proc_entry(SND_MEM_PROC_FILE, NULL); |
583 | free_all_reserved_pages(); | 558 | free_all_reserved_pages(); |
584 | if (snd_allocated_pages > 0) | ||
585 | printk(KERN_ERR "snd-malloc: Memory leak? pages not freed = %li\n", snd_allocated_pages); | ||
586 | } | 559 | } |
587 | 560 | ||
588 | 561 | ||