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] [day] [month] [year] [list]
Message-ID: <fdfca0e9-dd2c-13a2-39ed-b360f7bcb881@redhat.com>
Date:   Mon, 31 May 2021 14:34:16 +0800
From:   Jason Wang <jasowang@...hat.com>
To:     Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
        virtualization@...ts.linux-foundation.org
Cc:     "Michael S. Tsirkin" <mst@...hat.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org
Subject: Re: [PATCH] virtio: Introduce a new kick interface
 virtqueue_kick_try()


在 2021/5/19 下午7:47, Xuan Zhuo 写道:
> Unlike virtqueue_kick(), virtqueue_kick_try() returns true only when the
> kick is successful. In virtio-net, we want to count the number of kicks.
> So we need an interface that can perceive whether the kick is actually
> executed.
>
> Signed-off-by: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>


Acked-by: Jason Wang <jasowang@...hat.com>

Thanks


> ---
>   drivers/net/virtio_net.c     |  8 ++++----
>   drivers/virtio/virtio_ring.c | 20 ++++++++++++++++++++
>   include/linux/virtio.h       |  2 ++
>   3 files changed, 26 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 9b6a4a875c55..167697030cb6 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -617,7 +617,7 @@ static int virtnet_xdp_xmit(struct net_device *dev,
>   	ret = nxmit;
>   
>   	if (flags & XDP_XMIT_FLUSH) {
> -		if (virtqueue_kick_prepare(sq->vq) && virtqueue_notify(sq->vq))
> +		if (virtqueue_kick_try(sq->vq))
>   			kicks = 1;
>   	}
>   out:
> @@ -1325,7 +1325,7 @@ static bool try_fill_recv(struct virtnet_info *vi, struct receive_queue *rq,
>   		if (err)
>   			break;
>   	} while (rq->vq->num_free);
> -	if (virtqueue_kick_prepare(rq->vq) && virtqueue_notify(rq->vq)) {
> +	if (virtqueue_kick_try(rq->vq)) {
>   		unsigned long flags;
>   
>   		flags = u64_stats_update_begin_irqsave(&rq->stats.syncp);
> @@ -1533,7 +1533,7 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
>   
>   	if (xdp_xmit & VIRTIO_XDP_TX) {
>   		sq = virtnet_xdp_get_sq(vi);
> -		if (virtqueue_kick_prepare(sq->vq) && virtqueue_notify(sq->vq)) {
> +		if (virtqueue_kick_try(sq->vq)) {
>   			u64_stats_update_begin(&sq->stats.syncp);
>   			sq->stats.kicks++;
>   			u64_stats_update_end(&sq->stats.syncp);
> @@ -1710,7 +1710,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)
>   	}
>   
>   	if (kick || netif_xmit_stopped(txq)) {
> -		if (virtqueue_kick_prepare(sq->vq) && virtqueue_notify(sq->vq)) {
> +		if (virtqueue_kick_try(sq->vq)) {
>   			u64_stats_update_begin(&sq->stats.syncp);
>   			sq->stats.kicks++;
>   			u64_stats_update_end(&sq->stats.syncp);
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index 71e16b53e9c1..1462be756875 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -1874,6 +1874,26 @@ bool virtqueue_kick(struct virtqueue *vq)
>   }
>   EXPORT_SYMBOL_GPL(virtqueue_kick);
>   
> +/**
> + * virtqueue_kick_try - try update after add_buf
> + * @vq: the struct virtqueue
> + *
> + * After one or more virtqueue_add_* calls, invoke this to kick
> + * the other side.
> + *
> + * Caller must ensure we don't call this with other virtqueue
> + * operations at the same time (except where noted).
> + *
> + * Returns true if kick success, otherwise false.
> + */
> +bool virtqueue_kick_try(struct virtqueue *vq)
> +{
> +	if (virtqueue_kick_prepare(vq) && virtqueue_notify(vq))
> +		return true;
> +	return false;
> +}
> +EXPORT_SYMBOL_GPL(virtqueue_kick_try);
> +
>   /**
>    * virtqueue_get_buf - get the next used buffer
>    * @_vq: the struct virtqueue we're talking about.
> diff --git a/include/linux/virtio.h b/include/linux/virtio.h
> index b1894e0323fa..45cd6a0af24d 100644
> --- a/include/linux/virtio.h
> +++ b/include/linux/virtio.h
> @@ -59,6 +59,8 @@ int virtqueue_add_sgs(struct virtqueue *vq,
>   
>   bool virtqueue_kick(struct virtqueue *vq);
>   
> +bool virtqueue_kick_try(struct virtqueue *vq);
> +
>   bool virtqueue_kick_prepare(struct virtqueue *vq);
>   
>   bool virtqueue_notify(struct virtqueue *vq);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ