Re: [PATCH rdma-next] IB/core: Protect against concurrent access to hardware stats

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

 



On Fri, 30 Mar 2018, Leon Romanovsky wrote:

> On Wed, Mar 28, 2018 at 04:57:33PM -0500, Christopher Lameter wrote:
> > On Tue, 27 Mar 2018, Leon Romanovsky wrote:
> >
> > > +
> > > +	mutex_lock(&stats->lock);
> > > +	msecs = jiffies_to_msecs(stats->lifespan);
> > > +	mutex_unlock(&stats->lock);
> > > +
> > >  	return sprintf(buf, "%d\n", msecs);
> >
> > Yuck. Can we use atomic64_t instead of u64 there? There are already ops
> > defined for these types of scalars that ensure atomicity when using a
> > variety of operations. The way this is going means that one needs to be
> > aware of the special nature of the u64s here and manually take locks which
> > is error prone.
> >
> > Plus you wont need a mutex with atomc64_t.
> >
> > Plus it falls back to sane code on 64 bit platforms where this is not
> > needed.
> Do you mean to use get_jiffies_64() and friends?

No I mean that the stats should be atomic64_t if you want safe 32 bit
support.

You are here improvising safe handling of 64 bit entities in the driver
subsystem of the kernel using a mutex. That is not the way to do things.

You need to be using proper kernel infrastructure for handling 64 bit
entities.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux