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




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