Skip to contentSkip to conversation

suppress more allocation failure warnings

PATCH In review Andrew Morton 1 participant 1 message Jul 5, 2002

Subsystems (7)
Memory management VFS SCSI Scheduler +3 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 19/27 suppress more allocation failure warnings

The `page allocation failure' warning in __alloc_pages() is being a pain. But I'm persisting with it...

The patch renames PF_RADIX_TREE to PF_NOWARN, and uses it in a few places where allocations failures are known to happen. These code paths are well-tested now and suppressing the warning is OK.

 drivers/scsi/scsi.c   |    2 ++
 fs/bio.c              |   13 +++++++++----
 fs/buffer.c           |    2 ++
 include/linux/sched.h |    2 +-
 mm/page_alloc.c       |    2 +-
 mm/vmscan.c           |    2 +-
 6 files changed, 16 insertions(+), 7 deletions(-)
include/linux/sched.h renamed from include/linux/sched.h~alloc-warnings +1 -1
@@ -386,7 +386,7 @@ do { if (atomic_dec_and_test(&(tsk)->usa
 #define PF_MEMDIE	0x00001000	/* Killed for out-of-memory */
 #define PF_FREE_PAGES	0x00002000	/* per process page freeing */
 #define PF_FLUSHER	0x00004000	/* responsible for disk writeback */
-#define PF_RADIX_TREE	0x00008000	/* debug: performing radix tree alloc */
+#define PF_NOWARN	0x00008000	/* debug: don't warn if alloc fails */
 
 #define PF_FREEZE	0x00010000	/* this task should be frozen for suspend */
 #define PF_IOTHREAD	0x00020000	/* this thread is needed for doing I/O to swap */
mm/page_alloc.c renamed from mm/page_alloc.c~alloc-warnings +1 -1
@@ -399,7 +399,7 @@ rebalance:
 				return page;
 		}
 nopage:
-		if (!(current->flags & PF_RADIX_TREE)) {
+		if (!(current->flags & PF_NOWARN)) {
 			printk("%s: page allocation failure."
 				" order:%d, mode:0x%x\n",
 				current->comm, order, gfp_mask);
mm/vmscan.c renamed from mm/vmscan.c~alloc-warnings +1 -1
@@ -63,7 +63,7 @@ swap_out_add_to_swap_cache(struct page *
 	int ret;
 
 	current->flags &= ~PF_MEMALLOC;
-	current->flags |= PF_RADIX_TREE;
+	current->flags |= PF_NOWARN;
 	ClearPageUptodate(page);		/* why? */
 	ClearPageReferenced(page);		/* why? */
 	ret = add_to_swap_cache(page, entry);
fs/bio.c renamed from fs/bio.c~alloc-warnings +9 -4
@@ -135,21 +135,26 @@ inline void bio_init(struct bio *bio)
  **/
 struct bio *bio_alloc(int gfp_mask, int nr_iovecs)
 {
-	struct bio *bio = mempool_alloc(bio_pool, gfp_mask);
+	struct bio *bio;
 	struct bio_vec *bvl = NULL;
 
+	current->flags |= PF_NOWARN;
+	bio = mempool_alloc(bio_pool, gfp_mask);
 	if (unlikely(!bio))
-		return NULL;
+		goto out;
 
 	if (!nr_iovecs || (bvl = bvec_alloc(gfp_mask,nr_iovecs,&bio->bi_max))) {
 		bio_init(bio);
 		bio->bi_destructor = bio_destructor;
 		bio->bi_io_vec = bvl;
-		return bio;
+		goto out;
 	}
 
 	mempool_free(bio, bio_pool);
-	return NULL;
+	bio = NULL;
+out:
+	current->flags &= ~PF_NOWARN;
+	return bio;
 }
 
 /**
drivers/scsi/scsi.c renamed from drivers/scsi/scsi.c~alloc-warnings +2 -0
@@ -2481,7 +2481,9 @@ struct scatterlist *scsi_alloc_sgtable(S
 
 	sgp = scsi_sg_pools + SCpnt->sglist_len;
 
+	current->flags |= PF_NOWARN;
 	sgl = mempool_alloc(sgp->pool, gfp_mask);
+	current->flags &= ~PF_NOWARN;
 	if (sgl) {
 		memset(sgl, 0, sgp->size);
 		return sgl;
fs/buffer.c renamed from fs/buffer.c~alloc-warnings +2 -0
@@ -965,7 +965,9 @@ try_again:
 	head = NULL;
 	offset = PAGE_SIZE;
 	while ((offset -= size) >= 0) {
+		current->flags |= PF_NOWARN;
 		bh = alloc_buffer_head();
+		current->flags &= ~PF_NOWARN;
 		if (!bh)
 			goto no_grow;
 

-