mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lasse Collin <lasse.collin@tukaani.org>
To: Baoquan He <bhe@redhat.com>
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, alain@knaff.lu,
	phillip@lougher.demon.co.uk, akpm@linux-foundation.org,
	keescook@chromium.org, bp@alien8.de, vgoyal@redhat.com
Subject: Re: About support XZ-compressed kernel on x86
Date: Mon, 15 Feb 2016 22:26:22 +0200	[thread overview]
Message-ID: <20160215222622.7e159519@tukaani.org> (raw)
In-Reply-To: <20160214133138.GA2552@x1.redhat.com>

On 2016-02-14 Baoquan He wrote:
> On 02/13/16 at 08:57pm, Lasse Collin wrote:
> > The long comment in arch/x86/boot/compressed/misc.c explains the
> > need for the offset for gzip/Deflate. A similar comment in
> > lib/decompress_unxz.c explains it for XZ/LZMA2.  
> 
> Thank you so much, Lasse. You clearly pointed out my confusion.
> Yeah, I didn't understand it well. Your description for xz in
> lib/decompress_unxz.c is very helpful. The 64K is the maximum payload
> in one chunk. Adding this 64K is to avoid the worst case that very
> small payload can reprsent a 64K uncompressed output data. With my
> understanding it could be  a chunk which contains complete duplicate
> content. like all "0" or other stuff?

Yes, like all zeros. I wrote another explanation just in case it helps:

In-place decompression puts the compressed data at the end of the
buffer and decompresses it to the beginning of the buffer:

    F = free memory
    K = uncompressed kernel
    C = compressed input data

    Start:         FFFFFFFFFFFFFFCCCCCCCC
    Decompressing: KKKKKKKKKKFFFFFFFFCCCC
    Finished:      KKKKKKKKKKKKKKKKKKKKFF

The free memory (FF) at the end is the safety margin.

In the worst case the beginning of the uncompressed data compresses to
almost nothing (like all zeros do), and the end of the data is
incompressible. In the beginning the write position of the decompressor
advances quickly while the read position moves very little, and thus
the write position quickly approaches the read position:

    Start:         FFFFFFFFFFFFFFCCCCCCCC
    Decompressing: KKKKKKKKKKKKKKFCCCCCCC
    Finished:      KKKKKKKKKKKKKKKKKKKKFF

The safety margin ensures that the write position can never overtake
the read position.

-- 
Lasse Collin  |  IRC: Larhzu @ IRCnet & Freenode

  reply	other threads:[~2016-02-15 20:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-12 15:34 Baoquan He
2016-02-12 15:41 ` Baoquan He
2016-02-13 18:57 ` Lasse Collin
2016-02-14 13:31   ` Baoquan He
2016-02-15 20:26     ` Lasse Collin [this message]
2016-02-16 13:20       ` Baoquan He
2016-02-17 17:57         ` Lasse Collin
2016-02-18  0:48           ` Baoquan He
2016-02-19 20:19             ` Lasse Collin

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=20160215222622.7e159519@tukaani.org \
    --to=lasse.collin@tukaani.org \
    --cc=akpm@linux-foundation.org \
    --cc=alain@knaff.lu \
    --cc=bhe@redhat.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phillip@lougher.demon.co.uk \
    --cc=vgoyal@redhat.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

all inboxes | Powered by JetHome®