From: Artem Bityutskiy <dedekind1@gmail.com>
To: Grant Erickson <marathon96@gmail.com>
Cc: Jarkko Lavinen <jarkko.lavinen@nokia.com>, linux-mtd@lists.infradead.org
Subject: Re: [PATCH] Retry Large Buffer Allocations
Date: Tue, 05 Apr 2011 22:31:22 +0300 [thread overview]
Message-ID: <1302031882.2608.48.camel@koala> (raw)
In-Reply-To: <1302028464-9519-1-git-send-email-marathon96@gmail.com>
Just partial review before I go to bed, to keep you busy :-)))
On Tue, 2011-04-05 at 11:34 -0700, Grant Erickson wrote:
> kfree(kbuf);
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index da69bc8..d102b96 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -638,6 +638,36 @@ int default_mtd_writev(struct mtd_info *mtd, const struct kvec *vecs,
> return ret;
> }
>
> +/* mtd_alloc_up_to - called, for example by mtd_{read,write} and
> + * jffs2_scan_medium, to handle smaller (i.e. degraded) buffer
> + * allocations under low- or fragmented-memory situations where
> + * such reduced allocations, from a requested ideal, are allowed.
> + */
Please, make the comment to be of proper style. See the CodingStyle
file. Or even better - make it proper kerneldoc comment, if you can. I'm
sure you'll find the rules in the "Documentation" directory, but this is
optional. Also, please, put the comment just above the function.
> +#define MAX_KMALLOC_SIZE 0x20000
> +
> +void *mtd_alloc_up_to(size_t *size)
> +{
> + gfp_t flags;
> + size_t try;
> + void *kbuf;
> +
> + try = min_t(size_t, *size, MAX_KMALLOC_SIZE);
> +
> + do {
> + flags = ((size == PAGE_SIZE) ?
s/size/try/
> + GFP_KERNEL :
> + (__GFP_NOWARN | __GFP_WAIT |
> + __GFP_NORETRY | __GFP_NO_KSWAPD));
Sorry, but this construct is not beautiful and difficult to read. I'd
call it abuse of ?: operators :-) I think it is much more readable to
simply:
1. initialize gfp_t flags to (__GFP_NOWARN .... ) when you initialize it
or just before the loop.
2. Do
if (try == PAGE_SIZE)
flags = GFP_KERNEL;
Simple and readable.
And do not forget to check the code with checkpatch.pl before sending
out :-)
Good night!
--
Best Regards,
Artem Bityutskiy (Битюцкий Артём)
next prev parent reply other threads:[~2011-04-05 19:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-05 18:34 [PATCH] Retry Large Buffer Allocations Grant Erickson
2011-04-05 19:31 ` Artem Bityutskiy [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-04-05 20:05 Grant Erickson
2011-04-06 8:47 ` Artem Bityutskiy
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=1302031882.2608.48.camel@koala \
--to=dedekind1@gmail.com \
--cc=jarkko.lavinen@nokia.com \
--cc=linux-mtd@lists.infradead.org \
--cc=marathon96@gmail.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