Re: [PATCH net-next 5/5] virtio_net: Implement DMA pre-handler

2023-05-26 Thread Jason Wang
On Fri, May 26, 2023 at 1:47 PM Liang Chen  wrote:
>
> Adding a DMA pre-handler that utilizes page pool for managing DMA mappings.
> When IOMMU is enabled, turning on the page_pool_dma_map module parameter to
> select page pool for DMA mapping management gives a significant reduction
> in the overhead caused by DMA mappings.
>
> In testing environments with a single core vm and qemu emulated IOMMU,
> significant performance improvements can be observed:
>   Upstream codebase: 1.76 Gbits/sec
>   Upstream codebase with page pool fragmentation support: 1.81 Gbits/sec
>   Upstream codebase with page pool fragmentation and DMA support: 19.3
>   Gbits/sec
>
> Signed-off-by: Liang Chen 
> ---
>  drivers/net/virtio_net.c | 55 
>  1 file changed, 55 insertions(+)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index ac40b8c66c59..73cc4f9fe4fa 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -22,6 +22,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  static int napi_weight = NAPI_POLL_WEIGHT;
>  module_param(napi_weight, int, 0444);
> @@ -33,8 +34,10 @@ module_param(napi_tx, bool, 0644);
>
>  static bool page_pool_enabled;
>  static bool page_pool_frag;
> +static bool page_pool_dma_map;
>  module_param(page_pool_enabled, bool, 0400);
>  module_param(page_pool_frag, bool, 0400);
> +module_param(page_pool_dma_map, bool, 0400);
>
>  /* FIXME: MTU in config. */
>  #define GOOD_PACKET_LEN (ETH_HLEN + VLAN_HLEN + ETH_DATA_LEN)
> @@ -3830,6 +3833,49 @@ static void virtnet_del_vqs(struct virtnet_info *vi)
> virtnet_free_queues(vi);
>  }
>
> +static dma_addr_t virtnet_pp_dma_map_page(struct device *dev, struct page 
> *page,
> + unsigned long offset, size_t size,
> + enum dma_data_direction dir, 
> unsigned long attrs)
> +{
> +   struct page *head_page;
> +
> +   if (dir != DMA_FROM_DEVICE)
> +   return 0;
> +
> +   head_page = compound_head(page);
> +   return page_pool_get_dma_addr(head_page)
> +   + (page - head_page) * PAGE_SIZE
> +   + offset;

So it's not a map, it is just a query from the dma address from the pool.

> +}
> +
> +static bool virtnet_pp_dma_unmap_page(struct device *dev, dma_addr_t 
> dma_handle,
> + size_t size, enum dma_data_direction 
> dir,
> + unsigned long attrs)
> +{
> +   phys_addr_t phys;
> +
> +   /* Handle only the RX direction, and sync the DMA memory only if it's 
> not
> +* a DMA coherent architecture.
> +*/
> +   if (dir != DMA_FROM_DEVICE)
> +   return false;
> +
> +   if (dev_is_dma_coherent(dev))
> +   return true;
> +
> +   phys = iommu_iova_to_phys(iommu_get_dma_domain(dev), dma_handle);

This would be somehow slow. If we track the mapping by driver, it
would be much faster.

More could be seen here:

https://lists.linuxfoundation.org/pipermail/virtualization/2023-May/066778.html

Thanks

> +   if (WARN_ON(!phys))
> +   return false;
> +
> +   arch_sync_dma_for_cpu(phys, size, dir);
> +   return true;
> +}
> +
> +static struct virtqueue_pre_dma_ops virtnet_pp_pre_dma_ops = {
> +   .map_page = virtnet_pp_dma_map_page,
> +   .unmap_page = virtnet_pp_dma_unmap_page,
> +};
> +
>  static void virtnet_alloc_page_pool(struct receive_queue *rq)
>  {
> struct virtio_device *vdev = rq->vq->vdev;
> @@ -3845,6 +3891,15 @@ static void virtnet_alloc_page_pool(struct 
> receive_queue *rq)
> if (page_pool_frag)
> pp_params.flags |= PP_FLAG_PAGE_FRAG;
>
> +   /* Consider using page pool DMA support only when DMA API is used. */
> +   if (virtio_has_feature(vdev, VIRTIO_F_ACCESS_PLATFORM) &&
> +   page_pool_dma_map) {
> +   pp_params.flags |= PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV;
> +   pp_params.dma_dir = DMA_FROM_DEVICE;
> +   pp_params.max_len = PAGE_SIZE << pp_params.order;
> +   virtqueue_register_pre_dma_ops(rq->vq, 
> &virtnet_pp_pre_dma_ops);
> +   }
> +
> rq->page_pool = page_pool_create(&pp_params);
> if (IS_ERR(rq->page_pool)) {
> dev_warn(&vdev->dev, "page pool creation failed: %ld\n",
> --
> 2.31.1
>

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [PATCH] drm: Remove unnecessary (void*) conversions

2023-05-26 Thread Christian König via Virtualization

Am 26.05.23 um 05:32 schrieb Su Hui:

Pointer variables of (void*) type do not require type cast.


Please split that up by subsystem/driver. Taking it through the misc 
tree might just cause merge conflicts.


Christian.



Signed-off-by: Su Hui 
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 2 +-
  drivers/gpu/drm/amd/pm/amdgpu_pm.c| 2 +-
  drivers/gpu/drm/etnaviv/etnaviv_drv.c | 4 ++--
  drivers/gpu/drm/nouveau/nouveau_debugfs.c | 2 +-
  drivers/gpu/drm/omapdrm/omap_debugfs.c| 6 +++---
  drivers/gpu/drm/pl111/pl111_debugfs.c | 2 +-
  drivers/gpu/drm/qxl/qxl_debugfs.c | 4 ++--
  drivers/gpu/drm/tiny/arcpgu.c | 2 +-
  drivers/gpu/drm/ttm/ttm_resource.c| 3 +--
  drivers/gpu/drm/virtio/virtgpu_debugfs.c  | 6 +++---
  drivers/gpu/drm/vmwgfx/ttm_object.c   | 5 ++---
  drivers/gpu/drm/vmwgfx/vmwgfx_gem.c   | 2 +-
  12 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index 827fcb4fb3b3..8a2c39927167 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -3312,7 +3312,7 @@ static ssize_t dtn_log_write(
  
  static int mst_topo_show(struct seq_file *m, void *unused)

  {
-   struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
+   struct amdgpu_device *adev = m->private;
struct drm_device *dev = adev_to_drm(adev);
struct drm_connector *connector;
struct drm_connector_list_iter conn_iter;
diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c 
b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index 58c2246918fd..e6c870bd307b 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -3671,7 +3671,7 @@ static void amdgpu_parse_cg_state(struct seq_file *m, u64 
flags)
  
  static int amdgpu_debugfs_pm_info_show(struct seq_file *m, void *unused)

  {
-   struct amdgpu_device *adev = (struct amdgpu_device *)m->private;
+   struct amdgpu_device *adev = m->private;
struct drm_device *dev = adev_to_drm(adev);
u64 flags = 0;
int r;
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c 
b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 31a7f59ccb49..dd57f7164e9a 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -198,7 +198,7 @@ static int etnaviv_ring_show(struct etnaviv_gpu *gpu, 
struct seq_file *m)
  
  static int show_unlocked(struct seq_file *m, void *arg)

  {
-   struct drm_info_node *node = (struct drm_info_node *) m->private;
+   struct drm_info_node *node = m->private;
struct drm_device *dev = node->minor->dev;
int (*show)(struct drm_device *dev, struct seq_file *m) =
node->info_ent->data;
@@ -208,7 +208,7 @@ static int show_unlocked(struct seq_file *m, void *arg)
  
  static int show_each_gpu(struct seq_file *m, void *arg)

  {
-   struct drm_info_node *node = (struct drm_info_node *) m->private;
+   struct drm_info_node *node = m->private;
struct drm_device *dev = node->minor->dev;
struct etnaviv_drm_private *priv = dev->dev_private;
struct etnaviv_gpu *gpu;
diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c 
b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
index 2a36d1ca8fda..96b59d5d68ed 100644
--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
+++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
@@ -37,7 +37,7 @@
  static int
  nouveau_debugfs_vbios_image(struct seq_file *m, void *data)
  {
-   struct drm_info_node *node = (struct drm_info_node *) m->private;
+   struct drm_info_node *node = m->private;
struct nouveau_drm *drm = nouveau_drm(node->minor->dev);
int i;
  
diff --git a/drivers/gpu/drm/omapdrm/omap_debugfs.c b/drivers/gpu/drm/omapdrm/omap_debugfs.c

index a3d470468e5b..a94ce502e152 100644
--- a/drivers/gpu/drm/omapdrm/omap_debugfs.c
+++ b/drivers/gpu/drm/omapdrm/omap_debugfs.c
@@ -19,7 +19,7 @@
  
  static int gem_show(struct seq_file *m, void *arg)

  {
-   struct drm_info_node *node = (struct drm_info_node *) m->private;
+   struct drm_info_node *node = m->private;
struct drm_device *dev = node->minor->dev;
struct omap_drm_private *priv = dev->dev_private;
  
@@ -33,7 +33,7 @@ static int gem_show(struct seq_file *m, void *arg)
  
  static int mm_show(struct seq_file *m, void *arg)

  {
-   struct drm_info_node *node = (struct drm_info_node *) m->private;
+   struct drm_info_node *node = m->private;
struct drm_device *dev = node->minor->dev;
struct drm_printer p = drm_seq_file_printer(m);
  
@@ -45,7 +45,7 @@ static int mm_show(struct seq_file *m, void *arg)

  #ifdef 

[RFC] virtio-net: support modern-transtional devices

2023-05-26 Thread Zhu Lingshan
Current virtio-net only probes a device with VIRITO_ID_NET == 1.

For a modern-transtional virtio-net device which has a transtional
device id 0x1000 and acts as a modern device, current virtio-pci
modern driver will assign the sub-device-id to its mdev->id.device,
which may not be 0x1, this sub-device-id is up to the vendor.

That means virtio-net driver doesn't probe a modern-transitonal
virtio-net with a sub-device-id other than 0x1, which is a bug.

Other types of devices also have similar issues, like virito-blk.

I propose to fix this problem of modern-transitonal device
whith this solution, all in the modern code path:
1) assign the device id to mdev->id.device
2) add transitional device ids in the virtio-net(and others) probe table.

Comments are welcome!

Thanks!

Signed-off-by: Zhu Lingshan 
---
 drivers/net/virtio_net.c   | 1 +
 drivers/virtio/virtio_pci_modern_dev.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 56ca1d270304..6b45d8602a6b 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -4250,6 +4250,7 @@ static __maybe_unused int virtnet_restore(struct 
virtio_device *vdev)
 
 static struct virtio_device_id id_table[] = {
{ VIRTIO_ID_NET, VIRTIO_DEV_ANY_ID },
+   { VIRTIO_TRANS_ID_NET, VIRTIO_DEV_ANY_ID },
{ 0 },
 };
 
diff --git a/drivers/virtio/virtio_pci_modern_dev.c 
b/drivers/virtio/virtio_pci_modern_dev.c
index 869cb46bef96..80846e1195ce 100644
--- a/drivers/virtio/virtio_pci_modern_dev.c
+++ b/drivers/virtio/virtio_pci_modern_dev.c
@@ -229,7 +229,7 @@ int vp_modern_probe(struct virtio_pci_modern_device *mdev)
/* Transitional devices: use the PCI subsystem device id as
 * virtio device id, same as legacy driver always did.
 */
-   mdev->id.device = pci_dev->subsystem_device;
+   mdev->id.device = pci_dev->device;
} else {
/* Modern devices: simply use PCI device id, but start from 
0x1040. */
mdev->id.device = pci_dev->device - 0x1040;
-- 
2.39.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [RFC PATCH v3 00/17] vsock: MSG_ZEROCOPY flag support

2023-05-26 Thread Stefano Garzarella

On Thu, May 25, 2023 at 06:56:42PM +0300, Arseniy Krasnov wrote:



On 22.05.2023 10:39, Arseniy Krasnov wrote:

This patchset is unstable with SOCK_SEQPACKET. I'll fix it.


Thanks for let us know!

I'm thinking if we should start split this series in two, because it
becomes too big.

But let keep this for RFC, we can decide later. An idea is to send
the first 7 patches with a preparation series, and the next ones with a
second series.

Thanks,
Stefano

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [RFC PATCH v3 00/17] vsock: MSG_ZEROCOPY flag support

2023-05-26 Thread Stefano Garzarella

On Fri, May 26, 2023 at 02:36:17PM +0300, Arseniy Krasnov wrote:



On 26.05.2023 13:30, Stefano Garzarella wrote:

On Thu, May 25, 2023 at 06:56:42PM +0300, Arseniy Krasnov wrote:



On 22.05.2023 10:39, Arseniy Krasnov wrote:

This patchset is unstable with SOCK_SEQPACKET. I'll fix it.


Thanks for let us know!

I'm thinking if we should start split this series in two, because it
becomes too big.

But let keep this for RFC, we can decide later. An idea is to send
the first 7 patches with a preparation series, and the next ones with a
second series.


Hello, ok! So i'll split patchset in the following way:
1) Patches which adds new fields/flags and checks. But all of this is not used,
  as it is preparation.
2) Second part starts to use it and also carries tests.


As long as they're RFCs, maybe you can keep them together if they're
related, possibly specifying in the cover letter where you'd like to
split them. When we agree that we are in good shape, we can split it.

Thanks,
Stefano

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH net-next 2/5] virtio_net: Add page_pool support to improve performance

2023-05-26 Thread kernel test robot
Hi Liang,

kernel test robot noticed the following build errors:

[auto build test ERROR on net-next/main]

url:
https://github.com/intel-lab-lkp/linux/commits/Liang-Chen/virtio_net-Add-page_pool-support-to-improve-performance/20230526-135805
base:   net-next/main
patch link:
https://lore.kernel.org/r/20230526054621.18371-2-liangchen.linux%40gmail.com
patch subject: [PATCH net-next 2/5] virtio_net: Add page_pool support to 
improve performance
config: x86_64-defconfig 
(https://download.01.org/0day-ci/archive/20230526/202305262334.gifq3wpg-...@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build):
# 
https://github.com/intel-lab-lkp/linux/commit/bfba563f43bba37181d8502cb2e566c32f96ec9e
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Liang-Chen/virtio_net-Add-page_pool-support-to-improve-performance/20230526-135805
git checkout bfba563f43bba37181d8502cb2e566c32f96ec9e
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 olddefconfig
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202305262334.gifq3wpg-...@intel.com/

All errors (new ones prefixed by >>):

   ld: vmlinux.o: in function `virtnet_find_vqs':
>> virtio_net.c:(.text+0x901fb5): undefined reference to `page_pool_create'
   ld: vmlinux.o: in function `add_recvbuf_mergeable.isra.0':
>> virtio_net.c:(.text+0x905618): undefined reference to `page_pool_alloc_pages'
   ld: vmlinux.o: in function `xdp_linearize_page':
   virtio_net.c:(.text+0x906b6b): undefined reference to `page_pool_alloc_pages'
   ld: vmlinux.o: in function `mergeable_xdp_get_buf.isra.0':
   virtio_net.c:(.text+0x90728f): undefined reference to `page_pool_alloc_pages'

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH net-next 5/5] virtio_net: Implement DMA pre-handler

2023-05-26 Thread kernel test robot
Hi Liang,

kernel test robot noticed the following build errors:

[auto build test ERROR on net-next/main]

url:
https://github.com/intel-lab-lkp/linux/commits/Liang-Chen/virtio_net-Add-page_pool-support-to-improve-performance/20230526-135805
base:   net-next/main
patch link:
https://lore.kernel.org/r/20230526054621.18371-5-liangchen.linux%40gmail.com
patch subject: [PATCH net-next 5/5] virtio_net: Implement DMA pre-handler
config: m68k-allmodconfig 
(https://download.01.org/0day-ci/archive/20230527/202305270110.tbnsdh0z-...@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
mkdir -p ~/bin
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# 
https://github.com/intel-lab-lkp/linux/commit/e968bb5cacd30b672d0ccf705a24f1a792ff45aa
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Liang-Chen/virtio_net-Add-page_pool-support-to-improve-performance/20230526-135805
git checkout e968bb5cacd30b672d0ccf705a24f1a792ff45aa
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 ~/bin/make.cross 
W=1 O=build_dir ARCH=m68k olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 ~/bin/make.cross 
W=1 O=build_dir ARCH=m68k SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202305270110.tbnsdh0z-...@intel.com/

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "iommu_get_dma_domain" [drivers/net/virtio_net.ko] undefined!

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [PATCH net-next 3/5] virtio_net: Add page pool fragmentation support

2023-05-26 Thread kernel test robot
Hi Liang,

kernel test robot noticed the following build errors:

[auto build test ERROR on net-next/main]

url:
https://github.com/intel-lab-lkp/linux/commits/Liang-Chen/virtio_net-Add-page_pool-support-to-improve-performance/20230526-135805
base:   net-next/main
patch link:
https://lore.kernel.org/r/20230526054621.18371-3-liangchen.linux%40gmail.com
patch subject: [PATCH net-next 3/5] virtio_net: Add page pool fragmentation 
support
config: x86_64-defconfig 
(https://download.01.org/0day-ci/archive/20230527/202305270116.tj31ijnl-...@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build):
# 
https://github.com/intel-lab-lkp/linux/commit/dda0469e059354b61192e1d25b77c57351346282
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Liang-Chen/virtio_net-Add-page_pool-support-to-improve-performance/20230526-135805
git checkout dda0469e059354b61192e1d25b77c57351346282
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 olddefconfig
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202305270116.tj31ijnl-...@intel.com/

All errors (new ones prefixed by >>):

   ld: vmlinux.o: in function `virtnet_find_vqs':
   virtio_net.c:(.text+0x901fd2): undefined reference to `page_pool_create'
   ld: vmlinux.o: in function `add_recvbuf_mergeable.isra.0':
   virtio_net.c:(.text+0x905662): undefined reference to `page_pool_alloc_pages'
>> ld: virtio_net.c:(.text+0x905715): undefined reference to 
>> `page_pool_alloc_frag'
   ld: vmlinux.o: in function `xdp_linearize_page':
   virtio_net.c:(.text+0x906c50): undefined reference to `page_pool_alloc_pages'
   ld: virtio_net.c:(.text+0x906e33): undefined reference to 
`page_pool_alloc_frag'
   ld: vmlinux.o: in function `mergeable_xdp_get_buf.isra.0':
>> virtio_net.c:(.text+0x90740e): undefined reference to `page_pool_alloc_frag'
>> ld: virtio_net.c:(.text+0x90750b): undefined reference to 
>> `page_pool_alloc_pages'

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization