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: <20240620115133-mutt-send-email-mst@kernel.org>
Date: Thu, 20 Jun 2024 11:52:36 -0400
From: "Michael S. Tsirkin" <mst@...hat.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Li RongQing <lirongqing@...du.com>, jasowang@...hat.com,
	xuanzhuo@...ux.alibaba.com, eperezma@...hat.com,
	hengqi@...ux.alibaba.com, virtualization@...ts.linux.dev,
	netdev@...r.kernel.org
Subject: Re: [PATCH] virtio_net: Use u64_stats_fetch_begin() for stats fetch

On Thu, Jun 20, 2024 at 07:09:08AM -0700, Jakub Kicinski wrote:
> On Wed, 19 Jun 2024 10:55:29 +0800 Li RongQing wrote:
> > This place is fetching the stats, so u64_stats_fetch_begin
> > and u64_stats_fetch_retry should be used
> > 
> > Fixes: 6208799553a8 ("virtio-net: support rx netdim")
> > Signed-off-by: Li RongQing <lirongqing@...du.com>
> > ---
> >  drivers/net/virtio_net.c | 14 ++++++++------
> >  1 file changed, 8 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > index 61a57d1..b669e73 100644
> > --- a/drivers/net/virtio_net.c
> > +++ b/drivers/net/virtio_net.c
> > @@ -2332,16 +2332,18 @@ static void virtnet_poll_cleantx(struct receive_queue *rq)
> >  static void virtnet_rx_dim_update(struct virtnet_info *vi, struct receive_queue *rq)
> >  {
> >  	struct dim_sample cur_sample = {};
> > +	unsigned int start;
> >  
> >  	if (!rq->packets_in_napi)
> >  		return;
> >  
> > -	u64_stats_update_begin(&rq->stats.syncp);
> > -	dim_update_sample(rq->calls,
> > -			  u64_stats_read(&rq->stats.packets),
> > -			  u64_stats_read(&rq->stats.bytes),
> > -			  &cur_sample);
> > -	u64_stats_update_end(&rq->stats.syncp);
> > +	do {
> > +		start = u64_stats_fetch_begin(&rq->stats.syncp);
> > +		dim_update_sample(rq->calls,
> > +				u64_stats_read(&rq->stats.packets),
> > +				u64_stats_read(&rq->stats.bytes),
> > +				&cur_sample);
> > +	} while (u64_stats_fetch_retry(&rq->stats.syncp, start));
> 
> Did you by any chance use an automated tool of any sort to find this
> issue or generate the fix?
> 
> I don't think this is actually necessary here, you're in the same
> context as the updater of the stats, you don't need any protection.
> You can remove u64_stats_update_begin() / end() (in net-next, there's
> no bug).
> 
> I won't comment on implications of calling dim_update_sample() in 
> a loop.

I didn't realize there are any - it seems to be idempotent, no?


> Please make sure you answer my "did you use a tool" question, I'm
> really curious.
> -- 
> pw-bot: cr


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ