From: Andrew Morton <akpm@linux-foundation.org>
To: Ming Lei <ming.lei@canonical.com>
Cc: balbi@ti.com, Linux USB Mailing List <linux-usb@vger.kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Jens Axboe <axboe@kernel.dk>
Subject: Re: Page allocation failure on v3.8-rc5
Date: Thu, 31 Jan 2013 15:43:31 -0800 [thread overview]
Message-ID: <20130131154331.09d157a3.akpm@linux-foundation.org> (raw)
In-Reply-To: <CACVXFVOATzTJq+-5M9j3G3y_WUrWKJt=naPkjkLwGDmT0H8gog@mail.gmail.com>
On Wed, 30 Jan 2013 19:53:22 +0800
Ming Lei <ming.lei@canonical.com> wrote:
> The allocation failure is caused by the big sizeof(struct parsed_partitions),
> which is 64K in my 32bit box,
Geeze.
We could fix that nicely by making parsed_partitions.parts an array of
pointers to a single `struct parsed_partition' and allocating those
on-demand.
But given the short-lived nature of this storage and the infrequency of
check_partition(), that isn't necessary.
> could you test the blow patch to see
> if it can fix the allocation failure?
(The patch is wordwrapped)
> ...
>
> @@ -106,18 +107,43 @@ static int (*check_part[])(struct parsed_partitions *) = {
> NULL
> };
>
> +struct parsed_partitions *allocate_partitions(int nr)
> +{
> + struct parsed_partitions *state;
> +
> + state = kzalloc(sizeof(struct parsed_partitions), GFP_KERNEL);
I personally prefer sizefo(*state) here. It means the reader doesn't
have to scroll back to check things.
> + if (!state)
> + return NULL;
> +
> + state->parts = vzalloc(nr * sizeof(state->parts[0]));
> + if (!state->parts) {
> + kfree(state);
> + return NULL;
> + }
It doesn't really need to be this complex - we could just vmalloc the
entire `struct parsed_partitions'. But I see that your change will
cause us to allcoate much less memory in many situations, which is
good. It should be mentioned in the changelog!
next prev parent reply other threads:[~2013-01-31 23:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20130128091039.GG6871@arwen.pp.htv.fi>
2013-01-30 11:53 ` Page allocation failure on v3.8-rc5 Ming Lei
2013-01-31 23:43 ` Andrew Morton [this message]
2013-02-01 0:33 ` Ming Lei
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=20130131154331.09d157a3.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=balbi@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-usb@vger.kernel.org \
--cc=ming.lei@canonical.com \
/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