RE: [PATCH 1/1] swiotlb: Track and report io_tlb_used high water mark in debugfs

From: Dexuan Cui
Date: Wed Mar 22 2023 - 17:54:14 EST


> From: Michael Kelley (LINUX) <mikelley@xxxxxxxxxxxxx>
> Sent: Wednesday, March 22, 2023 7:39 AM
> > > ...
> > > + new_used = atomic_long_add_return(nslots, &total_used);
> > > + old_hiwater = atomic_long_read(&used_hiwater);
> > > + do {
> > > + if (new_used <= old_hiwater)
> > > + break;
> > > + } while (!atomic_long_try_cmpxchg(&used_hiwater, &old_hiwater,
> new_used));
> >
> > Here 'old_hiwater' is not updated in the loop, which looks suspicious to me.
>
> Actually, it *is* updated in the loop. The atomic_long_try_cmpxchg()
> function updates old_hiwater to the current value if the exchange
> fails.

Yes, you're correct. Thanks for the explanation!