Re: [PATCH] IB/rxe: Make counters thread safe

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

 



On Sat, Nov 24, 2018 at 02:27:53PM +0000, Parav Pandit wrote:

> > > +static u64 rxe_stats_read_by_index(const struct rxe_dev *dev, int
> > > +index) {
> > > +	struct rxe_stats *stats;
> > > +	u64 sum = 0;
> > > +	int cpu;
> > > +
> > > +	for_each_possible_cpu(cpu) {
> > > +		stats = per_cpu_ptr(dev->pcpu_stats, cpu);
> > > +		sum += stats->counters[index];
> > > +	}
> > 
> > This is still racy with a writer on another CPU.
> 
> I didn't follow you. If other cpu is updating counter for given
> index, sum will be updated to user in next read cycle whenever user
> does it.  Counters are always a snapshot when read.  Idea here is to
> have right sum when multiple cpu writers are writing, which was not
> the case before this patch.

Where is the snapshot?

Reading a u64 is not possible atomically on 32 bit platforms, you get
garbage if there is a race with a writer.

Jason



[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