From: Chengming Zhou <chengming.zhou@linux.dev>
To: Yosry Ahmed <yosryahmed@google.com>,
Johannes Weiner <hannes@cmpxchg.org>
Cc: Nhat Pham <nphamcs@gmail.com>, Chris Li <chrisl@kernel.org>,
Linux-MM <linux-mm@kvack.org>
Subject: Re: [RFC] Storing same-filled pages without a zswap_entry
Date: Thu, 21 Mar 2024 11:40:32 +0800 [thread overview]
Message-ID: <7d7b755a-e13e-4267-b1b5-a4e2ff33d6e0@linux.dev> (raw)
In-Reply-To: <CAJD7tkb98M=nimo_XWUMNbG-WHuDZa=ZYQ+7RTtzDLjME+tNLw@mail.gmail.com>
On 2024/3/21 05:31, Yosry Ahmed wrote:
> On Wed, Mar 20, 2024 at 2:19 PM Johannes Weiner <hannes@cmpxchg.org> wrote:
>>
>> On Wed, Mar 20, 2024 at 05:07:21PM -0400, Johannes Weiner wrote:
>>> On Wed, Mar 20, 2024 at 01:49:17PM -0700, Yosry Ahmed wrote:
>>>> Hey folks,
>>>>
>>>> I was looking at cleaning up the same-filled handling code in zswap,
>>>> when it hit me that after the xarray conversion, the only member of
>>>> struct zwap_entry that is relevant to same-filled pages is now the
>>>> objcg pointer.
>>>>
>>>> The xarray allows a pointer to be tagged by up to two tags (1 and 3),
>>>> so we can completely avoid allocating a zswap_entry for same-filled
>>>> pages by storing a tagged objcg pointer directly in the xarray
>>>> instead.
>>>>
>>>> Basically the xarray would then either have a pointer to struct
>>>> zswap_entry or struct obj_cgroup, where the latter is tagged as
>>>> SAME_FILLED_ONE or SAME_FILLED_ZERO.
>>>>
>>>> There are two benefits of this:
>>>> - Saving some memory (precisely 64 bytes per same-filled entry).
>>>> - Further separating handling of same-filled pages from compressed
>>>> pages, which results in some nice cleanups (especially in
>>>> zswap_store()). It also makes further improvements easier (e.g.
>>>> skipping limit checking for same-filled entries).
I also think this is a good idea. :) Which could simplify the code too.
>>>
>>> This sounds interesting.
>>>
>>> Where would you store the byte value it's filled with? Or would you
>>> limit it to zero-filled only?
>>
>> The dumb thing about objcg is that for same-filled entries we really
>> only need it for bumping ZSWPIN. Nothing else. entry->length is 0 for
>> them, so even though we call the charge function, it doesn't actually
>> do anything.
>>
>> Loading them is cheap and doesn't involve decompression. An argument
>> could be made to exclude them from ZSWPOUT and ZSWPIN entirely.
>>
>> Or cheat a little and bump ZSWPIN for current->objcg instead -
>> probably good enough to make excessive thrashing discoverable by the
>> workload that's directly affected.
>>
>> Then you could get rid of the objcg pointer and use the xarray slot
>> for whatever else you'd want.
>
> Yeah it's only useful for the stats. Using current->objcg would work,
> and should be ultimately pointing to the same memcg in *most* cases, I
In some cases where the current objcg is not "correct", the testcases in
test_zswap.c may break? Maybe we can use swap_cgroup info to charge the
stats to the correct memcg? Not sure if this is feasible.
> assume. We still wouldn't be able to store a full word as we do today,
> because the xarray needs 1 bit for its own usage. So the same-filled
> implementation would still need to change from repeated words (8
> bytes) to something smaller -- or we can just allocate a separate
> struct for same-filled pages.
Yes, this seems an unavoidable limit of value in xarray...
Thanks.
next prev parent reply other threads:[~2024-03-21 3:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-20 20:49 [RFC] Storing same-filled pages without a zswap_entry Yosry Ahmed
2024-03-20 21:07 ` Johannes Weiner
2024-03-20 21:14 ` Yosry Ahmed
2024-03-20 21:19 ` Johannes Weiner
2024-03-20 21:31 ` Yosry Ahmed
2024-03-21 3:40 ` Chengming Zhou [this message]
2024-03-21 18:44 ` Yosry Ahmed
2024-03-21 19:29 ` Johannes Weiner
2024-03-21 19:57 ` Yosry Ahmed
2024-03-22 0:28 ` Chris Li
2024-03-22 0:37 ` Yosry Ahmed
2024-03-20 21:42 ` Chris Li
2024-03-21 4:26 ` Chris Li
2024-03-21 18:50 ` Yosry Ahmed
2024-03-22 0:18 ` Chris Li
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=7d7b755a-e13e-4267-b1b5-a4e2ff33d6e0@linux.dev \
--to=chengming.zhou@linux.dev \
--cc=chrisl@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=yosryahmed@google.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 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.