From: Jan Kara <jack@suse.cz>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Jan Kara <jack@suse.cz>, Matthew Wilcox <willy@infradead.org>,
linux-fsdevel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 3/8] xarray: Explicitely set XA_FREE_MARK in __xa_cmpxchg()
Date: Thu, 6 Feb 2020 09:03:07 +0100 [thread overview]
Message-ID: <20200206080307.GB14001@quack2.suse.cz> (raw)
In-Reply-To: <20200205184512.GC28298@ziepe.ca>
On Wed 05-02-20 14:45:12, Jason Gunthorpe wrote:
> On Tue, Feb 04, 2020 at 03:25:09PM +0100, Jan Kara wrote:
> > __xa_cmpxchg() relies on xas_store() to set XA_FREE_MARK when storing
> > NULL into xarray that has free tracking enabled. Make the setting of
> > XA_FREE_MARK explicit similarly as its clearing currently it.
> >
> > Signed-off-by: Jan Kara <jack@suse.cz>
> > lib/xarray.c | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/lib/xarray.c b/lib/xarray.c
> > index ae8b7070e82c..4e32497c51bd 100644
> > +++ b/lib/xarray.c
> > @@ -1477,8 +1477,12 @@ void *__xa_cmpxchg(struct xarray *xa, unsigned long index,
> > curr = xas_load(&xas);
> > if (curr == old) {
> > xas_store(&xas, entry);
> > - if (xa_track_free(xa) && entry && !curr)
> > - xas_clear_mark(&xas, XA_FREE_MARK);
> > + if (xa_track_free(xa)) {
> > + if (entry && !curr)
> > + xas_clear_mark(&xas, XA_FREE_MARK);
> > + else if (!entry && curr)
> > + xas_set_mark(&xas, XA_FREE_MARK);
> > + }
>
> This feels like an optimization that should also happen for
> __xa_store, which has very similar code:
>
> curr = xas_store(&xas, entry);
> if (xa_track_free(xa))
> xas_clear_mark(&xas, XA_FREE_MARK);
>
> Something like
>
> if (xa_track_free(xa) && entry && !curr)
> xas_clear_mark(&xas, XA_FREE_MARK);
>
> ?
Yeah, entry != NULL is guaranteed for __xa_store() (see how it transforms
NULL to XA_ZERO_ENTRY a few lines above) but !curr is probably a good
condition to add to save some unnecessary clearing when overwriting
existing values. It is unrelated to this patch though, just a separate
optimization so I'll add that as a separate patch to the series. Thanks for
the idea.
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2020-02-06 8:03 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-04 14:25 [PATCH 0/8] mm: Speedup page cache truncation Jan Kara
2020-02-04 14:25 ` [PATCH 1/8] xarray: Fix premature termination of xas_for_each_marked() Jan Kara
2020-03-12 21:45 ` Matthew Wilcox
2020-03-16 9:16 ` Jan Kara
2020-02-04 14:25 ` [PATCH 2/8] xarray: Provide xas_erase() helper Jan Kara
2020-03-14 19:54 ` Matthew Wilcox
2020-03-16 9:21 ` Jan Kara
2020-03-17 15:28 ` Matthew Wilcox
2020-04-15 16:12 ` Jan Kara
2020-02-04 14:25 ` [PATCH 3/8] xarray: Explicitely set XA_FREE_MARK in __xa_cmpxchg() Jan Kara
2020-02-05 18:45 ` Jason Gunthorpe
2020-02-06 8:03 ` Jan Kara [this message]
2020-03-17 15:12 ` Matthew Wilcox
2020-02-04 14:25 ` [PATCH 4/8] mm: Use xas_erase() in page_cache_delete_batch() Jan Kara
2020-02-04 14:25 ` [PATCH 5/8] dax: Use xas_erase() in __dax_invalidate_entry() Jan Kara
2020-02-04 14:25 ` [PATCH 6/8] idr: Use xas_erase() in ida_destroy() Jan Kara
2020-02-04 14:25 ` [PATCH 7/8] mm: Use xas_erase() in collapse_file() Jan Kara
2020-02-04 14:25 ` [PATCH 8/8] xarray: Don't clear marks in xas_store() Jan Kara
2020-02-05 18:43 ` Jason Gunthorpe
2020-02-05 21:59 ` Matthew Wilcox
2020-02-06 13:49 ` Jason Gunthorpe
2020-02-06 14:36 ` Jan Kara
2020-02-06 14:49 ` Jason Gunthorpe
2020-02-05 22:19 ` John Hubbard
2020-02-06 2:21 ` Matthew Wilcox
2020-02-06 3:48 ` John Hubbard
2020-02-06 4:28 ` Matthew Wilcox
2020-02-06 4:37 ` John Hubbard
2020-02-06 8:36 ` Jan Kara
2020-02-06 8:04 ` Jan Kara
2020-02-06 14:40 ` [PATCH 0/8] mm: Speedup page cache truncation David Sterba
2020-02-18 9:25 ` Jan Kara
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=20200206080307.GB14001@quack2.suse.cz \
--to=jack@suse.cz \
--cc=jgg@ziepe.ca \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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