Re: [PATCH vhost v5 00/10] virtio: drivers maintain dma info for premapped vq

2024-03-25 Thread Jason Wang
On Mon, Mar 25, 2024 at 4:54 PM Xuan Zhuo wrote: > > As discussed: > > http://lore.kernel.org/all/cacgkmevq0no8qgc46u4mgsmtud44fd_cflcpavmj3rhyqrz...@mail.gmail.com > > If the virtio is premapped mode, the driver should manage the dma info by > self. > So the virtio core should not store the dma

[PATCH net v2] virtio-net: fix possible dim status unrecoverable

2024-03-25 Thread Heng Qi
When the dim worker is scheduled, if it fails to acquire the lock, dim may not be able to return to the working state later. For example, the following single queue scenario: 1. The dim worker of rxq0 is scheduled, and the dim status is changed to DIM_APPLY_NEW_PROFILE; 2. The ethtool com

Re: [PATCH net-next 0/4] Remove RTNL lock protection of CVQ

2024-03-25 Thread Heng Qi
在 2024/3/26 下午12:11, Dan Jurgens 写道: From: Heng Qi Sent: Monday, March 25, 2024 9:54 PM To: Dan Jurgens ; netdev@vger.kernel.org Cc: m...@redhat.com; jasow...@redhat.com; xuanz...@linux.alibaba.com; virtualizat...@lists.linux.dev; da...@davemloft.net; eduma...@google.com; k...@kernel.org; pab

Re: [PATCH 2/2] virtio-net: reduce the CPU consumption of dim worker

2024-03-25 Thread Jason Wang
On Tue, Mar 26, 2024 at 1:57 PM Heng Qi wrote: > > > > 在 2024/3/26 下午12:08, Jason Wang 写道: > > On Tue, Mar 26, 2024 at 10:46 AM Heng Qi wrote: > >> > >> > >> 在 2024/3/25 下午4:42, Jason Wang 写道: > >>> On Mon, Mar 25, 2024 at 4:22 PM Heng Qi wrote: > > 在 2024/3/25 下午3:56, Jason Wang 写道: >

Re: [PATCH 2/2] virtio-net: reduce the CPU consumption of dim worker

2024-03-25 Thread Heng Qi
在 2024/3/26 下午12:08, Jason Wang 写道: On Tue, Mar 26, 2024 at 10:46 AM Heng Qi wrote: 在 2024/3/25 下午4:42, Jason Wang 写道: On Mon, Mar 25, 2024 at 4:22 PM Heng Qi wrote: 在 2024/3/25 下午3:56, Jason Wang 写道: On Mon, Mar 25, 2024 at 3:18 PM Heng Qi wrote: 在 2024/3/25 下午1:57, Jason Wang 写道:

Re: REGRESSION: RIP: 0010:skb_release_data+0xb8/0x1e0 in vhost/tun

2024-03-25 Thread Jason Wang
On Mon, Mar 25, 2024 at 4:44 PM Igor Raits wrote: > > Hello, > > On Fri, Mar 22, 2024 at 12:19 PM Igor Raits wrote: > > > > Hi Jason, > > > > On Fri, Mar 22, 2024 at 9:39 AM Igor Raits wrote: > > > > > > Hi Jason, > > > > > > On Fri, Mar 22, 2024 at 6:31 AM Jason Wang wrote: > > > > > > > > On

RE: [PATCH net-next 0/4] Remove RTNL lock protection of CVQ

2024-03-25 Thread Dan Jurgens
> From: Heng Qi > Sent: Monday, March 25, 2024 9:54 PM > To: Dan Jurgens ; netdev@vger.kernel.org > Cc: m...@redhat.com; jasow...@redhat.com; xuanz...@linux.alibaba.com; > virtualizat...@lists.linux.dev; da...@davemloft.net; > eduma...@google.com; k...@kernel.org; pab...@redhat.com; Jiri Pirko >

Re: [PATCH 2/2] virtio-net: reduce the CPU consumption of dim worker

2024-03-25 Thread Jason Wang
On Tue, Mar 26, 2024 at 10:46 AM Heng Qi wrote: > > > > 在 2024/3/25 下午4:42, Jason Wang 写道: > > On Mon, Mar 25, 2024 at 4:22 PM Heng Qi wrote: > >> > >> > >> 在 2024/3/25 下午3:56, Jason Wang 写道: > >>> On Mon, Mar 25, 2024 at 3:18 PM Heng Qi wrote: > > 在 2024/3/25 下午1:57, Jason Wang 写道: >

Re: [PATCH net-next 0/4] Remove RTNL lock protection of CVQ

2024-03-25 Thread Heng Qi
在 2024/3/26 上午5:49, Daniel Jurgens 写道: Currently the buffer used for control VQ commands is protected by the RTNL lock. Previously this wasn't a major concern because the control VQ was only used during device setup and user interaction. With the recent addition of dynamic interrupt moderation

Re: [PATCH 2/2] virtio-net: reduce the CPU consumption of dim worker

2024-03-25 Thread Heng Qi
在 2024/3/25 下午4:42, Jason Wang 写道: On Mon, Mar 25, 2024 at 4:22 PM Heng Qi wrote: 在 2024/3/25 下午3:56, Jason Wang 写道: On Mon, Mar 25, 2024 at 3:18 PM Heng Qi wrote: 在 2024/3/25 下午1:57, Jason Wang 写道: On Mon, Mar 25, 2024 at 10:21 AM Heng Qi wrote: 在 2024/3/22 下午1:19, Jason Wang 写道:

Re: [PATCH net-next 0/4] Remove RTNL lock protection of CVQ

2024-03-25 Thread Xuan Zhuo
For series: Reviewed-by: Xuan Zhuo On Mon, 25 Mar 2024 16:49:07 -0500, Daniel Jurgens wrote: > Currently the buffer used for control VQ commands is protected by the > RTNL lock. Previously this wasn't a major concern because the control > VQ was only used during device setup and user interactio

[PATCH net-next 4/4] virtio_net: Remove rtnl lock protection of command buffers

2024-03-25 Thread Daniel Jurgens
The rtnl lock is no longer needed to protect the control buffer and command VQ. Signed-off-by: Daniel Jurgens Reviewed-by: Jiri Pirko --- drivers/net/virtio_net.c | 27 +-- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/

[PATCH net-next 3/4] virtio_net: Add a lock for the command VQ.

2024-03-25 Thread Daniel Jurgens
The command VQ will no longer be protected by the RTNL lock. Use a spinlock to protect the control buffer header and the VQ. Signed-off-by: Daniel Jurgens Reviewed-by: Jiri Pirko --- drivers/net/virtio_net.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/vi

[PATCH net-next 2/4] virtio_net: Remove command data from control_buf

2024-03-25 Thread Daniel Jurgens
Allocate memory for the data when it's used. Ideally the could be on the stack, but we can't DMA stack memory. With this change only the header and status memory are shared between commands, which will allow using a tighter lock than RTNL. Signed-off-by: Daniel Jurgens Reviewed-by: Jiri Pirko --

[PATCH net-next 1/4] virtio_net: Store RSS setting in virtnet_info

2024-03-25 Thread Daniel Jurgens
Stop storing RSS setting in the control buffer. This is prep work for removing RTNL lock protection of the control buffer. Signed-off-by: Daniel Jurgens Reviewed-by: Jiri Pirko --- drivers/net/virtio_net.c | 40 1 file changed, 20 insertions(+), 20 delet

[PATCH net-next 0/4] Remove RTNL lock protection of CVQ

2024-03-25 Thread Daniel Jurgens
Currently the buffer used for control VQ commands is protected by the RTNL lock. Previously this wasn't a major concern because the control VQ was only used during device setup and user interaction. With the recent addition of dynamic interrupt moderation the control VQ may be used frequently durin

[PATCH vhost v5 09/10] virtio_net: set premapped mode by find_vqs()

2024-03-25 Thread Xuan Zhuo
Now, the virtio core can set the premapped mode by find_vqs(). If the premapped can be enabled, the dma array will not be allocated. So virtio-net use the api of find_vqs to enable the premapped. Judge the premapped mode by the vq->premapped instead of saving local variable. Signed-off-by: Xuan Z

Re: [PATCH 1/2] virtio-net: fix possible dim status unrecoverable

2024-03-25 Thread Jason Wang
On Mon, Mar 25, 2024 at 10:11 AM Heng Qi wrote: > > > > 在 2024/3/22 下午1:17, Jason Wang 写道: > > On Thu, Mar 21, 2024 at 7:46 PM Heng Qi wrote: > >> When the dim worker is scheduled, if it fails to acquire the lock, > >> dim may not be able to return to the working state later. > >> > >> For exampl

[PATCH vhost v5 02/10] virtio_ring: packed: remove double check of the unmap ops

2024-03-25 Thread Xuan Zhuo
In the functions vring_unmap_extra_packed and vring_unmap_desc_packed, multiple checks are made whether unmap is performed and whether it is INDIRECT. These two functions are usually called in a loop, and we should put the check outside the loop. And we unmap the descs with VRING_DESC_F_INDIRECT

[PATCH vhost v5 10/10] virtio_ring: virtqueue_set_dma_premapped support disable

2024-03-25 Thread Xuan Zhuo
Now, the API virtqueue_set_dma_premapped just support to enable premapped mode. If we allow enabling the premapped dynamically, we should make this API to support disable the premapped mode. Signed-off-by: Xuan Zhuo --- drivers/virtio/virtio_ring.c | 39 +++- inc

[PATCH vhost v5 06/10] virtio_ring: no store dma info when unmap is not needed

2024-03-25 Thread Xuan Zhuo
As discussed: http://lore.kernel.org/all/CACGkMEug-=C+VQhkMYSgUKMC==04m7-uem_yc21bggkkzh8...@mail.gmail.com When the vq is premapped mode, the driver manages the dma info is a good way. So this commit make the virtio core not to store the dma info and release the memory which is used to store the

Re: [PATCH 2/2] virtio-net: reduce the CPU consumption of dim worker

2024-03-25 Thread Jason Wang
On Mon, Mar 25, 2024 at 10:21 AM Heng Qi wrote: > > > > 在 2024/3/22 下午1:19, Jason Wang 写道: > > On Thu, Mar 21, 2024 at 7:46 PM Heng Qi wrote: > >> Currently, ctrlq processes commands in a synchronous manner, > >> which increases the delay of dim commands when configuring > >> multi-queue VMs, whi

Re: [PATCH 2/2] virtio-net: reduce the CPU consumption of dim worker

2024-03-25 Thread Heng Qi
在 2024/3/25 下午3:56, Jason Wang 写道: On Mon, Mar 25, 2024 at 3:18 PM Heng Qi wrote: 在 2024/3/25 下午1:57, Jason Wang 写道: On Mon, Mar 25, 2024 at 10:21 AM Heng Qi wrote: 在 2024/3/22 下午1:19, Jason Wang 写道: On Thu, Mar 21, 2024 at 7:46 PM Heng Qi wrote: Currently, ctrlq processes commands

Re: [PATCH 2/2] virtio-net: reduce the CPU consumption of dim worker

2024-03-25 Thread Jason Wang
On Mon, Mar 25, 2024 at 4:22 PM Heng Qi wrote: > > > > 在 2024/3/25 下午3:56, Jason Wang 写道: > > On Mon, Mar 25, 2024 at 3:18 PM Heng Qi wrote: > >> > >> > >> 在 2024/3/25 下午1:57, Jason Wang 写道: > >>> On Mon, Mar 25, 2024 at 10:21 AM Heng Qi wrote: > > 在 2024/3/22 下午1:19, Jason Wang 写道: >

Re: [PATCH 2/2] virtio-net: reduce the CPU consumption of dim worker

2024-03-25 Thread Jason Wang
On Mon, Mar 25, 2024 at 3:18 PM Heng Qi wrote: > > > > 在 2024/3/25 下午1:57, Jason Wang 写道: > > On Mon, Mar 25, 2024 at 10:21 AM Heng Qi wrote: > >> > >> > >> 在 2024/3/22 下午1:19, Jason Wang 写道: > >>> On Thu, Mar 21, 2024 at 7:46 PM Heng Qi wrote: > Currently, ctrlq processes commands in a syn

[PATCH vhost v5 08/10] virtio_ring: export premapped to driver by struct virtqueue

2024-03-25 Thread Xuan Zhuo
Export the premapped to drivers, then drivers can check the vq premapped mode after the find_vqs(). Because the find_vqs() just try to enable the vq premapped mode, the driver must check that after find_vqs(). Signed-off-by: Xuan Zhuo --- drivers/virtio/virtio_ring.c | 13 + include/

[PATCH vhost v5 04/10] virtio_ring: split: remove double check of the unmap ops

2024-03-25 Thread Xuan Zhuo
In the functions vring_unmap_one_split and vring_unmap_one_split_indirect, multiple checks are made whether unmap is performed and whether it is INDIRECT. These two functions are usually called in a loop, and we should put the check outside the loop. And we unmap the descs with VRING_DESC_F_INDIR

[PATCH vhost v5 07/10] virtio: find_vqs: add new parameter premapped

2024-03-25 Thread Xuan Zhuo
If the premapped mode is enabled, the dma array(struct vring_desc_dma) of virtio core will not be allocated. That is judged when find_vqs() is called. To avoid allocating dma array in find_vqs() and releasing it immediately by virtqueue_set_dma_premapped(). This patch introduces a new parameter to

[PATCH vhost v5 03/10] virtio_ring: packed: structure the indirect desc table

2024-03-25 Thread Xuan Zhuo
This commit structure the indirect desc table. Then we can get the desc num directly when doing unmap. And save the dma info to the struct, then the indirect will not use the dma fields of the desc_extra. The subsequent commits will make the dma fields are optional. But for the indirect case, we m

[PATCH vhost v5 00/10] virtio: drivers maintain dma info for premapped vq

2024-03-25 Thread Xuan Zhuo
As discussed: http://lore.kernel.org/all/cacgkmevq0no8qgc46u4mgsmtud44fd_cflcpavmj3rhyqrz...@mail.gmail.com If the virtio is premapped mode, the driver should manage the dma info by self. So the virtio core should not store the dma info. We can release the memory used to store the dma info. For

[PATCH vhost v5 01/10] virtio_ring: introduce vring_need_unmap_buffer

2024-03-25 Thread Xuan Zhuo
To make the code readable, introduce vring_need_unmap_buffer() to replace do_unmap. use_dma_api premapped -> vring_need_unmap_buffer() 1. false falsefalse 2. truefalsetrue 3. truetrue false Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- drive

[PATCH vhost v5 05/10] virtio_ring: split: structure the indirect desc table

2024-03-25 Thread Xuan Zhuo
This commit structure the indirect desc table. Then we can get the desc num directly when doing unmap. And save the dma info to the struct, then the indirect will not use the dma fields of the desc_extra. The subsequent commits will make the dma fields are optional. But for the indirect case, we m

Re: REGRESSION: RIP: 0010:skb_release_data+0xb8/0x1e0 in vhost/tun

2024-03-25 Thread Igor Raits
Hello, On Fri, Mar 22, 2024 at 12:19 PM Igor Raits wrote: > > Hi Jason, > > On Fri, Mar 22, 2024 at 9:39 AM Igor Raits wrote: > > > > Hi Jason, > > > > On Fri, Mar 22, 2024 at 6:31 AM Jason Wang wrote: > > > > > > On Thu, Mar 21, 2024 at 5:44 PM Igor Raits wrote: > > > > > > > > Hello Jason &

Re: [PATCH 2/2] virtio-net: reduce the CPU consumption of dim worker

2024-03-25 Thread Heng Qi
在 2024/3/25 下午1:57, Jason Wang 写道: On Mon, Mar 25, 2024 at 10:21 AM Heng Qi wrote: 在 2024/3/22 下午1:19, Jason Wang 写道: On Thu, Mar 21, 2024 at 7:46 PM Heng Qi wrote: Currently, ctrlq processes commands in a synchronous manner, which increases the delay of dim commands when configuring mu

Re: [PATCH vhost v4 03/10] virtio_ring: packed: structure the indirect desc table

2024-03-25 Thread Jason Wang
On Fri, Mar 22, 2024 at 3:58 PM Xuan Zhuo wrote: > > On Fri, 22 Mar 2024 13:15:10 +0800, Jason Wang wrote: > > On Thu, Mar 21, 2024 at 4:29 PM Xuan Zhuo > > wrote: > > > > > > On Thu, 21 Mar 2024 12:47:18 +0800, Jason Wang > > > wrote: > > > > On Tue, Mar 12, 2024 at 11:36 AM Xuan Zhuo > >

Re: [PATCH 1/2] virtio-net: fix possible dim status unrecoverable

2024-03-25 Thread Jason Wang
On Mon, Mar 25, 2024 at 2:58 PM Heng Qi wrote: > > > > 在 2024/3/25 下午2:29, Jason Wang 写道: > > On Mon, Mar 25, 2024 at 10:11 AM Heng Qi wrote: > >> > >> > >> 在 2024/3/22 下午1:17, Jason Wang 写道: > >>> On Thu, Mar 21, 2024 at 7:46 PM Heng Qi wrote: > When the dim worker is scheduled, if it fail

Re: [PATCH 1/2] virtio-net: fix possible dim status unrecoverable

2024-03-25 Thread Heng Qi
在 2024/3/25 下午2:29, Jason Wang 写道: On Mon, Mar 25, 2024 at 10:11 AM Heng Qi wrote: 在 2024/3/22 下午1:17, Jason Wang 写道: On Thu, Mar 21, 2024 at 7:46 PM Heng Qi wrote: When the dim worker is scheduled, if it fails to acquire the lock, dim may not be able to return to the working state late

Re: [PATCH vhost v4 10/10] virtio_ring: virtqueue_set_dma_premapped support disable

2024-03-25 Thread Jason Wang
On Fri, Mar 22, 2024 at 2:04 PM Xuan Zhuo wrote: > > On Fri, 22 Mar 2024 13:13:36 +0800, Jason Wang wrote: > > On Thu, Mar 21, 2024 at 4:22 PM Xuan Zhuo > > wrote: > > > > > > On Thu, 21 Mar 2024 14:02:14 +0800, Jason Wang > > > wrote: > > > > On Tue, Mar 12, 2024 at 11:36 AM Xuan Zhuo > >

Re: [PATCH 0/2] virtio-net: a fix and some updates for virtio dim

2024-03-25 Thread Heng Qi
在 2024/3/21 下午8:25, Jiri Pirko 写道: Thu, Mar 21, 2024 at 12:45:55PM CET, hen...@linux.alibaba.com wrote: Patch 1 fixes an existing bug. Belongs to the net branch. Send separately with "net" indication in the patch brackets: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html?h

Re: [PATCH 1/2] virtio-net: fix possible dim status unrecoverable

2024-03-25 Thread Heng Qi
在 2024/3/22 下午1:17, Jason Wang 写道: On Thu, Mar 21, 2024 at 7:46 PM Heng Qi wrote: When the dim worker is scheduled, if it fails to acquire the lock, dim may not be able to return to the working state later. For example, the following single queue scenario: 1. The dim worker of rxq0 is sc

Re: [PATCH 2/2] virtio-net: reduce the CPU consumption of dim worker

2024-03-25 Thread Heng Qi
在 2024/3/22 下午1:19, Jason Wang 写道: On Thu, Mar 21, 2024 at 7:46 PM Heng Qi wrote: Currently, ctrlq processes commands in a synchronous manner, which increases the delay of dim commands when configuring multi-queue VMs, which in turn causes the CPU utilization to increase and interferes with