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: <20190220171414.GI12668@bombadil.infradead.org>
Date:   Wed, 20 Feb 2019 09:14:14 -0800
From:   Matthew Wilcox <willy@...radead.org>
To:     Jason Gunthorpe <jgg@...pe.ca>
Cc:     linux-kernel@...r.kernel.org
Subject: Re: xarray reserve/release?

On Tue, Feb 19, 2019 at 08:46:27PM -0700, Jason Gunthorpe wrote:
> 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..

Yes, you're right.

> 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);
> }
> 
> ?

I decided to instead remove the magic from xa_cmpxchg().  I used
to prohibit any internal entry being passed to the regular API, but
I recently changed that with 76b4e5299565 ("XArray: Permit storing
2-byte-aligned pointers").  Now that we can pass XA_ZERO_ENTRY, I
think this all makes much more sense.

> 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..

Yes, I agree.  I've pushed a couple of new commits to
http://git.infradead.org/users/willy/linux-dax.git/shortlog/refs/heads/xarray

which should fix your problem, and implement this optimisation.
Thanks for the report!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ