public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind1@gmail.com>
To: josselin.costanzi@mobile-devices.fr
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH] UBI: allocate verification buffer on demand
Date: Thu, 08 Mar 2012 15:50:29 +0200	[thread overview]
Message-ID: <1331214629.7257.58.camel@sauron.fi.intel.com> (raw)
In-Reply-To: <4f450bbc.334cb40a.7321.64ad@mx.google.com>

On Wed, 2012-02-22 at 16:37 +0100, josselin.costanzi@mobile-devices.fr
wrote:
> From: Josselin Costanzi <josselin.costanzi@mobile-devices.fr>
> 
> Instead of using pre-allocated 'ubi->peb_buf2' buffer in
> 'ubi_eba_copy_leb()', dynamically allocate it when needed. The intent is
> to get rid of the pre-allocated 'ubi->peb_buf2' buffer and save up to
> 2MiB of RAM per attached device (or more if PEB size is larger). If the
> allocation fails, we fallback to a degraded mode where data integrity is
> still ensured, at the cost of higher CPU usage.

Hi, thanks for the patch! We actually do not need peb_buf2 at all, we
can just always use CRC for checking. So I have modified your patch a
bit. I'll send them shortly. Also, you did not add Signed-off-by - I did
it for you, but I am not supposed to do this :-) I also added another
patch which renames peb_buf1 to peb_buf. I'll send them out shortly -
please - review and test. Once you report that they work, I'll push them
to my tree. Thanks!

And yeah, as you already suggested, you do not have to allocate so much
memory for peb_buf as well. 2-4 NAND pages is good enough. You can
optimize RAM usage further then. And I think that CRC caclulation for
partial buffers can be done easily - you just use UBI_CRC32_INIT seed
for the first chunk, then you pass the previous CRC as the seed for the
next chunk and so on. The result should be the same as calculating CRC
for the whole buffer at once.

Also, peb_buf1 does not have to be pre-allocated. You can allocate it
when you actually need it, and then free it. Use
'mtd_kmalloc_up_to(ubi->mtd, 512)' for example.

If the system does not have memory at all, then it is in big trouble
anyway.

-- 
Best Regards,
Artem Bityutskiy

      reply	other threads:[~2012-03-08 13:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1329925025-4980-1-git-send-email-y>
2012-02-22 15:37 ` [PATCH] UBI: allocate verification buffer on demand josselin.costanzi
2012-03-08 13:50   ` Artem Bityutskiy [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=1331214629.7257.58.camel@sauron.fi.intel.com \
    --to=dedekind1@gmail.com \
    --cc=josselin.costanzi@mobile-devices.fr \
    --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