Re: xa_cmpxchg and XA_ZERO_ENTRY?

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

 



On Wed, Oct 30, 2024 at 10:15:13AM -0300, Jason Gunthorpe wrote:
> Hi Matthew,
> 
> Nicolin pointed this out and I was wondering what is the right thing.
> 
> For instance this:
> 
> 	xa_init(&xa);
> 	ret = xa_reserve(&xa, 1, GFP_KERNEL);
> 	printk("xa_reserve() = %d\n", ret);
> 	old = xa_cmpxchg(&xa, 1, NULL, &xa, GFP_KERNEL);

You're really not supposed to be doing xa_cmpxchg() here.  Just use
xa_store().  That's the intended way to use these APIs.

> The general purpose of code like the above is to just validate that
> the xa has not been corrupted, that the index we are storing to has
> been reserved. Maybe we can't sleep or something.

Thr intent is to provide you with an array abstraction.  You don't
cmpxchg() pointers into an array, do you?  Almost everybody just does
array[i] = p.




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

  Powered by Linux