diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-14 19:49:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-14 19:49:17 -0400 |
commit | 1dcf58d6e6e6eb7ec10e9abc56887b040205b06f (patch) | |
tree | c03e7a25ef13eea62f1547914a76e5c68f3f4c28 /mm/mempool.c | |
parent | 80dcc31fbe55932ac9204daee5f2ebc0c49b6da3 (diff) | |
parent | e4b0db72be2487bae0e3251c22f82c104f7c1cfd (diff) |
Merge branch 'akpm' (patches from Andrew)
Merge first patchbomb from Andrew Morton:
- arch/sh updates
- ocfs2 updates
- kernel/watchdog feature
- about half of mm/
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (122 commits)
Documentation: update arch list in the 'memtest' entry
Kconfig: memtest: update number of test patterns up to 17
arm: add support for memtest
arm64: add support for memtest
memtest: use phys_addr_t for physical addresses
mm: move memtest under mm
mm, hugetlb: abort __get_user_pages if current has been oom killed
mm, mempool: do not allow atomic resizing
memcg: print cgroup information when system panics due to panic_on_oom
mm: numa: remove migrate_ratelimited
mm: fold arch_randomize_brk into ARCH_HAS_ELF_RANDOMIZE
mm: split ET_DYN ASLR from mmap ASLR
s390: redefine randomize_et_dyn for ELF_ET_DYN_BASE
mm: expose arch_mmap_rnd when available
s390: standardize mmap_rnd() usage
powerpc: standardize mmap_rnd() usage
mips: extract logic for mmap_rnd()
arm64: standardize mmap_rnd() usage
x86: standardize mmap_rnd() usage
arm: factor out mmap ASLR into mmap_rnd
...
Diffstat (limited to 'mm/mempool.c')
-rw-r--r-- | mm/mempool.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/mm/mempool.c b/mm/mempool.c index e209c98c7203..949970db2874 100644 --- a/mm/mempool.c +++ b/mm/mempool.c | |||
@@ -113,23 +113,24 @@ EXPORT_SYMBOL(mempool_create_node); | |||
113 | * mempool_create(). | 113 | * mempool_create(). |
114 | * @new_min_nr: the new minimum number of elements guaranteed to be | 114 | * @new_min_nr: the new minimum number of elements guaranteed to be |
115 | * allocated for this pool. | 115 | * allocated for this pool. |
116 | * @gfp_mask: the usual allocation bitmask. | ||
117 | * | 116 | * |
118 | * This function shrinks/grows the pool. In the case of growing, | 117 | * This function shrinks/grows the pool. In the case of growing, |
119 | * it cannot be guaranteed that the pool will be grown to the new | 118 | * it cannot be guaranteed that the pool will be grown to the new |
120 | * size immediately, but new mempool_free() calls will refill it. | 119 | * size immediately, but new mempool_free() calls will refill it. |
120 | * This function may sleep. | ||
121 | * | 121 | * |
122 | * Note, the caller must guarantee that no mempool_destroy is called | 122 | * Note, the caller must guarantee that no mempool_destroy is called |
123 | * while this function is running. mempool_alloc() & mempool_free() | 123 | * while this function is running. mempool_alloc() & mempool_free() |
124 | * might be called (eg. from IRQ contexts) while this function executes. | 124 | * might be called (eg. from IRQ contexts) while this function executes. |
125 | */ | 125 | */ |
126 | int mempool_resize(mempool_t *pool, int new_min_nr, gfp_t gfp_mask) | 126 | int mempool_resize(mempool_t *pool, int new_min_nr) |
127 | { | 127 | { |
128 | void *element; | 128 | void *element; |
129 | void **new_elements; | 129 | void **new_elements; |
130 | unsigned long flags; | 130 | unsigned long flags; |
131 | 131 | ||
132 | BUG_ON(new_min_nr <= 0); | 132 | BUG_ON(new_min_nr <= 0); |
133 | might_sleep(); | ||
133 | 134 | ||
134 | spin_lock_irqsave(&pool->lock, flags); | 135 | spin_lock_irqsave(&pool->lock, flags); |
135 | if (new_min_nr <= pool->min_nr) { | 136 | if (new_min_nr <= pool->min_nr) { |
@@ -145,7 +146,8 @@ int mempool_resize(mempool_t *pool, int new_min_nr, gfp_t gfp_mask) | |||
145 | spin_unlock_irqrestore(&pool->lock, flags); | 146 | spin_unlock_irqrestore(&pool->lock, flags); |
146 | 147 | ||
147 | /* Grow the pool */ | 148 | /* Grow the pool */ |
148 | new_elements = kmalloc(new_min_nr * sizeof(*new_elements), gfp_mask); | 149 | new_elements = kmalloc_array(new_min_nr, sizeof(*new_elements), |
150 | GFP_KERNEL); | ||
149 | if (!new_elements) | 151 | if (!new_elements) |
150 | return -ENOMEM; | 152 | return -ENOMEM; |
151 | 153 | ||
@@ -164,7 +166,7 @@ int mempool_resize(mempool_t *pool, int new_min_nr, gfp_t gfp_mask) | |||
164 | 166 | ||
165 | while (pool->curr_nr < pool->min_nr) { | 167 | while (pool->curr_nr < pool->min_nr) { |
166 | spin_unlock_irqrestore(&pool->lock, flags); | 168 | spin_unlock_irqrestore(&pool->lock, flags); |
167 | element = pool->alloc(gfp_mask, pool->pool_data); | 169 | element = pool->alloc(GFP_KERNEL, pool->pool_data); |
168 | if (!element) | 170 | if (!element) |
169 | goto out; | 171 | goto out; |
170 | spin_lock_irqsave(&pool->lock, flags); | 172 | spin_lock_irqsave(&pool->lock, flags); |