linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Yeongjin Kwon <yeongjinkwon@gmail.com>, linux-mm@kvack.org
Subject: Re: Make zswap same filled pages copy on write
Date: Tue, 21 Jun 2022 11:08:05 +0200	[thread overview]
Message-ID: <7b6f42ea-ba97-2f73-ca7f-9ea23fa8da06@redhat.com> (raw)
In-Reply-To: <CANPvvcPzd1pf6i0iCgoF+Y=C=iJ57mcYqBOJfa=OOKrPyCJQRQ@mail.gmail.com>

On 16.06.22 18:40, Yeongjin Kwon wrote:
> Hi,
> 

Hi

> As I understand it, zswap currently handles same filled pages by
> storing them uncompressed and then copying them out when they are

What I get from the doc is:

"
Some of the pages in zswap are same-value filled pages (i.e. contents of
the page have same value or repetitive pattern). These pages include
zero-filled pages and they are handled differently. During store
operation, a page is checked if it is a same-value filled page before
compressing it. If true, the compressed length of the page is set to
zero and the pattern or same-filled value is stored.
"

And staring at the code (zswap_is_page_same_filled()) all it does is
checking for a repetitive pattern sizeof(unsigned long) pattern and
storing that pattern instead of compressing.

Which is an optimization for compression, not deduplication of pages.

If a page is filled with 0xFF, just store "page is filled with 0xFF"
instead of a pointer to a compressed chunk stating the same.


> loaded. A possible alternative could be to have same filled pages that
> get swapped out mapped to the page stored in zswap as copy on write in
> the page table, instead of being marked as swapped out. Then reads

zswap really feels like the wrong place to do something like that. Its
job is not memory deduplication, it's compression. We do have KSM for
deduplication.

> from the "swapped out" page will just read the underlying page stored
> in zswap, and the stored page will only be truly loaded/copied out
> when it is written to. This is similar in concept to the copy on write
> mechanism the kernel has for forking processes. Would this be worth
> implementing? I am largely unfamiliar with kernel development. This is

Please take a look at KSM. And maybe how KSM and similar memory
deduplication techniques provide a steady stream of work for security
researchers.

:)

-- 
Thanks,

David / dhildenb



      reply	other threads:[~2022-06-21  9:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-16 16:40 Yeongjin Kwon
2022-06-21  9:08 ` David Hildenbrand [this message]

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=7b6f42ea-ba97-2f73-ca7f-9ea23fa8da06@redhat.com \
    --to=david@redhat.com \
    --cc=linux-mm@kvack.org \
    --cc=yeongjinkwon@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