Commit d51832f3 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] fix suppression of page allocation failure warnings

Somebody somewhere is stomping on PF_NOWARN, and page allocation
failure warnings are coming out of the wrong places.

So change the handling of current->flags to be:

int pf_flags = current->flags;

current->flags |= PF_NOWARN;
...
current->flags = pf_flags;

which is a generally more robust approach.
parent d4872de3
......@@ -2453,6 +2453,7 @@ struct scatterlist *scsi_alloc_sgtable(Scsi_Cmnd *SCpnt, int gfp_mask)
{
struct scsi_host_sg_pool *sgp;
struct scatterlist *sgl;
int pf_flags;
BUG_ON(!SCpnt->use_sg);
......@@ -2467,9 +2468,10 @@ struct scatterlist *scsi_alloc_sgtable(Scsi_Cmnd *SCpnt, int gfp_mask)
sgp = scsi_sg_pools + SCpnt->sglist_len;
pf_flags = current->flags;
current->flags |= PF_NOWARN;
sgl = mempool_alloc(sgp->pool, gfp_mask);
current->flags &= ~PF_NOWARN;
current->flags = pf_flags;
if (sgl) {
memset(sgl, 0, sgp->size);
return sgl;
......
......@@ -137,6 +137,7 @@ struct bio *bio_alloc(int gfp_mask, int nr_iovecs)
{
struct bio *bio;
struct bio_vec *bvl = NULL;
int pf_flags = current->flags;
current->flags |= PF_NOWARN;
bio = mempool_alloc(bio_pool, gfp_mask);
......@@ -153,7 +154,7 @@ struct bio *bio_alloc(int gfp_mask, int nr_iovecs)
mempool_free(bio, bio_pool);
bio = NULL;
out:
current->flags &= ~PF_NOWARN;
current->flags = pf_flags;
return bio;
}
......
......@@ -936,9 +936,11 @@ create_buffers(struct page * page, unsigned long size, int retry)
head = NULL;
offset = PAGE_SIZE;
while ((offset -= size) >= 0) {
int pf_flags = current->flags;
current->flags |= PF_NOWARN;
bh = alloc_buffer_head();
current->flags &= ~PF_NOWARN;
current->flags = pf_flags;
if (!bh)
goto no_grow;
......
......@@ -187,11 +187,12 @@ void * mempool_alloc(mempool_t *pool, int gfp_mask)
int curr_nr;
DECLARE_WAITQUEUE(wait, current);
int gfp_nowait = gfp_mask & ~(__GFP_WAIT | __GFP_IO);
int pf_flags = current->flags;
repeat_alloc:
current->flags |= PF_NOWARN;
element = pool->alloc(gfp_nowait, pool->pool_data);
current->flags &= ~PF_NOWARN;
current->flags = pf_flags;
if (likely(element != NULL))
return element;
......
......@@ -119,7 +119,7 @@ void __delete_from_swap_cache(struct page *page)
int add_to_swap(struct page * page)
{
swp_entry_t entry;
int flags;
int pf_flags;
if (!PageLocked(page))
BUG();
......@@ -142,7 +142,7 @@ int add_to_swap(struct page * page)
* just not all of them.
*/
flags = current->flags;
pf_flags = current->flags;
current->flags &= ~PF_MEMALLOC;
current->flags |= PF_NOWARN;
ClearPageUptodate(page); /* why? */
......@@ -154,20 +154,20 @@ int add_to_swap(struct page * page)
*/
switch (add_to_swap_cache(page, entry)) {
case 0: /* Success */
current->flags = flags;
current->flags = pf_flags;
SetPageUptodate(page);
set_page_dirty(page);
swap_free(entry);
return 1;
case -ENOMEM: /* radix-tree allocation */
current->flags = flags;
current->flags = pf_flags;
swap_free(entry);
return 0;
default: /* ENOENT: raced */
break;
}
/* Raced with "speculative" read_swap_cache_async */
current->flags = flags;
current->flags = pf_flags;
swap_free(entry);
}
}
......
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