public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: xarray reserve/release?
Date: Tue, 19 Feb 2019 20:46:27 -0700	[thread overview]
Message-ID: <20190220034627.GA564@ziepe.ca> (raw)
In-Reply-To: <20190220012609.GC12668@bombadil.infradead.org>

On Tue, Feb 19, 2019 at 05:26:09PM -0800, Matthew Wilcox wrote:
> On Tue, Feb 19, 2019 at 04:53:49PM -0700, Jason Gunthorpe wrote:
> > Hey Matt,
> > 
> > Did you intend that xa_release doesn't work on allocating arrays:
> 
> That surprises me.  I'll take a look in the morning.

I think the issue is that this:

static inline void xa_release(struct xarray *xa, unsigned long index)
{
	xa_cmpxchg(xa, index, NULL, NULL, 0);

relies on the NULL actually being xas_store(NULL), but cmpxchg
transforms it into xas_store(XA_ZERO_ENTRY) when allocating..

So xa_reserve(), xa_release() and xa_cmpxchg() all do the same thing
for allocating arrays.

Perhaps this:

void __xa_release(struct xarray *xa, unsigned long index)
{
	XA_STATE(xas, xa, index);
	void *curr;

	curr = xas_load(&xas);
	if (curr == XA_ZERO_ENTRY)
		xas_store(&xas, NULL);
}

?

Also, I wonder if xa_reserve() is better written as as

       xa_cmpxchg(xa, index, NULL, XA_ZERO_ENTRY)

Bit clearer what is going on..

Jason

  reply	other threads:[~2019-02-20  3:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-19 23:53 xarray reserve/release? Jason Gunthorpe
2019-02-20  1:26 ` Matthew Wilcox
2019-02-20  3:46   ` Jason Gunthorpe [this message]
2019-02-20 17:14     ` Matthew Wilcox
2019-02-20 17:43       ` Jason Gunthorpe
2019-02-20 20:47         ` Matthew Wilcox
2019-02-20 21:18           ` Jason Gunthorpe

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=20190220034627.GA564@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=linux-kernel@vger.kernel.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