lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 03 Apr 2009 12:54:20 +0200
From:	Andreas Robinson <andr345@...il.com>
To:	Nigel Cunningham <ncunningham@...a.org.au>
Cc:	Arjan van de Ven <arjan@...ux.intel.com>,
	"H. Peter Anvin" <hpa@...or.com>, Alain Knaff <alain@...ff.lu>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] lib: add fast lzo decompressor

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);
> }


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ