From: Usama Arif <usamaarif642@gmail.com>
To: Nhat Pham <nphamcs@gmail.com>
Cc: akpm@linux-foundation.org, hannes@cmpxchg.org, david@redhat.com,
ying.huang@intel.com, hughd@google.com, willy@infradead.org,
yosryahmed@google.com, chengming.zhou@linux.dev,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com, Shakeel Butt <shakeel.butt@linux.dev>
Subject: Re: [PATCH v3 1/2] mm: store zero pages to be swapped out in a bitmap
Date: Wed, 12 Jun 2024 11:42:47 +0100 [thread overview]
Message-ID: <b7635421-e5e3-47cc-9aea-13a4a9c224fb@gmail.com> (raw)
In-Reply-To: <CAKEwX=MOWFQojVgO7u=zEpQSG661j1QHjTGL9m3Gcy47CLNKAg@mail.gmail.com>
On 11/06/2024 20:33, Nhat Pham wrote:
> On Tue, Jun 11, 2024 at 11:50 AM Usama Arif <usamaarif642@gmail.com> wrote:
>> In swap_writepage, with this patch you have:
>>
>> if (is_folio_zero_filled(folio)) {
>> swap_zeromap_folio_set(folio);
>> folio_unlock(folio);
>> return 0;
>> }
>> swap_zeromap_folio_clear(folio);
>>
> I was concerned with the swap slot being freed and reused, without
> ever being read :) But looks like it has to be properly reset before
> being reused, so all is well on that front.
>
> What about the put_swap_folio() -> swap_free_cluster() case - do we
> need to handle zeromap bit clearing here too? Looks like it's clearing
> the swap_map (i.e returning it directly to the swapfile, allowing
> those slots to be reused) here, and I notice that you clear the
> zeromap bitmap wherever the swap_map is cleared as well :)
>
> I jumped around the code a bit - in free_cluster() (called by
> swap_free_cluster()), there's this chunk:
>
> if ((si->flags & (SWP_WRITEOK | SWP_PAGE_DISCARD)) ==
> (SWP_WRITEOK | SWP_PAGE_DISCARD)) {
> swap_cluster_schedule_discard(si, idx);
> return;
> }
>
> swap_cluster_schedule_discard() does clear_bit() on the zeromap on the
> entire cluster. We also clear_bit() in the work function
> swap_do_scheduled_discard() (is this redundant?).
>
> But what if this check is false, i.e the swap device does not have the
> SWP_PAGE_DISCARD flag set? Are we not clearing the bits in the zeromap
> here?
Yes, should add in swap_free_cluster as well, will do in next revision.
Thanks!
next prev parent reply other threads:[~2024-06-12 10:42 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-10 12:15 [PATCH v3 0/2] " Usama Arif
2024-06-10 12:15 ` [PATCH v3 1/2] " Usama Arif
2024-06-10 13:07 ` Matthew Wilcox
2024-06-10 13:56 ` Usama Arif
2024-06-10 14:06 ` Matthew Wilcox
2024-06-10 14:14 ` Usama Arif
2024-06-10 14:33 ` Usama Arif
2024-06-10 17:57 ` Yosry Ahmed
2024-06-10 18:36 ` Usama Arif
2024-06-10 18:47 ` Yosry Ahmed
2024-06-11 11:49 ` Usama Arif
2024-06-11 15:42 ` Yosry Ahmed
2024-06-11 16:52 ` Usama Arif
2024-06-11 17:51 ` Yosry Ahmed
2024-06-11 18:43 ` Usama Arif
2024-06-11 18:39 ` Nhat Pham
2024-06-11 18:46 ` Yosry Ahmed
2024-06-11 18:53 ` Nhat Pham
2024-06-11 18:50 ` Usama Arif
2024-06-11 19:33 ` Nhat Pham
2024-06-12 10:42 ` Usama Arif [this message]
2024-06-10 12:16 ` [PATCH v3 2/2] mm: remove code to handle same filled pages Usama Arif
2024-06-13 21:21 ` [PATCH v3 0/2] mm: store zero pages to be swapped out in a bitmap Yosry Ahmed
2024-06-14 9:22 ` Usama Arif
2024-06-14 9:28 ` Yosry Ahmed
2024-06-13 21:50 ` Yosry Ahmed
2024-06-13 22:41 ` Shakeel Butt
2024-06-13 22:59 ` Yosry Ahmed
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=b7635421-e5e3-47cc-9aea-13a4a9c224fb@gmail.com \
--to=usamaarif642@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--cc=david@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=shakeel.butt@linux.dev \
--cc=willy@infradead.org \
--cc=ying.huang@intel.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