linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Yosry Ahmed <yosryahmed@google.com>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Vlastimil Babka <vbabka@suse.cz>,
	Matthew Wilcox <willy@infradead.org>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Christoph Hellwig <hch@infradead.org>,
	 Nhat Pham <nphamcs@gmail.com>,
	Domenico Cerasuolo <cerasuolodomenico@gmail.com>,
	konrad.wilk@oracle.com,  vitaly.wool@konsulko.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: kill frontswap
Date: Wed, 19 Jul 2023 08:22:52 -0700	[thread overview]
Message-ID: <CAJD7tkYTmkVAbm20gmU0nB4vyA8YEy2+uRiQLFW00RHUApn+9Q@mail.gmail.com> (raw)
In-Reply-To: <20230719142832.GA932528@cmpxchg.org>

On Wed, Jul 19, 2023 at 7:28 AM Johannes Weiner <hannes@cmpxchg.org> wrote:
>
> Hi Yosry,
>
> thanks for the review. I hope I saw everything you commented on ;) -
> can you please trim your replies to the relevant hunks?

You did :) Sorry for that, my client automatically trims the quotes so
I couldn't perceive the size of the problem :p

>
> On Tue, Jul 18, 2023 at 11:52:45AM -0700, Yosry Ahmed wrote:
> > On Mon, Jul 17, 2023 at 9:02 AM Johannes Weiner <hannes@cmpxchg.org> wrote:
> > > -/*
> > > - * "Get" data from frontswap associated with swaptype and offset that were
> > > - * specified when the data was put to frontswap and use it to fill the
> > > - * specified page with data. Page must be locked and in the swap cache.
> > > - */
> > > -int __frontswap_load(struct page *page)
> > > -{
> > > -       int ret = -1;
> > > -       swp_entry_t entry = { .val = page_private(page), };
> > > -       int type = swp_type(entry);
> > > -       struct swap_info_struct *sis = swap_info[type];
> > > -       pgoff_t offset = swp_offset(entry);
> > > -       bool exclusive = false;
> > > -
> > > -       VM_BUG_ON(!frontswap_ops);
> > > -       VM_BUG_ON(!PageLocked(page));
> > > -       VM_BUG_ON(sis == NULL);
> > > -
> > > -       if (!__frontswap_test(sis, offset))
> > > -               return -1;
> >
> > With the removal of the above, it will be a bit slower to realize an
> > entry is not in zswap and read it from disk (bitmask test vs. rbtree
> > lookup). I guess in the swapin path (especially from disk), it would
> > not matter much in practice. Just a note (mostly to myself).
>
> I briefly considered moving that bitmap to zswap, but it actually
> seems quite backwards. It adds overhead to the fast path, where
> entries are in-cache, in order to optimize the cold path that requires
> IO. As long as compression is faster than IO, zswap is expected to see
> the (much) bigger share of transactions in any sane config.

Makes sense to me, thanks for the clarification. Maybe we should put
this in the commit log as well?

>
> > > @@ -1356,15 +1342,12 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset,
> > >
> > >         /* map */
> > >         spin_lock(&tree->lock);
> > > -       do {
> > > -               ret = zswap_rb_insert(&tree->rbroot, entry, &dupentry);
> > > -               if (ret == -EEXIST) {
> > > -                       zswap_duplicate_entry++;
> > > -                       /* remove from rbtree */
> > > -                       zswap_rb_erase(&tree->rbroot, dupentry);
> > > -                       zswap_entry_put(tree, dupentry);
> > > -               }
> > > -       } while (ret == -EEXIST);
> > > +       while (zswap_rb_insert(&tree->rbroot, entry, &dupentry) == -EEXIST) {
> > > +               zswap_duplicate_entry++;
> > > +               /* remove from rbtree */
> > > +               zswap_rb_erase(&tree->rbroot, dupentry);
> > > +               zswap_entry_put(tree, dupentry);
> >
> > nit: it would be nice to replace the above two lines with
> > zswap_invalidate_entry(), which also keeps it clear that we maintain
> > the frontswap semantics of invalidating a duplicated entry.
>
> Agreed, that's better. I'll send a follow-up.

Thanks!

>
> > > @@ -1418,7 +1401,7 @@ static int zswap_frontswap_load(unsigned type, pgoff_t offset,
> > >         if (!entry) {
> > >                 /* entry was written back */
> >
> > nit: the above comment is now obsolete. We may not find the entry
> > because it was never stored in zswap in the first place (since we
> > dropped the frontswap map, we won't know before we do the lookup
> > here).
>
> Good catch. I'll send a delta fix to Andrew.
>
> > LGTM with a few nits above, probably they can be done in follow up
> > patches. Thanks for the cleanup!
> >
> > FWIW:
> > Acked-by: Yosry Ahmed <yosryahmed@google.com>
>
> Thanks!
>
> Andrew, could you please fold this in?
>
> ---
>
> From 86eeba389d7478e5794877254af6cc0310c835c7 Mon Sep 17 00:00:00 2001
> From: Johannes Weiner <hannes@cmpxchg.org>
> Date: Wed, 19 Jul 2023 10:21:49 -0400
> Subject: [PATCH] mm: kill frontswap fix
>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> ---
>  mm/zswap.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/mm/zswap.c b/mm/zswap.c
> index d58672f23d43..583ef7b84dc3 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -1399,7 +1399,6 @@ bool zswap_load(struct page *page)
>         spin_lock(&tree->lock);
>         entry = zswap_entry_find_get(&tree->rbroot, offset);
>         if (!entry) {
> -               /* entry was written back */
>                 spin_unlock(&tree->lock);
>                 return false;
>         }
> --
> 2.41.0


  reply	other threads:[~2023-07-19 15:23 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-14 19:46 [PATCH] mm: kill frontswap Johannes Weiner
2023-07-14 21:10 ` Konrad Rzeszutek Wilk
2023-07-14 22:25 ` Nhat Pham
2023-07-15  3:42 ` Matthew Wilcox
2023-07-17 14:12   ` Johannes Weiner
2023-07-17 14:31     ` Vlastimil Babka
2023-07-17 16:02       ` Johannes Weiner
2023-07-17 16:07         ` Matthew Wilcox
2023-07-17 21:51           ` Johannes Weiner
2023-07-17 22:58             ` Nhat Pham
2023-07-18 18:52         ` Yosry Ahmed
2023-07-19 14:28           ` Johannes Weiner
2023-07-19 15:22             ` Yosry Ahmed [this message]
2024-01-16 20:09         ` Andrew Morton
2024-01-16 20:18           ` Matthew Wilcox
2024-01-16 20:22             ` Yosry Ahmed
2024-01-16 21:35               ` Andrew Morton
2023-07-15  4:23 ` [PATCH 0/5] Followup folio conversions for zswap Matthew Wilcox (Oracle)
2023-07-15  4:23   ` [PATCH 1/5] fix-frontswap Matthew Wilcox (Oracle)
2023-07-15  4:23   ` [PATCH 2/5] zswap: Make zswap_store() take a folio Matthew Wilcox (Oracle)
2023-07-15  4:23   ` [PATCH 3/5] memcg: Convert get_obj_cgroup_from_page to get_obj_cgroup_from_folio Matthew Wilcox (Oracle)
2023-07-15  4:23   ` [PATCH 4/5] swap: Remove some calls to compound_head() in swap_readpage() Matthew Wilcox (Oracle)
2023-07-15  4:23   ` [PATCH 5/5] zswap: Make zswap_load() take a folio Matthew Wilcox (Oracle)
2023-07-20  6:00 ` [PATCH] mm: kill frontswap Christoph Hellwig

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=CAJD7tkYTmkVAbm20gmU0nB4vyA8YEy2+uRiQLFW00RHUApn+9Q@mail.gmail.com \
    --to=yosryahmed@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=cerasuolodomenico@gmail.com \
    --cc=hannes@cmpxchg.org \
    --cc=hch@infradead.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nphamcs@gmail.com \
    --cc=vbabka@suse.cz \
    --cc=vitaly.wool@konsulko.com \
    --cc=willy@infradead.org \
    /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).