aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mempool.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/mempool.c')
-rw-r--r--mm/mempool.c35
1 files changed, 14 insertions, 21 deletions
diff --git a/mm/mempool.c b/mm/mempool.c
index b014ffeaa413..c9f3d4620428 100644
--- a/mm/mempool.c
+++ b/mm/mempool.c
@@ -198,31 +198,22 @@ void * mempool_alloc(mempool_t *pool, unsigned int __nocast gfp_mask)
198 void *element; 198 void *element;
199 unsigned long flags; 199 unsigned long flags;
200 DEFINE_WAIT(wait); 200 DEFINE_WAIT(wait);
201 int gfp_nowait = gfp_mask & ~(__GFP_WAIT | __GFP_IO); 201 int gfp_temp;
202 202
203 might_sleep_if(gfp_mask & __GFP_WAIT); 203 might_sleep_if(gfp_mask & __GFP_WAIT);
204
205 gfp_mask |= __GFP_NOMEMALLOC; /* don't allocate emergency reserves */
206 gfp_mask |= __GFP_NORETRY; /* don't loop in __alloc_pages */
207 gfp_mask |= __GFP_NOWARN; /* failures are OK */
208
209 gfp_temp = gfp_mask & ~(__GFP_WAIT|__GFP_IO);
210
204repeat_alloc: 211repeat_alloc:
205 element = pool->alloc(gfp_nowait|__GFP_NOWARN, pool->pool_data); 212
213 element = pool->alloc(gfp_temp, pool->pool_data);
206 if (likely(element != NULL)) 214 if (likely(element != NULL))
207 return element; 215 return element;
208 216
209 /*
210 * If the pool is less than 50% full and we can perform effective
211 * page reclaim then try harder to allocate an element.
212 */
213 mb();
214 if ((gfp_mask & __GFP_FS) && (gfp_mask != gfp_nowait) &&
215 (pool->curr_nr <= pool->min_nr/2)) {
216 element = pool->alloc(gfp_mask, pool->pool_data);
217 if (likely(element != NULL))
218 return element;
219 }
220
221 /*
222 * Kick the VM at this point.
223 */
224 wakeup_bdflush(0);
225
226 spin_lock_irqsave(&pool->lock, flags); 217 spin_lock_irqsave(&pool->lock, flags);
227 if (likely(pool->curr_nr)) { 218 if (likely(pool->curr_nr)) {
228 element = remove_element(pool); 219 element = remove_element(pool);
@@ -235,8 +226,10 @@ repeat_alloc:
235 if (!(gfp_mask & __GFP_WAIT)) 226 if (!(gfp_mask & __GFP_WAIT))
236 return NULL; 227 return NULL;
237 228
229 /* Now start performing page reclaim */
230 gfp_temp = gfp_mask;
238 prepare_to_wait(&pool->wait, &wait, TASK_UNINTERRUPTIBLE); 231 prepare_to_wait(&pool->wait, &wait, TASK_UNINTERRUPTIBLE);
239 mb(); 232 smp_mb();
240 if (!pool->curr_nr) 233 if (!pool->curr_nr)
241 io_schedule(); 234 io_schedule();
242 finish_wait(&pool->wait, &wait); 235 finish_wait(&pool->wait, &wait);
@@ -257,7 +250,7 @@ void mempool_free(void *element, mempool_t *pool)
257{ 250{
258 unsigned long flags; 251 unsigned long flags;
259 252
260 mb(); 253 smp_mb();
261 if (pool->curr_nr < pool->min_nr) { 254 if (pool->curr_nr < pool->min_nr) {
262 spin_lock_irqsave(&pool->lock, flags); 255 spin_lock_irqsave(&pool->lock, flags);
263 if (pool->curr_nr < pool->min_nr) { 256 if (pool->curr_nr < pool->min_nr) {