lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACKFLi=VL8kHH-Q4UQF60tGaK2dk7NgH_9-yJpP7hgn_NE9e7Q@mail.gmail.com>
Date:   Wed, 8 Nov 2023 01:11:33 -0800
From:   Michael Chan <michael.chan@...adcom.com>
To:     alexey.pakhunov@...cex.com
Cc:     mchan@...adcom.com, vincent.wong2@...cex.com,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        siva.kallam@...adcom.com, prashant@...adcom.com
Subject: Re: [PATCH 1/2] tg3: Move the [rt]x_dropped counters to tg3_napi

On Tue, Nov 7, 2023 at 5:01 PM <alexey.pakhunov@...cex.com> wrote:
>
> From: Alex Pakhunov <alexey.pakhunov@...cex.com>
>
> This change moves [rt]x_dropped counters to tg3_napi so that they can be
> updated by a single writer, race-free.
>
> Signed-off-by: Alex Pakhunov <alexey.pakhunov@...cex.com>
> Signed-off-by: Vincent Wong <vincent.wong2@...cex.com>
> ---
...
> @@ -11895,6 +11898,9 @@ static void tg3_get_nstats(struct tg3 *tp, struct rtnl_link_stats64 *stats)
>  {
>         struct rtnl_link_stats64 *old_stats = &tp->net_stats_prev;
>         struct tg3_hw_stats *hw_stats = tp->hw_stats;
> +       unsigned long rx_dropped = 0;
> +       unsigned long tx_dropped = 0;
> +       int i;
>
>         stats->rx_packets = old_stats->rx_packets +
>                 get_stat64(&hw_stats->rx_ucast_packets) +
> @@ -11941,8 +11947,23 @@ static void tg3_get_nstats(struct tg3 *tp, struct rtnl_link_stats64 *stats)
>         stats->rx_missed_errors = old_stats->rx_missed_errors +
>                 get_stat64(&hw_stats->rx_discards);
>
> -       stats->rx_dropped = tp->rx_dropped;
> -       stats->tx_dropped = tp->tx_dropped;
> +       /* Aggregate per-queue counters. The per-queue counters are updated
> +        * by a single writer, race-free. The result computed by this loop
> +        * might not be 100% accurate (counters can be updated in the middle of
> +        * the loop) but the next tg3_get_nstats() will recompute the current
> +        * value so it is acceptable.
> +        */
> +       for (i = 0; i < tp->irq_cnt; i++) {
> +               struct tg3_napi *tnapi = &tp->napi[i];
> +
> +               rx_dropped += tnapi->rx_dropped;
> +               tx_dropped += tnapi->tx_dropped;
> +       }
> +
> +       /* The counters wrap around at 4G on 32bit machines. */
> +       stats->rx_dropped = rx_dropped;
> +       stats->tx_dropped = tx_dropped;

I think here we need to keep these counters accumulate across a reset:

stats->rx_dropped = old_stats->rx_dropped + rx_dropped;
stats->tx_dropped = old_stats->tx_dropped + tx_dropped;

> +
>  }
>

Download attachment "smime.p7s" of type "application/pkcs7-signature" (4209 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ