From: Andreas Robinson <andr345@gmail.com>
To: Nigel Cunningham <ncunningham@crca.org.au>
Cc: Arjan van de Ven <arjan@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>, Alain Knaff <alain@knaff.lu>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] lib: add fast lzo decompressor
Date: Fri, 03 Apr 2009 12:54:20 +0200 [thread overview]
Message-ID: <1238756060.11839.19.camel@andreas-desktop> (raw)
In-Reply-To: <1238705969.10479.8.camel@nigel-laptop>
On Fri, 2009-04-03 at 07:59 +1100, Nigel Cunningham wrote:
> static int toi_compress_write_page(unsigned long index,
> struct page *buffer_page, unsigned int buf_size)
> {
> int ret, cpu = smp_processor_id();
> struct cpu_context *ctx = &per_cpu(contexts, cpu);
>
> if (!ctx->transform)
> return next_driver->write_page(index, buffer_page, buf_size);
>
> ctx->buffer_start = kmap(buffer_page);
>
> ctx->len = buf_size;
The LZO compressor can produce more bytes than it consumes but here the
output buffer is the same size as the input.
This macro in linux/lzo.h defines how big the buffer needs to be:
#define lzo1x_worst_compress(x) ((x) + ((x) / 16) + 64 + 3)
If there are multiple threads perhaps they clobber each other's output
buffers?
> ret = crypto_comp_compress(ctx->transform,
> ctx->buffer_start, buf_size,
> ctx->page_buffer, &ctx->len);
>
> kunmap(buffer_page);
>
> if (ret) {
> printk(KERN_INFO "Compression failed.\n");
> return ret;
> }
>
> mutex_lock(&stats_lock);
> toi_compress_bytes_in += buf_size;
> toi_compress_bytes_out += ctx->len;
> mutex_unlock(&stats_lock);
>
> if (ctx->len < buf_size) /* some compression */
> return next_driver->write_page(index,
> virt_to_page(ctx->page_buffer),
> ctx->len);
> else
> return next_driver->write_page(index, buffer_page, buf_size);
> }
next prev parent reply other threads:[~2009-04-03 10:55 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-01 13:40 [PATCH 0/2] lib, initramfs: Add initramfs LZO compression Andreas Robinson
2009-04-01 13:40 ` [PATCH 1/2] lib: add fast lzo decompressor Andreas Robinson
2009-04-01 16:12 ` H. Peter Anvin
2009-04-01 19:22 ` Andreas Robinson
2009-04-01 20:55 ` H. Peter Anvin
2009-04-01 22:27 ` Andreas Robinson
2009-04-01 22:42 ` H. Peter Anvin
2009-04-01 23:11 ` Arjan van de Ven
2009-04-01 23:40 ` Nigel Cunningham
2009-04-02 12:30 ` Andreas Robinson
2009-04-02 20:59 ` Nigel Cunningham
2009-04-03 10:54 ` Andreas Robinson [this message]
2009-04-03 11:48 ` Nigel Cunningham
2009-04-03 12:53 ` Andreas Robinson
2009-04-03 23:28 ` Nigel Cunningham
2009-04-02 0:02 ` H. Peter Anvin
2009-04-02 12:13 ` Andreas Robinson
2009-04-02 14:30 ` John Stoffel
2009-04-03 9:49 ` Andreas Robinson
2009-04-03 18:35 ` H. Peter Anvin
2009-04-04 14:34 ` Andreas Robinson
2009-04-01 13:40 ` [PATCH 2/2] lib, initramfs: add support for LZO-compressed initramfs Andreas Robinson
2009-04-01 19:29 ` [PATCH 3/3] lib: enable lzo-compressed kernels Andreas Robinson
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=1238756060.11839.19.camel@andreas-desktop \
--to=andr345@gmail.com \
--cc=alain@knaff.lu \
--cc=arjan@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ncunningham@crca.org.au \
/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
all inboxes | Powered by JetHome®