linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chengming Zhou <zhouchengming@bytedance.com>
To: Nhat Pham <nphamcs@gmail.com>, Yosry Ahmed <yosryahmed@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Chris Li <chriscli@google.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Seth Jennings <sjenning@redhat.com>,
	Dan Streetman <ddstreet@ieee.org>,
	Vitaly Wool <vitaly.wool@konsulko.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 2/5] mm/zswap: change dstmem size to one page
Date: Thu, 14 Dec 2023 23:03:22 +0800	[thread overview]
Message-ID: <7a0e3229-be63-4a24-a3fe-7e3ff517de10@bytedance.com> (raw)
In-Reply-To: <7a8c77b0-c78c-427d-9545-2b328c7dc727@bytedance.com>

On 2023/12/14 21:57, Chengming Zhou wrote:
> On 2023/12/14 21:37, Yosry Ahmed wrote:
>> On Thu, Dec 14, 2023 at 5:33 AM Chengming Zhou
>> <zhouchengming@bytedance.com> wrote:
>>>
>>> On 2023/12/14 08:18, Nhat Pham wrote:
>>>> On Wed, Dec 13, 2023 at 3:34 PM Yosry Ahmed <yosryahmed@google.com> wrote:
>>>>>
>>>>> On Tue, Dec 12, 2023 at 8:18 PM Chengming Zhou
>>>>> <zhouchengming@bytedance.com> wrote:
>>>>>>
>>>>>> Change the dstmem size from 2 * PAGE_SIZE to only one page since
>>>>>> we only need at most one page when compress, and the "dlen" is also
>>>>>> PAGE_SIZE in acomp_request_set_params(). If the output size > PAGE_SIZE
>>>>>> we don't wanna store the output in zswap anyway.
>>>>>>
>>>>>> So change it to one page, and delete the stale comment.
>>>>>
>>>>> I couldn't find the history of why we needed 2 * PAGE_SIZE, it would
>>>>> be nice if someone has the context, perhaps one of the maintainers.
>>>>
>>>> It'd be very nice indeed.
>>>>
>>>>>
>>>>> One potential reason is that we used to store a zswap header
>>>>> containing the swap entry in the compressed page for writeback
>>>>> purposes, but we don't do that anymore. Maybe we wanted to be able to
>>>>> handle the case where an incompressible page would exceed PAGE_SIZE
>>>>> because of that?
>>>>
>>>> It could be hmm. I didn't study the old zswap architecture too much,
>>>> but it has been 2 * PAGE_SIZE since the time zswap was first merged
>>>> last I checked.
>>>> I'm not 100% comfortable ACK-ing the undoing of something that looks
>>>> so intentional, but FTR, AFAICT, this looks correct to me.
>>>
>>> Right, there is no any history about the reason why we needed 2 pages.
>>> But obviously only one page is needed from the current code and no any
>>> problem found in the kernel build stress testing.
>>
>> Could you try manually stressing the compression with data that
>> doesn't compress at all (i.e. dlen == PAGE_SIZE)? I want to make sure
>> that this case is specifically handled. I think using data from
>> /dev/random will do that but please double check that dlen ==
>> PAGE_SIZE.
> 
> I just did the same kernel build testing, indeed there are a few cases
> that output dlen == PAGE_SIZE.
> 
> bpftrace -e 'k:zpool_malloc {@[(uint32)arg1==4096]=count()}'
> 
> @[1]: 2
> @[0]: 12011430

I think we shouldn't put these poorly compressed output into zswap,
maybe it's better to early return in these cases when compress ratio
< threshold ratio, which can be tune by the user?

e.g. in the same kernel build testing:

bpftrace -e 'k:zpool_malloc {@[(uint32)arg1>2048]=count()}'

@[1]: 1597706
@[0]: 10886138


  reply	other threads:[~2023-12-14 15:04 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-13  4:17 [PATCH 0/5] mm/zswap: dstmem reuse optimizations and cleanups Chengming Zhou
2023-12-13  4:17 ` [PATCH 1/5] mm/zswap: reuse dstmem when decompress Chengming Zhou
2023-12-13 23:24   ` Yosry Ahmed
2023-12-14 13:29     ` Chengming Zhou
2023-12-14 13:32       ` Yosry Ahmed
2023-12-14 14:42         ` Chengming Zhou
2023-12-14 18:24           ` Yosry Ahmed
2023-12-18  8:06             ` Chengming Zhou
2023-12-14 17:59   ` Chris Li
2023-12-14 18:26     ` Yosry Ahmed
2023-12-14 22:02       ` Chris Li
2023-12-14 20:33     ` Nhat Pham
2023-12-13  4:17 ` [PATCH 2/5] mm/zswap: change dstmem size to one page Chengming Zhou
2023-12-13 23:34   ` Yosry Ahmed
2023-12-14  0:18     ` Nhat Pham
2023-12-14 13:33       ` Chengming Zhou
2023-12-14 13:37         ` Yosry Ahmed
2023-12-14 13:57           ` Chengming Zhou
2023-12-14 15:03             ` Chengming Zhou [this message]
2023-12-14 18:34               ` Yosry Ahmed
2023-12-14 18:30             ` Yosry Ahmed
2023-12-14 20:29               ` Nhat Pham
2023-12-13  4:18 ` [PATCH 3/5] mm/zswap: refactor out __zswap_load() Chengming Zhou
2023-12-13 23:37   ` Yosry Ahmed
2023-12-14  0:52   ` Yosry Ahmed
2023-12-14 14:45     ` Chengming Zhou
2023-12-18  8:15     ` Chengming Zhou
2023-12-18  9:38       ` Yosry Ahmed
2023-12-13  4:18 ` [PATCH 4/5] mm/zswap: cleanup zswap_load() Chengming Zhou
2023-12-14  0:56   ` Yosry Ahmed
2023-12-13  4:18 ` [PATCH 5/5] mm/zswap: cleanup zswap_reclaim_entry() Chengming Zhou
2023-12-13 23:27   ` Nhat Pham
2023-12-14  1:02   ` Yosry Ahmed
2023-12-14 22:23     ` Andrew Morton
2023-12-14 22:41       ` Yosry Ahmed
2023-12-18 14:03         ` Johannes Weiner
2023-12-18 14:39           ` Yosry Ahmed
2023-12-18 14:58             ` Johannes Weiner
2023-12-18 20:52               ` Yosry Ahmed
2023-12-19 12:16                 ` Chengming Zhou
2023-12-20  4:30                 ` Johannes Weiner

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=7a0e3229-be63-4a24-a3fe-7e3ff517de10@bytedance.com \
    --to=zhouchengming@bytedance.com \
    --cc=akpm@linux-foundation.org \
    --cc=chriscli@google.com \
    --cc=ddstreet@ieee.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nphamcs@gmail.com \
    --cc=sjenning@redhat.com \
    --cc=vitaly.wool@konsulko.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).