Re: [PATCH v2 1/2] tg3: Increment tx_dropped in tg3_tso_bug()

From: Michael Chan
Date: Sun Nov 05 2023 - 22:59:26 EST


On Sun, Nov 5, 2023 at 11:26 AM Alex Pakhunov
<alexey.pakhunov@xxxxxxxxxx> wrote:
>
> > I recommend using per queue counters as briefly mentioned in my
> > earlier reply...
> > tg3_get_stats64() can just loop and sum all the tx_dropped and
> > rx_dropped counters in each tg3_napi struct. We don't worry about
> > locks here since we are just reading.
>
> Got it. So the core idea is to make sure there is a single writer for each
> counter which will make updating the counter race-free. It does not keep
> reading the counters from multiple queues completely race free, but, I
> guess, the assumption is that computing the aggregate counter to be
> slightly wrong is acceptable - it will be recomputed correctly next time.

Correct.

>
> There is still some gotchas on 32 bit machines though. 64 bit reads are not
> atomic there, so we have to make the counters 32bit to compensate:

These counters are currently defined as unsigned long which is 32-bit
on 32-bit CPUs and 64-bit on 64-bit CPUs. We can just keep them
unchanged. Thanks.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature