All of lore.kernel.org
 help / color / mirror / Atom feed
* Make zswap same filled pages copy on write
@ 2022-06-16 16:40 Yeongjin Kwon
  2022-06-21  9:08 ` David Hildenbrand
  0 siblings, 1 reply; 2+ messages in thread
From: Yeongjin Kwon @ 2022-06-16 16:40 UTC (permalink / raw)
  To: linux-mm

Hi,

As I understand it, zswap currently handles same filled pages by
storing them uncompressed and then copying them out when they are
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
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
just an idea I figured I would mention here. Also please CC responses
to me, since I am not subscribed to the mailing list.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Make zswap same filled pages copy on write
  2022-06-16 16:40 Make zswap same filled pages copy on write Yeongjin Kwon
@ 2022-06-21  9:08 ` David Hildenbrand
  0 siblings, 0 replies; 2+ messages in thread
From: David Hildenbrand @ 2022-06-21  9:08 UTC (permalink / raw)
  To: Yeongjin Kwon, linux-mm

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-21  9:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-16 16:40 Make zswap same filled pages copy on write Yeongjin Kwon
2022-06-21  9:08 ` David Hildenbrand

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.