mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@digeo.com>
To: Jonah Sherman <jsherman@stuy.edu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [OOPS] 2.5.63 - NULL pointer dereference in loop device
Date: Mon, 24 Feb 2003 21:45:43 -0800	[thread overview]
Message-ID: <20030224214543.0e9e2de7.akpm@digeo.com> (raw)
In-Reply-To: <20030224212530.GA631@j0nah.ath.cx>

Jonah Sherman <jsherman@stuy.edu> wrote:
>
> I have come across a bug in the loop driver.

So you have.  See, the `dd' fills the machine up with dirty memory and the
loop driver wants to take a copy of all that memory to write it out.  It takes
this copy inside page reclaim, where we are allowed to use *all* memory.

So obviously, as there is so much memory to be written, we just run out of
the stuff.

The loop driver has a tendency to do this sort of thing.  Whenever it does,
we slap another bandaid on it.  


diff -puN drivers/block/loop.c~loop-hack drivers/block/loop.c
--- 25/drivers/block/loop.c~loop-hack	2003-02-24 21:21:11.000000000 -0800
+++ 25-akpm/drivers/block/loop.c	2003-02-24 21:45:13.000000000 -0800
@@ -447,7 +447,22 @@ static struct bio *loop_get_buffer(struc
 		goto out_bh;
 	}
 
-	bio = bio_copy(rbh, GFP_NOIO, rbh->bi_rw & WRITE);
+	/*
+	 * When called on the page reclaim -> writepage path, this code can
+	 * trivially consume all memory.  So we drop PF_MEMALLOC to avoid
+	 * stealing all the page reserves and throttle to the writeout rate.
+	 * pdflush will have been woken by page reclaim.  Let it do its work.
+	 */
+	do {
+		int flags = current->flags;
+
+		current->flags &= ~PF_MEMALLOC;
+		bio = bio_copy(rbh, (GFP_ATOMIC & ~__GFP_HIGH) | __GFP_NOWARN,
+					rbh->bi_rw & WRITE);
+		current->flags = flags;
+		if (bio == NULL)
+			blk_congestion_wait(WRITE, HZ/10);
+	} while (bio == NULL);
 
 	bio->bi_end_io = loop_end_io_transfer;
 	bio->bi_private = rbh;

_


  reply	other threads:[~2003-02-25  5:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-24 21:25 Jonah Sherman
2003-02-25  5:45 ` Andrew Morton [this message]
2003-02-25 21:15 ` Hugh Dickins
2003-02-25 19:38   ` Jonah Sherman
2003-02-26 13:32     ` Hugh Dickins
2003-02-26 10:52   ` Andrew Morton
2003-02-26 13:55     ` Hugh Dickins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030224214543.0e9e2de7.akpm@digeo.com \
    --to=akpm@digeo.com \
    --cc=jsherman@stuy.edu \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®