From: Richard Purdie <rpurdie@openedhand.com>
To: Satyam Sharma <satyam.sharma@gmail.com>
Cc: linux-crypto@vger.kernel.org,
linux-mtd <linux-mtd@lists.infradead.org>,
David Woodhouse <dwmw2@infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
herbert@gondor.apana.org.au
Subject: Re: [PATCH 2/5] jffs2: Add LZO compression support to jffs2
Date: Fri, 04 May 2007 11:52:17 +0100 [thread overview]
Message-ID: <1178275937.5839.25.camel@localhost.localdomain> (raw)
In-Reply-To: <a781481a0705040206jee1c4a7s9822960a7a18d56f@mail.gmail.com>
On Fri, 2007-05-04 at 14:36 +0530, Satyam Sharma wrote:
> On 5/1/07, Richard Purdie <rpurdie@openedhand.com> wrote:
> > +++ b/fs/jffs2/compr_lzo.c
> > [...]
> > +static void *lzo_mem;
> > +static void *lzo_compress_buf;
> > +static DEFINE_MUTEX(deflate_mutex);
> > +
> > +static void free_workspace(void)
> > +{
> > + vfree(lzo_mem);
> > + vfree(lzo_compress_buf);
> > +}
> > +
> > +static int __init alloc_workspace(void)
> > +{
> > + lzo_mem = vmalloc(LZO1X_MEM_COMPRESS);
> > + lzo_compress_buf = vmalloc(lzo1x_worst_compress(PAGE_SIZE));
> > +
> > + if (!lzo_mem || !lzo_compress_buf) {
> > + printk(KERN_WARNING "Failed to allocate lzo deflate workspace\n");
> > + free_workspace();
> > + return -ENOMEM;
> > + }
> > +
> > + return 0;
> > +}
> > +
> > +static int jffs2_lzo_compress(unsigned char *data_in, unsigned char *cpage_out,
> > + uint32_t *sourcelen, uint32_t *dstlen, void *model)
> > +{
> > + unsigned long compress_size;
> > + int ret;
> > +
> > + mutex_lock(&deflate_mutex);
> > + ret = lzo1x_1_compress(data_in, *sourcelen, lzo_compress_buf, &compress_size, lzo_mem);
> > + mutex_unlock(&deflate_mutex);
>
> Considering we do have to memcpy() the entire compressed result to the
> destination output buffer later anyway (note that
> fs/jffs2/compr_zlib.c doesn't need to do that), do we really gain much
> by avoiding vmalloc() and vfree() in jffs2_lzo_compress() itself and
> keeping the workspace buffers pre-allocated? I ask because I always
> found these global static workspace buffers ugly, and all the
> associated code + mutex could go away if we make them local to
> jffs2_lzo_compress() -- as long as it doesn't hurt performance
> terribly, of course.
memcpy is relatively fast and I'd expect continually allocing and
freeing buffers to have a significant overhead compared with that and
impact performance. The current approach means you don't get ENOMEM
errors in the uncompress/compress paths either.
Regards,
Richard
next prev parent reply other threads:[~2007-05-04 10:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-01 14:47 [PATCH 2/5] jffs2: Add LZO compression support to jffs2 Richard Purdie
2007-05-01 20:00 ` Randy Dunlap
2007-05-04 9:06 ` Satyam Sharma
2007-05-04 10:52 ` Richard Purdie [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-05-04 11:45 Richard Purdie
2007-05-04 11:30 Richard Purdie
2007-05-04 11:35 ` David Woodhouse
2007-05-04 12:41 ` Haavard Skinnemoen
2007-05-04 12:47 ` David Woodhouse
2007-02-28 19:13 Richard Purdie
2007-04-25 12:35 ` David Woodhouse
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=1178275937.5839.25.camel@localhost.localdomain \
--to=rpurdie@openedhand.com \
--cc=dwmw2@infradead.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=satyam.sharma@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