From: Artem Bityutskiy <dedekind1@gmail.com>
To: Nicholas <ciliwung36@gmail.com>
Cc: linux-mtd@lists.infradead.org
Subject: Re: UBI memory usage on large page nand
Date: Fri, 15 Apr 2011 16:13:46 +0300 [thread overview]
Message-ID: <1302873226.3220.43.camel@localhost> (raw)
In-Reply-To: <BANLkTi=pZqEwWYy=7mYQ_p73cHQ4rA6Rbg@mail.gmail.com>
On Fri, 2011-04-15 at 17:23 +0800, Nicholas wrote:
> Dear Artem,
>
> Thanks for the information. Indeed it has flexibility to be freed or consumed.
> Due to my case, i need to use maximum memory space while in the
> meantime i also need to write files into nand via ubi.
> 8KB page of nand flash will consume 16MB for a single volume on a
> single UBI MTD.
>
> 1. Is there any idea to reduce the memory consumption ?
Yes. The main idea is as I described: both UBI and UBIFS have several
multiple PEB-size buffers at attach/mount time. I did not count them,
but I think there may be about 6 of them. All these buffers are
allocated using vmalloc(), so you can easily fine all of them, because
'vmalloc()' is used only for those buffers.
And the basic idea is to not pre-allocate them, but allocate only when
they are needed. This is the first step you can try to do to see how
much you can gain.
E.g., in ubi.h I see the following buffers to optimize:
* @peb_buf1: a buffer of PEB size used for different purposes
* @peb_buf2: another buffer of PEB size used for different purposes
In UBIFS
* @ileb_buf: buffer for commit in-the-gaps method
* @orph_buf: buffer for orphan nodes
* @sbuf: a buffer of LEB size used by GC and replay for scanning
* @lpt_buf: buffer of LEB size used by LPT
May be there are other buffers. I'm sure these all buffers are not
needed simultaneously, may be max. 2-3 of them may be needed
simultaneously sometimes.
And there are many smaller buffers which are pre-allocated with
kmalloc() - you can also try to allocate them on the need only.
But if the allocation fails - you are screwed :-) But this can be
mitigated - there are several ways.
> 2. For smaller buffer allocation, can it be made for several attempts
> of read / write ?
Yes, I believe in many places this is possible. But this is a bit more
difficult to do.
We have another problem - some drivers do not like vmalloc()'ed buffers
because many arm platforms cannot do dma if the buffer was vmalloc()'ed.
So the idea is to switch from vmalloc(PEB_size) to kamalloc() an array
of pages and to vectored I/O (iovec). And in many places you do not
really need RAM for whole PEB, you man allocate smaller buffer and then
iterate and do one small piece of job at the time.
Anyway, you can certainly imporve UBI/UBIFS. It'd be interesting to help
you, but I have no time, and my priority is to solve the unstable bits
problem now. But I can help you by advising and reviewing your work if
you are serious about this.
So, again, if you are serious, start with UBI because it is simpler and
try to see where you can save RAM. Make some patches and send.
Thanks!
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
next prev parent reply other threads:[~2011-04-15 13:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <AANLkTi=GsmJOjurETG930t-TW7uXLR1M6yKXWBSk7ebV@mail.gmail.com>
2011-03-31 3:07 ` UBI memory usage on large page nand Nicholas
2011-04-01 15:31 ` Artem Bityutskiy
2011-04-15 9:23 ` Nicholas
2011-04-15 13:13 ` Artem Bityutskiy [this message]
2011-04-15 13:17 ` Artem Bityutskiy
2011-04-15 13:24 ` Artem Bityutskiy
2011-04-17 9:03 ` Nicholas
2011-04-17 9:16 ` Artem Bityutskiy
2011-04-18 8:29 ` Nicholas
2011-04-18 8:39 ` Artem Bityutskiy
2011-04-20 3:19 ` Nicholas
2011-04-20 7:30 ` Artem Bityutskiy
2011-08-17 6:35 ` Nicholas
2011-08-20 5:17 ` 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=1302873226.3220.43.camel@localhost \
--to=dedekind1@gmail.com \
--cc=ciliwung36@gmail.com \
--cc=linux-mtd@lists.infradead.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).