From: Artem Bityutskiy <dedekind1@gmail.com>
To: Adrian Hunter <adrian.hunter@nokia.com>
Cc: MTD list <linux-mtd@lists.infradead.org>
Subject: [PATCH 1/6] UBIFS: allocate dump buffer on demand
Date: Mon, 14 Mar 2011 16:46:07 +0200 [thread overview]
Message-ID: <1300113972-4507-2-git-send-email-dedekind1@gmail.com> (raw)
In-Reply-To: <1300113972-4507-1-git-send-email-dedekind1@gmail.com>
From: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Instead of using pre-allocated 'c->dbg->buf' buffer in
'dbg_dump_leb()', dynamically allocate it when needed. The intend
is to get rid of the pre-allocated 'c->dbg->buf' buffer and save
128KiB of RAM (or more if PEB size is larger). Indeed, currently we
allocate this memory even if the user never enables any self-check,
which is wasteful.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
---
fs/ubifs/debug.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 02c10dc..c2e5c08 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -810,16 +810,24 @@ void dbg_dump_leb(const struct ubifs_info *c, int lnum)
{
struct ubifs_scan_leb *sleb;
struct ubifs_scan_node *snod;
+ void *buf;
if (dbg_failure_mode)
return;
printk(KERN_DEBUG "(pid %d) start dumping LEB %d\n",
current->pid, lnum);
- sleb = ubifs_scan(c, lnum, 0, c->dbg->buf, 0);
+
+ buf = __vmalloc(c->leb_size, GFP_KERNEL | GFP_NOFS, PAGE_KERNEL);
+ if (!buf) {
+ ubifs_err("cannot allocate memory for dumping LEB %d", lnum);
+ return;
+ }
+
+ sleb = ubifs_scan(c, lnum, 0, buf, 0);
if (IS_ERR(sleb)) {
ubifs_err("scan error %d", (int)PTR_ERR(sleb));
- return;
+ goto out;
}
printk(KERN_DEBUG "LEB %d has %d nodes ending at %d\n", lnum,
@@ -835,6 +843,9 @@ void dbg_dump_leb(const struct ubifs_info *c, int lnum)
printk(KERN_DEBUG "(pid %d) finish dumping LEB %d\n",
current->pid, lnum);
ubifs_scan_destroy(sleb);
+
+out:
+ vfree(buf);
return;
}
--
1.7.2.3
next prev parent reply other threads:[~2011-03-14 14:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-14 14:46 [PATCH 0/6] UBIFS: save a bit of RAM Artem Bityutskiy
2011-03-14 14:46 ` Artem Bityutskiy [this message]
2011-03-14 14:46 ` [PATCH 2/6] UBIFS: allocate scanning buffer on demand Artem Bityutskiy
2011-03-14 14:46 ` [PATCH 3/6] UBIFS: allocate ltab checking " Artem Bityutskiy
2011-03-14 14:46 ` [PATCH 4/6] UBIFS: allocate lpt dump " Artem Bityutskiy
2011-03-14 14:46 ` [PATCH 5/6] UBIFS: allocate orphans scan " Artem Bityutskiy
2011-03-14 14:46 ` [PATCH 6/6] UBIFS: save 128KiB or more RAM 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=1300113972-4507-2-git-send-email-dedekind1@gmail.com \
--to=dedekind1@gmail.com \
--cc=adrian.hunter@nokia.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