Re: [RFC PATCH] locking/percpu-rwsem: use this_cpu_{inc|dec}() for read_count

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

 



On Fri, Sep 18, 2020 at 12:04:32PM +0200, peterz@xxxxxxxxxxxxx wrote:
> On Fri, Sep 18, 2020 at 12:01:12PM +0200, peterz@xxxxxxxxxxxxx wrote:
> > @@ -198,7 +198,9 @@ EXPORT_SYMBOL_GPL(__percpu_down_read);
> >   */
> >  static bool readers_active_check(struct percpu_rw_semaphore *sem)
> >  {
> > -	if (per_cpu_sum(*sem->read_count) != 0)
> > +	u64 sum = per_cpu_sum(*(u64 *)sem->read_count);
> > +
> > +	if (sum + (sum >> 32))
> 
> That obviously wants to be:
> 
> 	if ((u32)(sum + (sum >> 32)))
> 
> >  		return false;
> >  
> >  	/*

I suppose an alternative way of writing that would be something like:

	union {
		u64 sum;
		struct {
			u32 a, b;
		};
	} var;

	var.sum = per_cpu_sum(*(u64 *)sem->read_count);

	if (var.a + var.b)
		return false;

which is more verbose, but perhaps easier to read.



[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