Restore support for virtio on FreeBSD
PATCH 1/1 Restore support for virtio on FreeBSD
--- lib/librte_eal/bsdapp/eal/eal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/bsdapp/eal/eal.c +1 -1
@@ -426,7 +426,7 @@ rte_eal_iopl_init(void) fd =open ("/dev/io" ,O_RDWR );if (fd <0 )return -1 ; -close (fd); +/* keep fd open for iopl */ return 0 ; }
Signature · 1 line
2.1.2
PATCH v2 1/1 Restore support for virtio on FreeBSD
In reply to a message not in the archive--- lib/librte_eal/bsdapp/eal/eal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/bsdapp/eal/eal.c +1 -1
@@ -426,7 +426,7 @@ rte_eal_iopl_init(void) fd =open ("/dev/io" ,O_RDWR );if (fd <0 )return -1 ; -close (fd); +/* keep fd open for iopl */ return 0 ; }
Signature · 1 line
2.1.2
PATCH v3 1/1 Restore support for virtio on FreeBSD
In reply to a message not in the archive--- lib/librte_eal/bsdapp/eal/eal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/bsdapp/eal/eal.c +1 -1
@@ -426,7 +426,7 @@ rte_eal_iopl_init(void) fd =open ("/dev/io" ,O_RDWR );if (fd <0 )return -1 ; -close (fd); +/* keep fd open for iopl */ return 0 ; }
Signature · 1 line
2.1.2
Please provide more information in the commit message. We need to know what was the problem (crash) in the git history. Then when doing git blame, we'll have the full explanation.
2015-04-13 15:19, Raz Amir:
Quoted 12 lines
Fixes 8a312224bcde ("eal/bsd: fix fd leak")Signed-off-by Raz Amir <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_eal/bsdapp/eal/eal.c +0
-0
lib/librte_eal/bsdapp/eal/eal.c rte_eal_iopl_init(void) · line 429
Quoted 5 lines
lib/librte_eal/bsdapp/eal/eal.c +1
-1@@ -426,7 +426,7 @@ rte_eal_iopl_init(void) fd =open ("/dev/io" ,O_RDWR );if (fd <0 )return -1 ; -close (fd); +/* keep fd open for iopl */
Yes we need a comment but "for iopl" is not descriptive and not very accurate as iopl is a Linux mechanism.
lib/librte_eal/bsdapp/eal/eal.c rte_eal_iopl_init(void) · line 431
Quoted 2 lines
lib/librte_eal/bsdapp/eal/eal.c +0
-0return 0 ; }
Thanks
Hi
Quoted 19 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Monday, April 13, 2015 8:55 PM
To: Raz Amir
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v3] Restore support for virtio on FreeBSDPlease provide more information in the commit message. We need to know what was the problem (crash) in the git history. Then when doing git blame, we'll have the full explanation.
2015-04-13 15:19, Raz Amir:
Quoted 7 lines
Fixes 8a312224bcde ("eal/bsd: fix fd leak")Signed-off-by Raz Amir <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 10 lines
lib/librte_eal/bsdapp/eal/eal.c rte_eal_iopl_init(void) · line 429
Quoted 10 lines
(quoted diff) +0
-0
b/lib/librte_eal/bsdapp/eal/eal.cindex 871d5f4..e20f915 100644lib/librte_eal/bsdapp/eal/eal.c +1
-1@@ -426,7 +426,7 @@ rte_eal_iopl_init(void) fd =open ("/dev/io" ,O_RDWR );if (fd <0 )return -1 ; -close (fd); +/* keep fd open for iopl */
Copy and paste my comment into this new patch:
Would you pls think about this solution?
Declare a static var to keep the fd which is opened for freebsd;
Then define a deinit function for virtio device, Inside the deinit function, close the fd which was opened in init stage. Done.
thanks
Changchun
Thomas, I will add more information to the commit message, but regarding your feedback on the iopl comment, it is called also iopl on FreeBSD. See this link to FreeBSD source code, for the io driver code - the flag name is PSL_IOPL:
https://github.com/freebsd/freebsd/blob/master/sys/i386/i386/io.c#L38
Ouyang, I will implement your suggestion in the next patch version I submit.
-----Original Message-----
From: Ouyang, Changchun [mailto:[email protected]]
Sent: 14 April 2015 05:33
To: Thomas Monjalon; Raz Amir
Cc: [email protected]; Ouyang, Changchun
Subject: RE: [dpdk-dev] [PATCH v3] Restore support for virtio on FreeBSD
Hi
Quoted 20 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Thomas Monjalon
Sent: Monday, April 13, 2015 8:55 PM
To: Raz Amir
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v3] Restore support for virtio on
FreeBSDPlease provide more information in the commit message. We need to know what was the problem (crash) in the git history. Then when doing git blame, we'll have the full explanation.
2015-04-13 15:19, Raz Amir:
Quoted 7 lines
Fixes 8a312224bcde ("eal/bsd: fix fd leak")Signed-off-by Raz Amir <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 10 lines
lib/librte_eal/bsdapp/eal/eal.c rte_eal_iopl_init(void) · line 429
Quoted 10 lines
(quoted diff) +0
-0
b/lib/librte_eal/bsdapp/eal/eal.cindex 871d5f4..e20f915 100644lib/librte_eal/bsdapp/eal/eal.c +1
-1@@ -426,7 +426,7 @@ rte_eal_iopl_init(void) fd =open ("/dev/io" ,O_RDWR );if (fd <0 )return -1 ; -close (fd); +/* keep fd open for iopl */
Copy and paste my comment into this new patch:
Would you pls think about this solution?
Declare a static var to keep the fd which is opened for freebsd; Then define a deinit function for virtio device, Inside the deinit function, close the fd which was opened in init stage.
Done.
thanks
Changchun
PATCH v5 1/1 Restore support for virtio on FreeBSD
In reply to a message not in the archiveClosing /dev/io fd causes SIGBUS in inb/outb instructions as the process loses the IOPL privileges once the fd is closed:
(gdb) bt
0 0x0000000000492f2c in outb (port=49170, data=0 '\000')
at /usr/include/machine/cpufunc.h:244
1 0x0000000000492f7a in outb_p (data=0 '\000', port=49170)
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.h:211
2 0x000000000049328d in vtpci_set_status (hw=0x80331f380, status=0 '\000')
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:130
3 0x00000000004931fe in vtpci_reset (hw=0x80331f380)
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:108
4 0x00000000004a175e in eth_virtio_dev_init (eth_dev=0x831b80 <rte_eth_devices>)
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_ethdev.c:1150
5 0x0000000000462c09 in rte_eth_dev_init (pci_drv=0x79d1a0 <rte_virtio_pmd>,
pci_dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_ether/rte_ethdev.c:326
6 0x000000000046f03f in rte_eal_pci_probe_one_driver (dr=0x79d1a0 <rte_virtio_pmd>,
dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal_pci.c:487
7 0x0000000000475b06 in pci_probe_all_drivers (dev=0x802417560)
at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:116
8 0x0000000000475bb9 in rte_eal_pci_probe ()
at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:246
9 0x000000000046cd63 in rte_eal_init (argc=5, argv=0x7fffffffeaf0)
at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal.c:55410 0x0000000000404544 in main ()
--- lib/librte_eal/bsdapp/eal/eal.c | 19 ++++++++++++++----- lib/librte_eal/common/include/rte_eal.h | 10 ++++++++++ lib/librte_eal/linuxapp/eal/eal.c | 5 +++++ lib/librte_pmd_virtio/virtio_ethdev.c | 9 +++++++++ 4 files changed, 38 insertions(+), 5 deletions(-)
lib/librte_eal/bsdapp/eal/eal.c +14 -5
@@ -112,6 +112,9 @@ struct internal_config internal_config;/* used by rte_rdtsc() */ int rte_cycles_vmware_tsc_map; +/* fd to keep open for iopl */ +static int iopl_fd =-1 ; +/* Return a pointer to the configuration structure */ struct rte_config *rte_eal_get_configuration (void )
@@ -421,15 +424,21 @@ int rte_eal_has_hugepages(void)int rte_eal_iopl_init (void ) { -int fd; - - fd =open ("/dev/io" ,O_RDWR ); -if (fd <0 ) + iopl_fd =open ("/dev/io" ,O_RDWR ); +if (iopl_fd <0 )return -1 ; -close (fd); +/* keep fd open for iopl */ return 0 ; } +void +rte_eal_iopl_uninit (void ) +{ +if (iopl_fd !=-1 ) +close (iopl_fd); + iopl_fd =-1 ; +} +/* Launch threads, called at application init(). */ int rte_eal_init (int argc,char **argv)
lib/librte_eal/common/include/rte_eal.h +10 -0
@@ -127,6 +127,16 @@ enum rte_proc_type_t rte_eal_process_type(void);int rte_eal_iopl_init (void );/** +* Release iopl priviledge - currently relevant only for FreeBSD. +* +* This function should be called by pmds which need access to ioports. + +* @return +* void +*/ +void rte_eal_iopl_uninit (void ); + +/** * Initialize the Environment Abstraction Layer (EAL). * * This function is to be executed on the MASTER lcore only, as soon
lib/librte_eal/linuxapp/eal/eal.c +5 -0
@@ -695,6 +695,11 @@ rte_eal_iopl_init(void)#endif } +void +rte_eal_iopl_uninit (void ) +{ +} +/* Launch threads, called at application init(). */ int rte_eal_init (int argc,char **argv)
lib/librte_pmd_virtio/virtio_ethdev.c +9 -0
@@ -1265,6 +1265,14 @@ rte_virtio_pmd_init(const char *name __rte_unused,return 0 ; } +static int +rte_virtio_pmd_uninit (const char *name) +{ + (void )name; +rte_eal_iopl_uninit (); +return 0 ; +} +/* * Only 1 queue is supported, no queue release related operation */
@@ -1499,6 +1507,7 @@ __rte_unused uint8_t is_rx)static struct rte_driver rte_virtio_driver = { .type =PMD_PDEV , .init = rte_virtio_pmd_init, + .uninit = rte_virtio_pmd_uninit, };PMD_REGISTER_DRIVER (rte_virtio_driver);
Signature · 1 line
2.1.2
Hi,
Quoted 69 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Raz Amir
Sent: Tuesday, April 14, 2015 5:23 PM
To: [email protected]
Cc: Raz Amir
Subject: [dpdk-dev] [PATCH v5] Restore support for virtio on FreeBSDFixes 8a312224bcde ("eal/bsd: fix fd leak")Closing
/dev/iofd causes SIGBUS in inb/outb instructions as the process loses the IOPL privileges once the fd is closed:
(gdb) bt
00x0000000000492f2cin outb (port=49170, data=0 '\000')
at/usr/include/machine/cpufunc.h:244
10x0000000000492f7ainoutb_p(data=0 '\000', port=49170)at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.h:211 2 0x000000000049328d in vtpci_set_status (hw=0x80331f380, status=0 '\000') at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:130 3 0x00000000004931fe in vtpci_reset (hw=0x80331f380) at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:108 4 0x00000000004a175e in eth_virtio_dev_init (eth_dev=0x831b80 <rte_eth_devices>) at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_ethdev.c:1150 5 0x0000000000462c09 in rte_eth_dev_init (pci_drv=0x79d1a0 <rte_virtio_pmd>, pci_dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_ether/rte_ethdev.c:326 6 0x000000000046f03f in rte_eal_pci_probe_one_driver (dr=0x79d1a0 <rte_virtio_pmd>, dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal_pci.c:487 7 0x0000000000475b06 in pci_probe_all_drivers (dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:116 8 0x0000000000475bb9 in rte_eal_pci_probe () at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:246 9 0x000000000046cd63 in rte_eal_init (argc=5, argv=0x7fffffffeaf0) at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal.c:55410
0x0000000000404544in main ()Signed-off-by Raz Amir <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 19 ++++++++++++++----- lib/librte_eal/common/include/rte_eal.h | 10 ++++++++++ lib/librte_eal/linuxapp/eal/eal.c | 5 +++++ lib/librte_pmd_virtio/virtio_ethdev.c | 9 +++++++++ 4 files changed, 38 insertions(+), 5 deletions(-)lib/librte_eal/bsdapp/eal/eal.c +6
-5@@ -112,6 +112,9 @@ struct internal_config internal_config;/* used by rte_rdtsc() */ int rte_cycles_vmware_tsc_map; +/* fd to keep open for iopl */ +static int iopl_fd =-1 ; +/* Return a pointer to the configuration structure */ struct rte_config *rte_eal_get_configuration (void )@@ -421,15 +424,21 @@ int rte_eal_has_hugepages(void)int rte_eal_iopl_init (void ) { -int fd; - - fd =open ("/dev/io" ,O_RDWR ); -if (fd <0 ) + iopl_fd =open ("/dev/io" ,O_RDWR ); +if (iopl_fd <0 )return -1 ; -close (fd); +/* keep fd open for iopl */
lib/librte_eal/bsdapp/eal/eal.c int rte_eal_has_hugepages(void) · line 440
Quoted 10 lines
lib/librte_eal/bsdapp/eal/eal.c +7
-0return 0 ; } +void +rte_eal_iopl_uninit (void ) +{ +if (iopl_fd !=-1 ) +close (iopl_fd); + iopl_fd =-1 ; +}
Did I get it right: that function would be invoked for at dev_detach()?
And after we invoked it, we still we can have other multiple virtio devices attached and active? If so, then I suppose you'll hit the same problem again.
Konstantin
Quoted 70 lines
lib/librte_eal/bsdapp/eal/eal.c +1
-0+/* Launch threads, called at application init(). */ int rte_eal_init (int argc,char **argv)lib/librte_eal/common/include/rte_eal.h +10
-0@@ -127,6 +127,16 @@ enum rte_proc_type_t rte_eal_process_type(void);int rte_eal_iopl_init (void );/** +* Release iopl priviledge - currently relevant only for FreeBSD. +* +* This function should be called by pmds which need access to ioports. + +* @return +* void +*/ +void rte_eal_iopl_uninit (void ); + +/** * Initialize the Environment Abstraction Layer (EAL). * * This function is to be executed on the MASTER lcore only, as soon lib/librte_eal/linuxapp/eal/eal.c +5
-0@@ -695,6 +695,11 @@ rte_eal_iopl_init(void)#endif } +void +rte_eal_iopl_uninit (void ) +{ +} +/* Launch threads, called at application init(). */ int rte_eal_init (int argc,char **argv)lib/librte_pmd_virtio/virtio_ethdev.c +9
-1@@ -1265,6 +1265,14 @@ rte_virtio_pmd_init(const char *name __rte_unused,return 0 ; } +static int +rte_virtio_pmd_uninit (const char *name) +{ + (void )name; +rte_eal_iopl_uninit (); +return 0 ; +} +/* * Only 1 queue is supported, no queue release related operation */ @@ -1499,6 +1507,7 @@ __rte_unused uint8_t is_rx)static struct rte_driver rte_virtio_driver = { .type =PMD_PDEV , .init = rte_virtio_pmd_init, + .uninit = rte_virtio_pmd_uninit, };PMD_REGISTER_DRIVER (rte_virtio_driver); --2.1.2
Quoted 88 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ananyev, Konstantin
Sent: Wednesday, April 15, 2015 6:22 AM
To: Raz Amir; [email protected]
Subject: Re: [dpdk-dev] [PATCH v5] Restore support for virtio on FreeBSDHi,
Quoted 9 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Raz Amir
Sent: Tuesday, April 14, 2015 5:23 PM
To: [email protected]
Cc: Raz Amir
Subject: [dpdk-dev] [PATCH v5] Restore support for virtio on FreeBSDFixes 8a312224bcde ("eal/bsd: fix fd leak")Quoted 8 lines
Closing
/dev/iofd causes SIGBUS in inb/outb instructions as the process loses the IOPL privileges once the fd is closed:
(gdb) bt
00x0000000000492f2cin outb (port=49170, data=0 '\000')
at/usr/include/machine/cpufunc.h:244
10x0000000000492f7ainoutb_p(data=0 '\000', port=49170)at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.h:2112
0x000000000049328dinvtpci_set_status(hw=0x80331f380, status=0'\000')
Quoted 4 lines
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:130 3 0x00000000004931fe in vtpci_reset (hw=0x80331f380) at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:1084
0x00000000004a175eineth_virtio_dev_init(eth_dev=0x831b80<
rte_eth_devices>)Quoted 2 lines
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_ethdev.c:11505
0x0000000000462c09inrte_eth_dev_init(pci_drv=0x79d1a0<
rte_virtio_pmd>,Quoted 3 lines
pci_dev=0x802417560) at/dpdk/dpdk-2.0.0/lib/librte_ether/rte_ethdev.c:326
60x000000000046f03finrte_eal_pci_probe_one_driver(dr=0x79d1a0<
rte_virtio_pmd>,Quoted 47 lines
dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal_pci.c:487 7 0x0000000000475b06 in pci_probe_all_drivers (dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:116 8 0x0000000000475bb9 in rte_eal_pci_probe () at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:246 9 0x000000000046cd63 in rte_eal_init (argc=5, argv=0x7fffffffeaf0) at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal.c:55410
0x0000000000404544in main ()Signed-off-by Raz Amir <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 19 ++++++++++++++----- lib/librte_eal/common/include/rte_eal.h | 10 ++++++++++ lib/librte_eal/linuxapp/eal/eal.c | 5 +++++ lib/librte_pmd_virtio/virtio_ethdev.c | 9 +++++++++ 4 files changed, 38 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/lib/librte_eal/bsdapp/eal/eal.cindex 871d5f4..687dd83 100644lib/librte_eal/bsdapp/eal/eal.c +3
-0@@ -112,6 +112,9 @@ struct internal_config internal_config;/* used by rte_rdtsc() */ int rte_cycles_vmware_tsc_map; +/* fd to keep open for iopl */ +static int iopl_fd =-1 ; + /* Return a pointer to the configuration structure */ struct
rte_config*
rte_eal_get_configuration(void)lib/librte_eal/bsdapp/eal/eal.c +3
-5@@ -421,15 +424,21 @@ int rte_eal_has_hugepages(void) intrte_eal_iopl_init (void) { -int fd; - - fd =open ("/dev/io" ,O_RDWR ); -if (fd <0 ) + iopl_fd =open ("/dev/io" ,O_RDWR ); +if (iopl_fd <0 )return -1 ; -close (fd); +/* keep fd open for iopl */ return 0 ; }
Quoted 14 lines
lib/librte_eal/bsdapp/eal/eal.c int rte_eal_has_hugepages(void) · line 440
Quoted 7 lines
lib/librte_eal/bsdapp/eal/eal.c +7
-0+void +rte_eal_iopl_uninit (void ) +{ +if (iopl_fd !=-1 ) +close (iopl_fd); + iopl_fd =-1 ; +}Did I get it right: that function would be invoked for at
dev_detach()? And after we invoked it, we still we can have other multiple virtio devices attached and active?
If so, then I suppose you'll hit the same problem again. Konstantin
Yes, need verify this issue,
If it is true, may use reference counter to resolve it? Thanks
Changchun
Quoted 70 lines
lib/librte_eal/common/include/rte_eal.h enum rte_proc_type_t
Quoted 9 lines
lib/librte_eal/bsdapp/eal/eal.c +1
-0+/* Launch threads, called at application init(). */ int
rte_eal_init(int argc, char **argv)diff --gita/lib/librte_eal/common/include/rte_eal.hb/lib/librte_eal/common/include/rte_eal.h
index 1385a73..9151e08 100644lib/librte_eal/common/include/rte_eal.h +0
-0@@ -127,6 +127,16 @@ enum rte_proc_type_t
rte_eal_process_type(void);lib/librte_pmd_virtio/virtio_ethdev.c rte_virtio_pmd_init(const char *name
Quoted 36 lines
lib/librte_eal/common/include/rte_eal.h +10
-0int rte_eal_iopl_init (void );/** +* Release iopl priviledge - currently relevant only for FreeBSD. +* +* This function should be called by pmds which need access to ioports. + +* @return +* void +*/ +void rte_eal_iopl_uninit (void ); + +/** * Initialize the Environment Abstraction Layer (EAL). * * This function is to be executed on the MASTER lcore only, as soon lib/librte_eal/linuxapp/eal/eal.c +5
-0@@ -695,6 +695,11 @@ rte_eal_iopl_init(void) #endif } +void +rte_eal_iopl_uninit (void ) +{ +} +/* Launch threads, called at application init(). */ int
rte_eal_init(int argc, char **argv)diff --gita/lib/librte_pmd_virtio/virtio_ethdev.cb/lib/librte_pmd_virtio/virtio_ethdev.c
index 7b83d9b..5be5c27 100644lib/librte_pmd_virtio/virtio_ethdev.c +0
-0@@ -1265,6 +1265,14 @@ rte_virtio_pmd_init(const char *name
__rte_unused,Quoted 23 lines
lib/librte_pmd_virtio/virtio_ethdev.c +8
-1return 0 ; } +static int +rte_virtio_pmd_uninit (const char *name) { + (void )name; +rte_eal_iopl_uninit (); +return 0 ; +} +/* * Only 1 queue is supported, no queue release related operation */ @@ -1499,6 +1507,7 @@ __rte_unused uint8_t is_rx) static structrte_driver rte_virtio_driver = { .type =PMD_PDEV , .init = rte_virtio_pmd_init, + .uninit = rte_virtio_pmd_uninit, };PMD_REGISTER_DRIVER (rte_virtio_driver); --2.1.2
Hi,
Quoted 1 line
From both running and reading the code, the
rte_virtio_pmd_initis called
only once from: rte_eal_init -> rte_eal_dev_init.
But, the uninit won't be called, since uninit it called only for PMD_VDEV driver types, while virtio is PMD_PDEV.
Based on that, I am going to submit the original patch again, that fd won't be closed, and without handling the close at uninit as it isn't called and since fd will be closed anyway when the process exits.
Thanks,
Raz.
-----Original Message-----
From: Ouyang, Changchun [mailto:[email protected]]
Sent: 16 April 2015 06:31
To: Ananyev, Konstantin; Raz Amir; [email protected]
Cc: Ouyang, Changchun
Subject: RE: [dpdk-dev] [PATCH v5] Restore support for virtio on FreeBSD
Quoted 87 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ananyev, Konstantin
Sent: Wednesday, April 15, 2015 6:22 AM
To: Raz Amir; [email protected]
Subject: Re: [dpdk-dev] [PATCH v5] Restore support for virtio on FreeBSDHi,
Quoted 9 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Raz Amir
Sent: Tuesday, April 14, 2015 5:23 PM
To: [email protected]
Cc: Raz Amir
Subject: [dpdk-dev] [PATCH v5] Restore support for virtio on FreeBSDFixes 8a312224bcde ("eal/bsd: fix fd leak")Quoted 8 lines
Closing
/dev/iofd causes SIGBUS in inb/outb instructions as the process loses the IOPL privileges once the fd is closed:
(gdb) bt
00x0000000000492f2cin outb (port=49170, data=0 '\000')
at/usr/include/machine/cpufunc.h:244
10x0000000000492f7ainoutb_p(data=0 '\000', port=49170)at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.h:2112
0x000000000049328dinvtpci_set_status(hw=0x80331f380, status=0'\000')
Quoted 4 lines
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:130 3 0x00000000004931fe in vtpci_reset (hw=0x80331f380) at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:1084
0x00000000004a175eineth_virtio_dev_init(eth_dev=0x831b80<
rte_eth_devices>)Quoted 2 lines
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_ethdev.c:11505
0x0000000000462c09inrte_eth_dev_init(pci_drv=0x79d1a0<
rte_virtio_pmd>,Quoted 3 lines
pci_dev=0x802417560) at/dpdk/dpdk-2.0.0/lib/librte_ether/rte_ethdev.c:326
60x000000000046f03finrte_eal_pci_probe_one_driver(dr=0x79d1a0<
rte_virtio_pmd>,Quoted 47 lines
dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal_pci.c:487 7 0x0000000000475b06 in pci_probe_all_drivers (dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:116 8 0x0000000000475bb9 in rte_eal_pci_probe () at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:246 9 0x000000000046cd63 in rte_eal_init (argc=5, argv=0x7fffffffeaf0) at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal.c:55410
0x0000000000404544in main ()Signed-off-by Raz Amir <[email protected]>--- lib/librte_eal/bsdapp/eal/eal.c | 19 ++++++++++++++----- lib/librte_eal/common/include/rte_eal.h | 10 ++++++++++ lib/librte_eal/linuxapp/eal/eal.c | 5 +++++ lib/librte_pmd_virtio/virtio_ethdev.c | 9 +++++++++ 4 files changed, 38 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/lib/librte_eal/bsdapp/eal/eal.cindex 871d5f4..687dd83 100644lib/librte_eal/bsdapp/eal/eal.c +3
-0@@ -112,6 +112,9 @@ struct internal_config internal_config;/* used by rte_rdtsc() */ int rte_cycles_vmware_tsc_map; +/* fd to keep open for iopl */ +static int iopl_fd =-1 ; + /* Return a pointer to the configuration structure */ struct
rte_config*
rte_eal_get_configuration(void)lib/librte_eal/bsdapp/eal/eal.c +3
-5@@ -421,15 +424,21 @@ int rte_eal_has_hugepages(void) intrte_eal_iopl_init (void) { -int fd; - - fd =open ("/dev/io" ,O_RDWR ); -if (fd <0 ) + iopl_fd =open ("/dev/io" ,O_RDWR ); +if (iopl_fd <0 )return -1 ; -close (fd); +/* keep fd open for iopl */ return 0 ; }
Quoted 14 lines
lib/librte_eal/bsdapp/eal/eal.c int rte_eal_has_hugepages(void) · line 440
Quoted 7 lines
lib/librte_eal/bsdapp/eal/eal.c +7
-0+void +rte_eal_iopl_uninit (void ) +{ +if (iopl_fd !=-1 ) +close (iopl_fd); + iopl_fd =-1 ; +}Did I get it right: that function would be invoked for at
dev_detach()? And after we invoked it, we still we can have other multiple virtio devices attached and active?
If so, then I suppose you'll hit the same problem again. Konstantin
Yes, need verify this issue,
If it is true, may use reference counter to resolve it? Thanks
Changchun
Quoted 70 lines
lib/librte_eal/common/include/rte_eal.h enum rte_proc_type_t
Quoted 9 lines
lib/librte_eal/bsdapp/eal/eal.c +1
-0+/* Launch threads, called at application init(). */ int
rte_eal_init(int argc, char **argv)diff --gita/lib/librte_eal/common/include/rte_eal.hb/lib/librte_eal/common/include/rte_eal.h
index 1385a73..9151e08 100644lib/librte_eal/common/include/rte_eal.h +0
-0@@ -127,6 +127,16 @@ enum rte_proc_type_t
rte_eal_process_type(void);lib/librte_pmd_virtio/virtio_ethdev.c rte_virtio_pmd_init(const char *name
Quoted 36 lines
lib/librte_eal/common/include/rte_eal.h +10
-0int rte_eal_iopl_init (void );/** +* Release iopl priviledge - currently relevant only for FreeBSD. +* +* This function should be called by pmds which need access to ioports. + +* @return +* void +*/ +void rte_eal_iopl_uninit (void ); + +/** * Initialize the Environment Abstraction Layer (EAL). * * This function is to be executed on the MASTER lcore only, as soon diff --git
a/lib/librte_eal/linuxapp/eal/eal.cb/lib/librte_eal/linuxapp/eal/eal.c
index bd770cf..687cebf 100644lib/librte_eal/linuxapp/eal/eal.c +5
-0@@ -695,6 +695,11 @@ rte_eal_iopl_init(void) #endif } +void +rte_eal_iopl_uninit (void ) +{ +} +/* Launch threads, called at application init(). */ int
rte_eal_init(int argc, char **argv)diff --gita/lib/librte_pmd_virtio/virtio_ethdev.cb/lib/librte_pmd_virtio/virtio_ethdev.c
index 7b83d9b..5be5c27 100644lib/librte_pmd_virtio/virtio_ethdev.c +0
-0@@ -1265,6 +1265,14 @@ rte_virtio_pmd_init(const char *name
__rte_unused,Quoted 23 lines
lib/librte_pmd_virtio/virtio_ethdev.c +8
-1return 0 ; } +static int +rte_virtio_pmd_uninit (const char *name) { + (void )name; +rte_eal_iopl_uninit (); +return 0 ; +} +/* * Only 1 queue is supported, no queue release related operation */ @@ -1499,6 +1507,7 @@ __rte_unused uint8_t is_rx) static structrte_driver rte_virtio_driver = { .type =PMD_PDEV , .init = rte_virtio_pmd_init, + .uninit = rte_virtio_pmd_uninit, };PMD_REGISTER_DRIVER (rte_virtio_driver); --2.1.2
PATCH v6 1/1 Restore support for virtio on FreeBSD
In reply to a message not in the archiveClosing /dev/io fd causes SIGBUS in inb/outb instructions
as the process loses the IOPL privileges once the fd is closed:
(gdb) bt
0 0x0000000000492f2c in outb (port=49170, data=0 '\000')
at /usr/include/machine/cpufunc.h:244
1 0x0000000000492f7a in outb_p (data=0 '\000', port=49170)
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.h:211
2 0x000000000049328d in vtpci_set_status (hw=0x80331f380, status=0 '\000') at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:130
3 0x00000000004931fe in vtpci_reset (hw=0x80331f380)
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:108
4 0x00000000004a175e in eth_virtio_dev_init (eth_dev=0x831b80 <rte_eth_devices>) at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_ethdev.c:1150
5 0x0000000000462c09 in rte_eth_dev_init (pci_drv=0x79d1a0 <rte_virtio_pmd>, pci_dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_ether/rte_ethdev.c:326 6 0x000000000046f03f in rte_eal_pci_probe_one_driver (dr=0x79d1a0 <rte_virtio_pmd>, dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal_pci.c:487 7 0x0000000000475b06 in pci_probe_all_drivers (dev=0x802417560)
at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:116
8 0x0000000000475bb9 in rte_eal_pci_probe ()
at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:246
9 0x000000000046cd63 in rte_eal_init (argc=5, argv=0x7fffffffeaf0)
at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal.c:554
10 0x0000000000404544 in main ()
--- lib/librte_eal/bsdapp/eal/eal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/bsdapp/eal/eal.c +1 -1
@@ -426,7 +426,7 @@ rte_eal_iopl_init(void) fd =open ("/dev/io" ,O_RDWR );if (fd <0 )return -1 ; -close (fd); +/* keep fd open for iopl */ return 0 ; }
Signature · 1 line
2.1.2
Quoted 27 lines · Raz Amir
Fixes 8a312224bcde ("eal/bsd: fix fd leak")Closing
/dev/iofd causes SIGBUS in inb/outb instructions
as the process loses the IOPL privileges once the fd is closed:
(gdb) bt
00x0000000000492f2cin outb (port=49170, data=0 '\000')
at/usr/include/machine/cpufunc.h:244
10x0000000000492f7ainoutb_p(data=0 '\000', port=49170)
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.h:211
20x000000000049328dinvtpci_set_status(hw=0x80331f380, status=0 '\000') at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:130
30x00000000004931feinvtpci_reset(hw=0x80331f380)
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:108
40x00000000004a175eineth_virtio_dev_init(eth_dev=0x831b80 <rte_eth_devices>) at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_ethdev.c:1150
50x0000000000462c09inrte_eth_dev_init(pci_drv=0x79d1a0 <rte_virtio_pmd>, pci_dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_ether/rte_ethdev.c:326 60x000000000046f03finrte_eal_pci_probe_one_driver(dr=0x79d1a0 <rte_virtio_pmd>, dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal_pci.c:487 70x0000000000475b06inpci_probe_all_drivers(dev=0x802417560)
at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:116
80x0000000000475bb9inrte_eal_pci_probe()
at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:246
90x000000000046cd63inrte_eal_init(argc=5, argv=0x7fffffffeaf0)
at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal.c:554
100x0000000000404544in main ()
Quoted 1 line
Signed-off-by Raz Amir <[email protected]>
It does look the cleanest solution, though I don't like the idea of leaking the file handle. Can you perhaps just change things a little so that the fd variable is static - even locally in the function will do, as it helps indicate that the fd is persistent.
/Bruce
Quoted 20 lines
--- lib/librte_eal/bsdapp/eal/eal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/librte_eal/bsdapp/eal/eal.c +1
-1@@ -426,7 +426,7 @@ rte_eal_iopl_init(void) fd =open ("/dev/io" ,O_RDWR );if (fd <0 )return -1 ; -close (fd); +/* keep fd open for iopl */ return 0 ; }Signature · 1 line
2.1.2
Will do
-----Original Message-----
From: Bruce Richardson [mailto:[email protected]]
Sent: 16 April 2015 12:39
To: Raz Amir
Cc: [email protected]
Subject: Re: [dpdk-dev] [PATCH v6] Restore support for virtio on FreeBSD
Quoted 32 lines · Raz Amir
Fixes 8a312224bcde ("eal/bsd: fix fd leak")Closing
/dev/iofd causes SIGBUS in inb/outb instructions as the process loses the IOPL privileges once the fd is closed:
(gdb) bt
00x0000000000492f2cin outb (port=49170, data=0 '\000') at/usr/include/machine/cpufunc.h:244
10x0000000000492f7ainoutb_p(data=0 '\000', port=49170) at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.h:211
20x000000000049328dinvtpci_set_status(hw=0x80331f380, status=0 '\000') at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:130 30x00000000004931feinvtpci_reset(hw=0x80331f380) at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:108
40x00000000004a175eineth_virtio_dev_init(eth_dev=0x831b80 <rte_eth_devices>) at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_ethdev.c:1150 50x0000000000462c09inrte_eth_dev_init(pci_drv=0x79d1a0 <rte_virtio_pmd>,
pci_dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_ether/rte_ethdev.c:326
60x000000000046f03finrte_eal_pci_probe_one_driver(dr=0x79d1a0 <rte_virtio_pmd>,
dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal_pci.c:487
70x0000000000475b06inpci_probe_all_drivers(dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:116 80x0000000000475bb9inrte_eal_pci_probe() at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:246 90x000000000046cd63inrte_eal_init(argc=5, argv=0x7fffffffeaf0) at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal.c:554
100x0000000000404544in main ()
Quoted 1 line
Signed-off-by Raz Amir <[email protected]>
It does look the cleanest solution, though I don't like the idea of leaking the file handle. Can you perhaps just change things a little so that the fd variable is static - even locally in the function will do, as it helps indicate that the fd is persistent.
/Bruce
Quoted 20 lines
--- lib/librte_eal/bsdapp/eal/eal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/lib/librte_eal/bsdapp/eal/eal.cindex 871d5f4..e20f915 100644lib/librte_eal/bsdapp/eal/eal.c +1
-2@@ -426,7 +426,7 @@ rte_eal_iopl_init(void) fd =open ("/dev/io" ,O_RDWR );if (fd <0 )return -1 ; -close (fd); +/* keep fd open for iopl */ return 0 ; } --2.1.2
PATCH v7 1/1 Restore support for virtio on FreeBSD
In reply to a message not in the archiveClosing /dev/io fd causes SIGBUS in inb/outb instructions
as the process loses the IOPL privileges once the fd is closed:
(gdb) bt
0 0x0000000000492f2c in outb (port=49170, data=0 '\000')
at /usr/include/machine/cpufunc.h:244
1 0x0000000000492f7a in outb_p (data=0 '\000', port=49170)
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.h:211
2 0x000000000049328d in vtpci_set_status (hw=0x80331f380, status=0 '\000') at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:130
3 0x00000000004931fe in vtpci_reset (hw=0x80331f380)
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:108
4 0x00000000004a175e in eth_virtio_dev_init (eth_dev=0x831b80 <rte_eth_devices>) at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_ethdev.c:1150
5 0x0000000000462c09 in rte_eth_dev_init (pci_drv=0x79d1a0 <rte_virtio_pmd>, pci_dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_ether/rte_ethdev.c:326 6 0x000000000046f03f in rte_eal_pci_probe_one_driver (dr=0x79d1a0 <rte_virtio_pmd>, dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal_pci.c:487 7 0x0000000000475b06 in pci_probe_all_drivers (dev=0x802417560)
at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:116
8 0x0000000000475bb9 in rte_eal_pci_probe ()
at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:246
9 0x000000000046cd63 in rte_eal_init (argc=5, argv=0x7fffffffeaf0)
at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal.c:554
10 0x0000000000404544 in main ()
--- lib/librte_eal/bsdapp/eal/eal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/librte_eal/bsdapp/eal/eal.c +2 -2
@@ -421,12 +421,12 @@ int rte_eal_has_hugepages(void)int rte_eal_iopl_init (void ) { -int fd; +static int fd; fd =open ("/dev/io" ,O_RDWR );if (fd <0 )return -1 ; -close (fd); +/* keep fd open for iopl */ return 0 ; }
Signature · 1 line
2.1.2
Thomas Monjalon
AppliedQuoted 27 lines
Fixes 8a312224bcde ("eal/bsd: fix fd leak")Closing
/dev/iofd causes SIGBUS in inb/outb instructions
as the process loses the IOPL privileges once the fd is closed:
(gdb) bt
00x0000000000492f2cin outb (port=49170, data=0 '\000')
at/usr/include/machine/cpufunc.h:244
10x0000000000492f7ainoutb_p(data=0 '\000', port=49170)
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.h:211
20x000000000049328dinvtpci_set_status(hw=0x80331f380, status=0 '\000') at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:130
30x00000000004931feinvtpci_reset(hw=0x80331f380)
at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_pci.c:108
40x00000000004a175eineth_virtio_dev_init(eth_dev=0x831b80 <rte_eth_devices>) at /dpdk/dpdk-2.0.0/lib/librte_pmd_virtio/virtio_ethdev.c:1150
50x0000000000462c09inrte_eth_dev_init(pci_drv=0x79d1a0 <rte_virtio_pmd>, pci_dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_ether/rte_ethdev.c:326 60x000000000046f03finrte_eal_pci_probe_one_driver(dr=0x79d1a0 <rte_virtio_pmd>, dev=0x802417560) at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal_pci.c:487 70x0000000000475b06inpci_probe_all_drivers(dev=0x802417560)
at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:116
80x0000000000475bb9inrte_eal_pci_probe()
at /dpdk/dpdk-2.0.0/lib/librte_eal/common/eal_common_pci.c:246
90x000000000046cd63inrte_eal_init(argc=5, argv=0x7fffffffeaf0)
at /dpdk/dpdk-2.0.0/lib/librte_eal/bsdapp/eal/eal.c:554
100x0000000000404544in main ()
Quoted 1 line
Signed-off-by Raz Amir <[email protected]>
Applied, thanks