Skip to contentSkip to conversation

vhost: drop vring dependency on iotlb

PATCH In review Michael S. Tsirkin 3 participants 5 messages Apr 2, 2020 – Apr 13, 2020

Subsystems (5)
lore
Share & tools
lore

Michael S. Tsirkin

author maintainer
#0 lore raw

PATCH v2 1/1 vhost: drop vring dependency on iotlb

vringh can now be built without IOTLB.
Select IOTLB directly where it's used.

---

Applies on top of my vhost tree.
Changes from v1:
VDPA_SIM needs VHOST_IOTLB

 drivers/vdpa/Kconfig  | 1 +
 drivers/vhost/Kconfig | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
drivers/vdpa/Kconfig +1 -0
index 7db1460104b7..08b615f2da39 100644
@@ -17,6 +17,7 @@ config VDPA_SIM
 	depends on RUNTIME_TESTING_MENU
 	select VDPA
 	select VHOST_RING
+	select VHOST_IOTLB
 	default n
 	help
 	  vDPA networking device simulator which loop TX traffic back
drivers/vhost/Kconfig +0 -1
index f0404ce255d1..cb6b17323eb2 100644
@@ -8,7 +8,6 @@ config VHOST_IOTLB
 
 config VHOST_RING
 	tristate
-	select VHOST_IOTLB
 	help
 	  This option is selected by any driver which needs to access
 	  the host side of a virtio ring.
Signature · 1 line
MST
#1 lore raw
Quoted 9 lines · Michael S. Tsirkin

vringh can now be built without IOTLB.
Select IOTLB directly where it's used.

---

Applies on top of my vhost tree.
Changes from v1:
VDPA_SIM needs VHOST_IOTLB

It looks to me the patch is identical to v1.

Thanks

Quoted 29 lines
  drivers/vdpa/Kconfig  | 1 +
  drivers/vhost/Kconfig | 1 -
  2 files changed, 1 insertion(+), 1 deletion(-)
drivers/vdpa/Kconfig +1 -0
index 7db1460104b7..08b615f2da39 100644
@@ -17,6 +17,7 @@ config VDPA_SIM
  	depends on RUNTIME_TESTING_MENU
  	select VDPA
  	select VHOST_RING
+	select VHOST_IOTLB
  	default n
  	help
  	  vDPA networking device simulator which loop TX traffic back
drivers/vhost/Kconfig +0 -1
index f0404ce255d1..cb6b17323eb2 100644
@@ -8,7 +8,6 @@ config VHOST_IOTLB
 
  config VHOST_RING
  	tristate
-	select VHOST_IOTLB
  	help
  	  This option is selected by any driver which needs to access
  	  the host side of a virtio ring.
author maintainer
#2 lore raw
Quoted 8 lines · Jason Wang
Quoted 6 lines · Michael S. Tsirkin

vringh can now be built without IOTLB.
Select IOTLB directly where it's used.

---

Quoted 8 lines
Quoted 3 lines

Applies on top of my vhost tree.
Changes from v1:
VDPA_SIM needs VHOST_IOTLB

It looks to me the patch is identical to v1.

Thanks

you are right. I squashed the description into
virtio/test: fix up after IOTLB changes
take a look at it in the vhost tree.

Quoted 29 lines
Quoted 29 lines

  drivers/vdpa/Kconfig  | 1 +
  drivers/vhost/Kconfig | 1 -
  2 files changed, 1 insertion(+), 1 deletion(-)
drivers/vdpa/Kconfig +1 -0
index 7db1460104b7..08b615f2da39 100644
@@ -17,6 +17,7 @@ config VDPA_SIM
  	depends on RUNTIME_TESTING_MENU
  	select VDPA
  	select VHOST_RING
+	select VHOST_IOTLB
  	default n
  	help
  	  vDPA networking device simulator which loop TX traffic back
drivers/vhost/Kconfig +0 -1
index f0404ce255d1..cb6b17323eb2 100644
@@ -8,7 +8,6 @@ config VHOST_IOTLB
  config VHOST_RING
  	tristate
-	select VHOST_IOTLB
  	help
  	  This option is selected by any driver which needs to access
  	  the host side of a virtio ring.
#3 lore raw
Quoted 11 lines · Michael S. Tsirkin
Quoted 10 lines · Jason Wang
Quoted 9 lines · Michael S. Tsirkin

vringh can now be built without IOTLB.
Select IOTLB directly where it's used.

---

Applies on top of my vhost tree.
Changes from v1:
VDPA_SIM needs VHOST_IOTLB

Quoted 6 lines
Quoted 3 lines

It looks to me the patch is identical to v1.

Thanks

you are right. I squashed the description into
virtio/test: fix up after IOTLB changes
take a look at it in the vhost tree.

Looks fine.

Thanks

Quoted 1 line
#4 lore raw
In reply to Michael S. Tsirkin
I love your patch! Yet something to improve:

Hi "Michael,

I love your patch! Yet something to improve:

[auto build test ERROR on vhost/linux-next]
[also build test ERROR on linus/master v5.7-rc1]
[cannot apply to linux/master next-20200413]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Michael-S-Tsirkin/vhost-drop-vring-dependency-on-iotlb/20200403-234646
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
config: sparc-randconfig-a001-20200413 (attached as .config)
compiler: sparc-linux-gcc (GCC) 9.3.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.3.0 make.cross ARCH=sparc

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

arch/sparc/kernel/head_32.o: in function `current_pc':
arch/sparc/kernel/head_32.S:121:(.head.text+0x2040): relocation truncated to fit: R_SPARC_WDISP22 against .init.text' arch/sparc/kernel/head_32.o: in function halt_notsup':
arch/sparc/kernel/head_32.S:198:(.head.text+0x2100): relocation truncated to fit: R_SPARC_WDISP22 against .init.text' arch/sparc/kernel/process_32.o:(.fixup+0x4): relocation truncated to fit: R_SPARC_WDISP22 against .text' arch/sparc/kernel/process_32.o:(.fixup+0xc): relocation truncated to fit: R_SPARC_WDISP22 against .text' arch/sparc/kernel/signal_32.o:(.fixup+0x0): relocation truncated to fit: R_SPARC_WDISP22 against .text' arch/sparc/kernel/signal_32.o:(.fixup+0x8): relocation truncated to fit: R_SPARC_WDISP22 against .text' arch/sparc/kernel/signal_32.o:(.fixup+0x10): relocation truncated to fit: R_SPARC_WDISP22 against .text' arch/sparc/kernel/signal_32.o:(.fixup+0x18): relocation truncated to fit: R_SPARC_WDISP22 against .text' arch/sparc/kernel/signal_32.o:(.fixup+0x20): relocation truncated to fit: R_SPARC_WDISP22 against .text' arch/sparc/kernel/signal_32.o:(.fixup+0x28): relocation truncated to fit: R_SPARC_WDISP22 against `.text' arch/sparc/kernel/signal_32.o:(.fixup+0x30): additional relocation overflows omitted from the output
sparc-linux-ld: drivers/vhost/vringh.o: in function `iotlb_translate':

>> drivers/vhost/vringh.c:1079: undefined reference to `vhost_iotlb_itree_first'

vim +1079 drivers/vhost/vringh.c

f558a845c3a043 Dave Jones 2013-05-03  1061  
9ad9c49cfe970b Jason Wang 2020-03-26  1062  static int iotlb_translate(const struct vringh *vrh,
9ad9c49cfe970b Jason Wang 2020-03-26  1063  			   u64 addr, u64 len, struct bio_vec iov[],
9ad9c49cfe970b Jason Wang 2020-03-26  1064  			   int iov_size, u32 perm)
9ad9c49cfe970b Jason Wang 2020-03-26  1065  {
9ad9c49cfe970b Jason Wang 2020-03-26  1066  	struct vhost_iotlb_map *map;
9ad9c49cfe970b Jason Wang 2020-03-26  1067  	struct vhost_iotlb *iotlb = vrh->iotlb;
9ad9c49cfe970b Jason Wang 2020-03-26  1068  	int ret = 0;
9ad9c49cfe970b Jason Wang 2020-03-26  1069  	u64 s = 0;
9ad9c49cfe970b Jason Wang 2020-03-26  1070  
9ad9c49cfe970b Jason Wang 2020-03-26  1071  	while (len > s) {
9ad9c49cfe970b Jason Wang 2020-03-26  1072  		u64 size, pa, pfn;
9ad9c49cfe970b Jason Wang 2020-03-26  1073  
9ad9c49cfe970b Jason Wang 2020-03-26  1074  		if (unlikely(ret >= iov_size)) {
9ad9c49cfe970b Jason Wang 2020-03-26  1075  			ret = -ENOBUFS;
9ad9c49cfe970b Jason Wang 2020-03-26  1076  			break;
9ad9c49cfe970b Jason Wang 2020-03-26  1077  		}
9ad9c49cfe970b Jason Wang 2020-03-26  1078  
9ad9c49cfe970b Jason Wang 2020-03-26 @1079  		map = vhost_iotlb_itree_first(iotlb, addr,
9ad9c49cfe970b Jason Wang 2020-03-26  1080  					      addr + len - 1);
9ad9c49cfe970b Jason Wang 2020-03-26  1081  		if (!map || map->start > addr) {
9ad9c49cfe970b Jason Wang 2020-03-26  1082  			ret = -EINVAL;
9ad9c49cfe970b Jason Wang 2020-03-26  1083  			break;
9ad9c49cfe970b Jason Wang 2020-03-26  1084  		} else if (!(map->perm & perm)) {
9ad9c49cfe970b Jason Wang 2020-03-26  1085  			ret = -EPERM;
9ad9c49cfe970b Jason Wang 2020-03-26  1086  			break;
9ad9c49cfe970b Jason Wang 2020-03-26  1087  		}
9ad9c49cfe970b Jason Wang 2020-03-26  1088  
9ad9c49cfe970b Jason Wang 2020-03-26  1089  		size = map->size - addr + map->start;
9ad9c49cfe970b Jason Wang 2020-03-26  1090  		pa = map->addr + addr - map->start;
9ad9c49cfe970b Jason Wang 2020-03-26  1091  		pfn = pa >> PAGE_SHIFT;
9ad9c49cfe970b Jason Wang 2020-03-26  1092  		iov[ret].bv_page = pfn_to_page(pfn);
9ad9c49cfe970b Jason Wang 2020-03-26  1093  		iov[ret].bv_len = min(len - s, size);
9ad9c49cfe970b Jason Wang 2020-03-26  1094  		iov[ret].bv_offset = pa & (PAGE_SIZE - 1);
9ad9c49cfe970b Jason Wang 2020-03-26  1095  		s += size;
9ad9c49cfe970b Jason Wang 2020-03-26  1096  		addr += size;
9ad9c49cfe970b Jason Wang 2020-03-26  1097  		++ret;
9ad9c49cfe970b Jason Wang 2020-03-26  1098  	}
9ad9c49cfe970b Jason Wang 2020-03-26  1099  
9ad9c49cfe970b Jason Wang 2020-03-26  1100  	return ret;
9ad9c49cfe970b Jason Wang 2020-03-26  1101  }
9ad9c49cfe970b Jason Wang 2020-03-26  1102  

:::::: The code at line 1079 was first introduced by commit :::::: 9ad9c49cfe970b053bb0ef323b682dd1b4d4f8a0 vringh: IOTLB support

:::::: TO: Jason Wang <[email protected]>
:::::: CC: Michael S. Tsirkin <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org