lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJD7tkbc7j8B3X8YfQ9r00D3ojJvJg+YwNuAF6P=jyCyrGy_=Q@mail.gmail.com>
Date: Tue, 6 Feb 2024 21:45:41 -0800
From: Yosry Ahmed <yosryahmed@...gle.com>
To: Chris Li <chrisl@...nel.org>
Cc: chengming.zhou@...ux.dev, hannes@...xchg.org, nphamcs@...il.com, 
	akpm@...ux-foundation.org, linux-mm@...ck.org, linux-kernel@...r.kernel.org, 
	Chengming Zhou <zhouchengming@...edance.com>, stable@...r.kernel.org
Subject: Re: [PATCH v3] mm/zswap: invalidate old entry when store fail or !zswap_enabled

> > @@ -1608,14 +1598,12 @@ bool zswap_store(struct folio *folio)
> >         /* map */
> >         spin_lock(&tree->lock);
> >         /*
> > -        * A duplicate entry should have been removed at the beginning of this
> > -        * function. Since the swap entry should be pinned, if a duplicate is
> > -        * found again here it means that something went wrong in the swap
> > -        * cache.
> > +        * The folio may have been dirtied again, invalidate the
> > +        * possibly stale entry before inserting the new entry.
> >          */
> > -       while (zswap_rb_insert(&tree->rbroot, entry, &dupentry) == -EEXIST) {
> > -               WARN_ON(1);
> > +       if (zswap_rb_insert(&tree->rbroot, entry, &dupentry) == -EEXIST) {
> >                 zswap_invalidate_entry(tree, dupentry);
> > +               VM_WARN_ON(zswap_rb_insert(&tree->rbroot, entry, &dupentry));
>
> It seems there is only one path called zswap_rb_insert() and there is
> no loop to repeat the insert any more. Can we have the
> zswap_rb_insert() install the entry and return the dupentry? We can
> still just call zswap_invalidate_entry() on the duplicate. The mapping
> of the dupentry has been removed when  zswap_rb_insert() returns. That
> will save a repeat lookup on the duplicate case.
> After this change, the zswap_rb_insert() will map to the xarray
> xa_store() pretty nicely.

I brought this up in v1 [1]. We agreed to leave it as-is for now since
we expect the xarray conversion soon-ish. No need to update
zswap_rb_insert() only to replace it with xa_store() later anyway.

[1] https://lore.kernel.org/lkml/ZcFne336KJdbrvvS@google.com/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ