From: Catalin Marinas <catalin.marinas@arm.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
NeilBrown <neilb@suse.de>,
"linux-raid@vger.kernel.org" <linux-raid@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
David Rientjes <rientjes@google.com>,
Maxime Bizon <mbizon@freebox.fr>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: Recent 3.x kernels: Memory leak causing OOMs
Date: Tue, 1 Apr 2014 16:58:17 +0100 [thread overview]
Message-ID: <20140401155815.GF20061@arm.com> (raw)
In-Reply-To: <20140401113851.GA15317@n2100.arm.linux.org.uk>
On Tue, Apr 01, 2014 at 12:38:51PM +0100, Russell King - ARM Linux wrote:
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index aacf6bf352d8..604bad2fa442 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -123,8 +123,14 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
> bio = r1_bio->bios[j];
> bio->bi_vcnt = RESYNC_PAGES;
>
> - if (bio_alloc_pages(bio, gfp_flags))
> - goto out_free_bio;
> + if (bio_alloc_pages(bio, gfp_flags)) {
> + /*
> + * Mark this as having no pages - bio_alloc_pages
> + * removes any it allocated.
> + */
> + bio->bi_vcnt = 0;
> + goto out_free_all_bios;
> + }
> }
> /* If not user-requests, copy the page pointers to all bios */
> if (!test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery)) {
> @@ -138,9 +144,25 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
>
> return r1_bio;
>
> +out_free_all_bios:
> + j = -1;
> out_free_bio:
> - while (++j < pi->raid_disks)
> - bio_put(r1_bio->bios[j]);
> + while (++j < pi->raid_disks) {
> + bio = r1_bio->bios[j];
> + if (bio->bi_vcnt) {
> + struct bio_vec *bv;
> + int i;
> + /*
> + * Annoyingly, BIO has no way to do this, so we have
> + * to do it manually. Given the trouble here, and
> + * the lack of BIO support for cleaning up, I don't
> + * care about linux/bio.h's comment about this helper.
> + */
> + bio_for_each_segment_all(bv, bio, i)
> + __free_page(bv->bv_page);
> + }
Do you still need the 'if' block here? bio_for_each_segment_all() checks
for bio->bi_vcnt which was set to 0 above.
--
Catalin
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2014-04-01 15:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-16 20:05 Recent 3.x kernels: Memory leak causing OOMs Russell King - ARM Linux
2014-02-16 21:43 ` Theodore Ts'o
2014-02-17 18:34 ` Catalin Marinas
2014-02-16 22:17 ` David Rientjes
2014-02-16 22:50 ` Russell King - ARM Linux
2014-02-16 23:42 ` David Rientjes
2014-02-17 21:02 ` Maxime Bizon
2014-02-17 21:09 ` Russell King - ARM Linux
2014-03-15 10:19 ` Russell King - ARM Linux
2014-03-17 7:07 ` NeilBrown
2014-03-17 8:51 ` Russell King - ARM Linux
2014-03-17 18:18 ` Catalin Marinas
2014-03-17 19:33 ` Russell King - ARM Linux
2014-04-01 9:19 ` Russell King - ARM Linux
2014-04-01 11:38 ` Russell King - ARM Linux
2014-04-01 14:04 ` Russell King - ARM Linux
2014-04-02 23:28 ` NeilBrown
2014-04-01 15:58 ` Catalin Marinas [this message]
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=20140401155815.GF20061@arm.com \
--to=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=linux-raid@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=mbizon@freebox.fr \
--cc=neilb@suse.de \
--cc=rientjes@google.com \
--cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).