Re: [PATCH 8/8] xarray: Don't clear marks in xas_store()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed 05-02-20 20:28:01, Matthew Wilcox wrote:
> On Wed, Feb 05, 2020 at 07:48:57PM -0800, John Hubbard wrote:
> > You can then set entries using xa_store() and get entries
> > using xa_load().  xa_store will overwrite any entry with the
> > new entry and return the previous entry stored at that index.  You can
> > use xa_erase(), instead of calling xa_store() with a
> > ``NULL`` entry followed by xas_init_marks().  There is no difference between
> > an entry that has never been stored to and one that has been erased. Those,
> > in turn, are the same as an entry that has had ``NULL`` stored to it and
> > also had its marks erased via xas_init_marks().
> 
> There's a fundamental misunderstanding here.  If you store a NULL, the
> marks go away.  There is no such thing as a marked NULL entry.  If you
> observe such a thing, it can only exist through some kind of permitted
> RCU race, and the entry must be ignored.  If you're holding the xa_lock,
> there is no way to observe a NULL entry with a search mark set.
> 
> What Jan is trying to do is allow code that knows what it's doing
> the ability to say "Skip clearing the marks for performance reasons.
> The marks are already clear."
> 
> I'm still mulling over the patches from Jan.  There's something I don't
> like about them, but I can't articulate it in a useful way yet.  I'm on
> board with the general principle, and obviously the xas_for_each_marked()
> bug needs to be fixed.

There are different ways how to look at what I'm doing :) I was thinking
about it more like "xas_store() is for storing value at some index",
"xas_erase() is when I want the value at some index removed from the data
structure". Because these are principially different operations for any
data structure (as much as erasing can be *implemented* by just storing
NULL at some index). You seem to recognize this for xa_ functions but you
probably considered xas_ functions internal enough that they follow more
the "how it is implemented" way of thinking.

Now I agree that there are holes in my way of thinking about xas_store()
because if you happen to store NULL at some index, marks may get destroyed
as a side-effect. And some users of __xa_cmpxchg() (BTW nobody seems to be
using xa_cmpxchg_bh()) do use the fact that storing NULL does effectively
erase an entry which is BTW inconsistent with xa_store() itself as well...

You've been probably thinking more about xarray API semantics than I was so
I can be convinced otherwise but at this point, I'd rather move the API
more towards "erase is different from storing NULL".

									Honza

-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux