DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] eal/bus: use RTE_IOVA_PA only if phys addresses are available
@ 2018-09-07 15:47 Darek Stojaczyk
  2018-09-07 15:58 ` [dpdk-dev] [PATCH v2] " Darek Stojaczyk
  0 siblings, 1 reply; 7+ messages in thread
From: Darek Stojaczyk @ 2018-09-07 15:47 UTC (permalink / raw)
  To: dev, Santosh Shukla, Hemant Agrawal, Jerin Jacob
  Cc: Maxime Coquelin, Anatoly Burakov, Chas Williams, Darek Stojaczyk

When neither RTE_IOVA_VA nor RTE_IOVA_PA was explicitly
requested, DPDK would currently fallback to the default
RTE_IOVA_PA mode and possibly encounter a failure later
on if running as a non-priviledged user. Attempting to
use RTE_IOVA_VA if no phys addresses are available may
help in this case.

Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
---
 lib/librte_eal/common/eal_common_bus.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index 0943851cc..8b56979d7 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -236,9 +236,19 @@ rte_bus_get_iommu_class(void)
 			mode |= bus->get_iommu_class();
 	}
 
-	if (mode != RTE_IOVA_VA) {
-		/* Use default IOVA mode */
-		mode = RTE_IOVA_PA;
+	if (mode == RTE_IOVA_VA)
+		return RTE_IOVA_VA;
+
+	if (mode & RTE_IOVA_PA) {
+		/* Not all buses support RTE_IOVA_VA, fallback to RTE_IOVA_PA */
+		return RTE_IOVA_PA;
+	}
+
+	if (rte_eal_using_phys_addrs()) {
+		/* Default to RTE_IOVA_PA only if it's supported */
+		return RTE_IOVA_PA;
 	}
-	return mode;
+
+	/* Since RTE_IOVA_PA is unsupported, fallback to RTE_IOVA_VA */
+	return RTE_IOVA_VA;
 }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH v2] eal/bus: use RTE_IOVA_PA only if phys addresses are available
  2018-09-07 15:47 [dpdk-dev] [PATCH] eal/bus: use RTE_IOVA_PA only if phys addresses are available Darek Stojaczyk
@ 2018-09-07 15:58 ` Darek Stojaczyk
  2018-09-17 10:33   ` Burakov, Anatoly
  0 siblings, 1 reply; 7+ messages in thread
From: Darek Stojaczyk @ 2018-09-07 15:58 UTC (permalink / raw)
  To: dev, Santosh Shukla, Hemant Agrawal, Jerin Jacob
  Cc: Maxime Coquelin, Anatoly Burakov, Chas Williams, Darek Stojaczyk

When neither RTE_IOVA_VA nor RTE_IOVA_PA was explicitly
requested, DPDK would currently fallback to the default
RTE_IOVA_PA mode and possibly encounter a failure later
on if running as a non-priviledged user. Attempting to
use RTE_IOVA_VA if no phys addresses are available may
help in this case.

Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
---
Changes since v1:
 * added a missing rte_memory.h include

 lib/librte_eal/common/eal_common_bus.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
index 0943851cc..68c581b8a 100644
--- a/lib/librte_eal/common/eal_common_bus.c
+++ b/lib/librte_eal/common/eal_common_bus.c
@@ -37,6 +37,7 @@
 #include <rte_bus.h>
 #include <rte_debug.h>
 #include <rte_string_fns.h>
+#include <rte_memory.h>
 
 #include "eal_private.h"
 
@@ -236,9 +237,19 @@ rte_bus_get_iommu_class(void)
 			mode |= bus->get_iommu_class();
 	}
 
-	if (mode != RTE_IOVA_VA) {
-		/* Use default IOVA mode */
-		mode = RTE_IOVA_PA;
+	if (mode == RTE_IOVA_VA)
+		return RTE_IOVA_VA;
+
+	if (mode & RTE_IOVA_PA) {
+		/* Not all buses support RTE_IOVA_VA, fallback to RTE_IOVA_PA */
+		return RTE_IOVA_PA;
+	}
+
+	if (rte_eal_using_phys_addrs()) {
+		/* Default to RTE_IOVA_PA only if it's supported */
+		return RTE_IOVA_PA;
 	}
-	return mode;
+
+	/* Since RTE_IOVA_PA is unsupported, fallback to RTE_IOVA_VA */
+	return RTE_IOVA_VA;
 }
-- 
2.17.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v2] eal/bus: use RTE_IOVA_PA only if phys addresses are available
  2018-09-07 15:58 ` [dpdk-dev] [PATCH v2] " Darek Stojaczyk
@ 2018-09-17 10:33   ` Burakov, Anatoly
  2018-09-17 13:06     ` Stojaczyk, Dariusz
  2018-10-28 23:11     ` Thomas Monjalon
  0 siblings, 2 replies; 7+ messages in thread
From: Burakov, Anatoly @ 2018-09-17 10:33 UTC (permalink / raw)
  To: Darek Stojaczyk, dev, Santosh Shukla, Hemant Agrawal, Jerin Jacob
  Cc: Maxime Coquelin, Chas Williams

On 07-Sep-18 4:58 PM, Darek Stojaczyk wrote:
> When neither RTE_IOVA_VA nor RTE_IOVA_PA was explicitly
> requested, DPDK would currently fallback to the default
> RTE_IOVA_PA mode and possibly encounter a failure later
> on if running as a non-priviledged user. Attempting to
> use RTE_IOVA_VA if no phys addresses are available may
> help in this case.
> 
> Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
> ---
> Changes since v1:
>   * added a missing rte_memory.h include
> 
>   lib/librte_eal/common/eal_common_bus.c | 19 +++++++++++++++----
>   1 file changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
> index 0943851cc..68c581b8a 100644
> --- a/lib/librte_eal/common/eal_common_bus.c
> +++ b/lib/librte_eal/common/eal_common_bus.c
> @@ -37,6 +37,7 @@
>   #include <rte_bus.h>
>   #include <rte_debug.h>
>   #include <rte_string_fns.h>
> +#include <rte_memory.h>
>   
>   #include "eal_private.h"
>   
> @@ -236,9 +237,19 @@ rte_bus_get_iommu_class(void)
>   			mode |= bus->get_iommu_class();
>   	}
>   
> -	if (mode != RTE_IOVA_VA) {
> -		/* Use default IOVA mode */
> -		mode = RTE_IOVA_PA;
> +	if (mode == RTE_IOVA_VA)
> +		return RTE_IOVA_VA;
> +
> +	if (mode & RTE_IOVA_PA) {
> +		/* Not all buses support RTE_IOVA_VA, fallback to RTE_IOVA_PA */
> +		return RTE_IOVA_PA;
> +	}
> +
> +	if (rte_eal_using_phys_addrs()) {
> +		/* Default to RTE_IOVA_PA only if it's supported */
> +		return RTE_IOVA_PA;
>   	}
> -	return mode;
> +
> +	/* Since RTE_IOVA_PA is unsupported, fallback to RTE_IOVA_VA */
> +	return RTE_IOVA_VA;
>   }
> 

This is a good change, however I think that this is too pessimistic. If 
i don't have any devices that explictly require IOVA_PA, i should be 
running in IOVA_VA mode.

This of course doesn't take hotplug into account, so a command-line 
switch to force one or the other should also be available.

For example, at startup, i might have devices bound to VFIO, so IOVA_VA 
mode is picked. However, even though at a time of startup none of the 
devices require physical addresses, i also know that i might later 
hotplug a device that requires IOVA_PA (leaving the question of hotplug 
brokenness aside for now...) - currently, this scenario will not work, 
as i will be forced to use IOVA_VA mode unless i happen to have a 
IOVA_PA device available at startup.

Similarly, if i'm running DPDK as root but am only using virtual devices 
like pcap, i should be able to force DPDK into using VA addresses [*], 
yet currently i will be forced to use IOVA_PA if i don't *also* have a 
few devices bound exclusively to VFIO.

[*] Do we have vdev devices that require IOVA_PA? I can't think of any...

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v2] eal/bus: use RTE_IOVA_PA only if phys addresses are available
  2018-09-17 10:33   ` Burakov, Anatoly
@ 2018-09-17 13:06     ` Stojaczyk, Dariusz
  2018-10-30 12:58       ` Alejandro Lucero
  2018-10-28 23:11     ` Thomas Monjalon
  1 sibling, 1 reply; 7+ messages in thread
From: Stojaczyk, Dariusz @ 2018-09-17 13:06 UTC (permalink / raw)
  To: Burakov, Anatoly, dev, Santosh Shukla, Hemant Agrawal, Jerin Jacob
  Cc: Maxime Coquelin, Chas Williams



> -----Original Message-----
> From: Burakov, Anatoly
> Sent: Monday, September 17, 2018 12:34 PM
> To: Stojaczyk, Dariusz <dariusz.stojaczyk@intel.com>; dev@dpdk.org;
> Santosh Shukla <santosh.shukla@caviumnetworks.com>; Hemant Agrawal
> <hemant.agrawal@nxp.com>; Jerin Jacob
> <jerin.jacob@caviumnetworks.com>
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>; Chas Williams
> <chas3@att.com>
> Subject: Re: [PATCH v2] eal/bus: use RTE_IOVA_PA only if phys addresses
> are available
> 
> On 07-Sep-18 4:58 PM, Darek Stojaczyk wrote:
> > When neither RTE_IOVA_VA nor RTE_IOVA_PA was explicitly requested,
> > DPDK would currently fallback to the default RTE_IOVA_PA mode and
> > possibly encounter a failure later on if running as a non-priviledged
> > user. Attempting to use RTE_IOVA_VA if no phys addresses are available
> > may help in this case.
> >
> > Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
> > ---
> > Changes since v1:
> >   * added a missing rte_memory.h include
> >
> >   lib/librte_eal/common/eal_common_bus.c | 19 +++++++++++++++----
> >   1 file changed, 15 insertions(+), 4 deletions(-)
> >
> > diff --git a/lib/librte_eal/common/eal_common_bus.c
> > b/lib/librte_eal/common/eal_common_bus.c
> > index 0943851cc..68c581b8a 100644
> > --- a/lib/librte_eal/common/eal_common_bus.c
> > +++ b/lib/librte_eal/common/eal_common_bus.c
> > @@ -37,6 +37,7 @@
> >   #include <rte_bus.h>
> >   #include <rte_debug.h>
> >   #include <rte_string_fns.h>
> > +#include <rte_memory.h>
> >
> >   #include "eal_private.h"
> >
> > @@ -236,9 +237,19 @@ rte_bus_get_iommu_class(void)
> >   			mode |= bus->get_iommu_class();
> >   	}
> >
> > -	if (mode != RTE_IOVA_VA) {
> > -		/* Use default IOVA mode */
> > -		mode = RTE_IOVA_PA;
> > +	if (mode == RTE_IOVA_VA)
> > +		return RTE_IOVA_VA;
> > +
> > +	if (mode & RTE_IOVA_PA) {
> > +		/* Not all buses support RTE_IOVA_VA, fallback to
> RTE_IOVA_PA */
> > +		return RTE_IOVA_PA;
> > +	}
> > +
> > +	if (rte_eal_using_phys_addrs()) {
> > +		/* Default to RTE_IOVA_PA only if it's supported */
> > +		return RTE_IOVA_PA;
> >   	}
> > -	return mode;
> > +
> > +	/* Since RTE_IOVA_PA is unsupported, fallback to RTE_IOVA_VA */
> > +	return RTE_IOVA_VA;
> >   }
> >
> 
> This is a good change, however I think that this is too pessimistic. If i don't
> have any devices that explictly require IOVA_PA, i should be running in
> IOVA_VA mode.

Another problem may occur when trying to hotplug devices that support only 39bit DMA. You may not be able to map any memory with vfio when in RTE_IOVA_VA mode, as virtual addresses likely occupy more than 39 bits. 

The rte_pci bus enforces RTE_IOVA_PA whenever it finds such devices on init.

I have no doubt the logic can be improved here, but for now RTE_IOVA_PA is the only safe default.

D.

> 
> This of course doesn't take hotplug into account, so a command-line switch
> to force one or the other should also be available.
> 
> For example, at startup, i might have devices bound to VFIO, so IOVA_VA
> mode is picked. However, even though at a time of startup none of the
> devices require physical addresses, i also know that i might later hotplug a
> device that requires IOVA_PA (leaving the question of hotplug brokenness
> aside for now...) - currently, this scenario will not work, as i will be forced to
> use IOVA_VA mode unless i happen to have a IOVA_PA device available at
> startup.
> 
> Similarly, if i'm running DPDK as root but am only using virtual devices like
> pcap, i should be able to force DPDK into using VA addresses [*], yet
> currently i will be forced to use IOVA_PA if i don't *also* have a few devices
> bound exclusively to VFIO.
> 
> [*] Do we have vdev devices that require IOVA_PA? I can't think of any...
> 
> --
> Thanks,
> Anatoly

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v2] eal/bus: use RTE_IOVA_PA only if phys addresses are available
  2018-09-17 10:33   ` Burakov, Anatoly
  2018-09-17 13:06     ` Stojaczyk, Dariusz
@ 2018-10-28 23:11     ` Thomas Monjalon
  2018-10-30 10:25       ` Burakov, Anatoly
  1 sibling, 1 reply; 7+ messages in thread
From: Thomas Monjalon @ 2018-10-28 23:11 UTC (permalink / raw)
  To: Burakov, Anatoly, Darek Stojaczyk
  Cc: dev, Santosh Shukla, Hemant Agrawal, Jerin Jacob,
	Maxime Coquelin, Chas Williams, alejandro.lucero, arybchenko,
	ferruh.yigit, bruce.richardson

17/09/2018 12:33, Burakov, Anatoly:
> On 07-Sep-18 4:58 PM, Darek Stojaczyk wrote:
> > When neither RTE_IOVA_VA nor RTE_IOVA_PA was explicitly
> > requested, DPDK would currently fallback to the default
> > RTE_IOVA_PA mode and possibly encounter a failure later
> > on if running as a non-priviledged user. Attempting to
> > use RTE_IOVA_VA if no phys addresses are available may
> > help in this case.
> > 
> > Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
> > ---
> > Changes since v1:
> >   * added a missing rte_memory.h include
> > 
> >   lib/librte_eal/common/eal_common_bus.c | 19 +++++++++++++++----
> >   1 file changed, 15 insertions(+), 4 deletions(-)
> > 
> > diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
> > index 0943851cc..68c581b8a 100644
> > --- a/lib/librte_eal/common/eal_common_bus.c
> > +++ b/lib/librte_eal/common/eal_common_bus.c
> > @@ -37,6 +37,7 @@
> >   #include <rte_bus.h>
> >   #include <rte_debug.h>
> >   #include <rte_string_fns.h>
> > +#include <rte_memory.h>
> >   
> >   #include "eal_private.h"
> >   
> > @@ -236,9 +237,19 @@ rte_bus_get_iommu_class(void)
> >   			mode |= bus->get_iommu_class();
> >   	}
> >   
> > -	if (mode != RTE_IOVA_VA) {
> > -		/* Use default IOVA mode */
> > -		mode = RTE_IOVA_PA;
> > +	if (mode == RTE_IOVA_VA)
> > +		return RTE_IOVA_VA;
> > +
> > +	if (mode & RTE_IOVA_PA) {
> > +		/* Not all buses support RTE_IOVA_VA, fallback to RTE_IOVA_PA */
> > +		return RTE_IOVA_PA;
> > +	}
> > +
> > +	if (rte_eal_using_phys_addrs()) {
> > +		/* Default to RTE_IOVA_PA only if it's supported */
> > +		return RTE_IOVA_PA;
> >   	}
> > -	return mode;
> > +
> > +	/* Since RTE_IOVA_PA is unsupported, fallback to RTE_IOVA_VA */
> > +	return RTE_IOVA_VA;
> >   }
> > 
> 
> This is a good change, however I think that this is too pessimistic. If 
> i don't have any devices that explictly require IOVA_PA, i should be 
> running in IOVA_VA mode.
> 
> This of course doesn't take hotplug into account, so a command-line 
> switch to force one or the other should also be available.
> 
> For example, at startup, i might have devices bound to VFIO, so IOVA_VA 
> mode is picked. However, even though at a time of startup none of the 
> devices require physical addresses, i also know that i might later 
> hotplug a device that requires IOVA_PA (leaving the question of hotplug 
> brokenness aside for now...) - currently, this scenario will not work, 
> as i will be forced to use IOVA_VA mode unless i happen to have a 
> IOVA_PA device available at startup.
> 
> Similarly, if i'm running DPDK as root but am only using virtual devices 
> like pcap, i should be able to force DPDK into using VA addresses [*], 
> yet currently i will be forced to use IOVA_PA if i don't *also* have a 
> few devices bound exclusively to VFIO.
> 
> [*] Do we have vdev devices that require IOVA_PA? I can't think of any...

If running as root, what is the benefit of using virtual addresses?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v2] eal/bus: use RTE_IOVA_PA only if phys addresses are available
  2018-10-28 23:11     ` Thomas Monjalon
@ 2018-10-30 10:25       ` Burakov, Anatoly
  0 siblings, 0 replies; 7+ messages in thread
From: Burakov, Anatoly @ 2018-10-30 10:25 UTC (permalink / raw)
  To: Thomas Monjalon, Darek Stojaczyk
  Cc: dev, Santosh Shukla, Hemant Agrawal, Jerin Jacob,
	Maxime Coquelin, Chas Williams, alejandro.lucero, arybchenko,
	ferruh.yigit, bruce.richardson

On 28-Oct-18 11:11 PM, Thomas Monjalon wrote:
> 17/09/2018 12:33, Burakov, Anatoly:
>> On 07-Sep-18 4:58 PM, Darek Stojaczyk wrote:
>>> When neither RTE_IOVA_VA nor RTE_IOVA_PA was explicitly
>>> requested, DPDK would currently fallback to the default
>>> RTE_IOVA_PA mode and possibly encounter a failure later
>>> on if running as a non-priviledged user. Attempting to
>>> use RTE_IOVA_VA if no phys addresses are available may
>>> help in this case.
>>>
>>> Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
>>> ---
>>> Changes since v1:
>>>    * added a missing rte_memory.h include
>>>
>>>    lib/librte_eal/common/eal_common_bus.c | 19 +++++++++++++++----
>>>    1 file changed, 15 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c
>>> index 0943851cc..68c581b8a 100644
>>> --- a/lib/librte_eal/common/eal_common_bus.c
>>> +++ b/lib/librte_eal/common/eal_common_bus.c
>>> @@ -37,6 +37,7 @@
>>>    #include <rte_bus.h>
>>>    #include <rte_debug.h>
>>>    #include <rte_string_fns.h>
>>> +#include <rte_memory.h>
>>>    
>>>    #include "eal_private.h"
>>>    
>>> @@ -236,9 +237,19 @@ rte_bus_get_iommu_class(void)
>>>    			mode |= bus->get_iommu_class();
>>>    	}
>>>    
>>> -	if (mode != RTE_IOVA_VA) {
>>> -		/* Use default IOVA mode */
>>> -		mode = RTE_IOVA_PA;
>>> +	if (mode == RTE_IOVA_VA)
>>> +		return RTE_IOVA_VA;
>>> +
>>> +	if (mode & RTE_IOVA_PA) {
>>> +		/* Not all buses support RTE_IOVA_VA, fallback to RTE_IOVA_PA */
>>> +		return RTE_IOVA_PA;
>>> +	}
>>> +
>>> +	if (rte_eal_using_phys_addrs()) {
>>> +		/* Default to RTE_IOVA_PA only if it's supported */
>>> +		return RTE_IOVA_PA;
>>>    	}
>>> -	return mode;
>>> +
>>> +	/* Since RTE_IOVA_PA is unsupported, fallback to RTE_IOVA_VA */
>>> +	return RTE_IOVA_VA;
>>>    }
>>>
>>
>> This is a good change, however I think that this is too pessimistic. If
>> i don't have any devices that explictly require IOVA_PA, i should be
>> running in IOVA_VA mode.
>>
>> This of course doesn't take hotplug into account, so a command-line
>> switch to force one or the other should also be available.
>>
>> For example, at startup, i might have devices bound to VFIO, so IOVA_VA
>> mode is picked. However, even though at a time of startup none of the
>> devices require physical addresses, i also know that i might later
>> hotplug a device that requires IOVA_PA (leaving the question of hotplug
>> brokenness aside for now...) - currently, this scenario will not work,
>> as i will be forced to use IOVA_VA mode unless i happen to have a
>> IOVA_PA device available at startup.
>>
>> Similarly, if i'm running DPDK as root but am only using virtual devices
>> like pcap, i should be able to force DPDK into using VA addresses [*],
>> yet currently i will be forced to use IOVA_PA if i don't *also* have a
>> few devices bound exclusively to VFIO.
>>
>> [*] Do we have vdev devices that require IOVA_PA? I can't think of any...
> 
> If running as root, what is the benefit of using virtual addresses?
> 

Contiguous memory addresses is one that comes to mind.

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH v2] eal/bus: use RTE_IOVA_PA only if phys addresses are available
  2018-09-17 13:06     ` Stojaczyk, Dariusz
@ 2018-10-30 12:58       ` Alejandro Lucero
  0 siblings, 0 replies; 7+ messages in thread
From: Alejandro Lucero @ 2018-10-30 12:58 UTC (permalink / raw)
  To: dariusz.stojaczyk
  Cc: Burakov, Anatoly, dev, Santosh Shukla, Hemant Agrawal,
	Jerin Jacob, Maxime Coquelin, chas3

On Mon, Sep 17, 2018 at 2:06 PM Stojaczyk, Dariusz <
dariusz.stojaczyk@intel.com> wrote:

>
>
> > -----Original Message-----
> > From: Burakov, Anatoly
> > Sent: Monday, September 17, 2018 12:34 PM
> > To: Stojaczyk, Dariusz <dariusz.stojaczyk@intel.com>; dev@dpdk.org;
> > Santosh Shukla <santosh.shukla@caviumnetworks.com>; Hemant Agrawal
> > <hemant.agrawal@nxp.com>; Jerin Jacob
> > <jerin.jacob@caviumnetworks.com>
> > Cc: Maxime Coquelin <maxime.coquelin@redhat.com>; Chas Williams
> > <chas3@att.com>
> > Subject: Re: [PATCH v2] eal/bus: use RTE_IOVA_PA only if phys addresses
> > are available
> >
> > On 07-Sep-18 4:58 PM, Darek Stojaczyk wrote:
> > > When neither RTE_IOVA_VA nor RTE_IOVA_PA was explicitly requested,
> > > DPDK would currently fallback to the default RTE_IOVA_PA mode and
> > > possibly encounter a failure later on if running as a non-priviledged
> > > user. Attempting to use RTE_IOVA_VA if no phys addresses are available
> > > may help in this case.
> > >
> > > Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
> > > ---
> > > Changes since v1:
> > >   * added a missing rte_memory.h include
> > >
> > >   lib/librte_eal/common/eal_common_bus.c | 19 +++++++++++++++----
> > >   1 file changed, 15 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/lib/librte_eal/common/eal_common_bus.c
> > > b/lib/librte_eal/common/eal_common_bus.c
> > > index 0943851cc..68c581b8a 100644
> > > --- a/lib/librte_eal/common/eal_common_bus.c
> > > +++ b/lib/librte_eal/common/eal_common_bus.c
> > > @@ -37,6 +37,7 @@
> > >   #include <rte_bus.h>
> > >   #include <rte_debug.h>
> > >   #include <rte_string_fns.h>
> > > +#include <rte_memory.h>
> > >
> > >   #include "eal_private.h"
> > >
> > > @@ -236,9 +237,19 @@ rte_bus_get_iommu_class(void)
> > >                     mode |= bus->get_iommu_class();
> > >     }
> > >
> > > -   if (mode != RTE_IOVA_VA) {
> > > -           /* Use default IOVA mode */
> > > -           mode = RTE_IOVA_PA;
> > > +   if (mode == RTE_IOVA_VA)
> > > +           return RTE_IOVA_VA;
> > > +
> > > +   if (mode & RTE_IOVA_PA) {
> > > +           /* Not all buses support RTE_IOVA_VA, fallback to
> > RTE_IOVA_PA */
> > > +           return RTE_IOVA_PA;
> > > +   }
> > > +
> > > +   if (rte_eal_using_phys_addrs()) {
> > > +           /* Default to RTE_IOVA_PA only if it's supported */
> > > +           return RTE_IOVA_PA;
> > >     }
> > > -   return mode;
> > > +
> > > +   /* Since RTE_IOVA_PA is unsupported, fallback to RTE_IOVA_VA */
> > > +   return RTE_IOVA_VA;
> > >   }
> > >
> >
> > This is a good change, however I think that this is too pessimistic. If
> i don't
> > have any devices that explictly require IOVA_PA, i should be running in
> > IOVA_VA mode.
>
> Another problem may occur when trying to hotplug devices that support only
> 39bit DMA. You may not be able to map any memory with vfio when in
> RTE_IOVA_VA mode, as virtual addresses likely occupy more than 39 bits.
>
>
There is now a hint for trying to map memory as low as possible instead of
using default Linux mmap base address. This makes devices with addressing
limitations being usable as long as the physical memory to map is not more
than what those devices allow.



> The rte_pci bus enforces RTE_IOVA_PA whenever it finds such devices on
> init.
>
> I have no doubt the logic can be improved here, but for now RTE_IOVA_PA is
> the only safe default.
>
> D.
>
> >
> > This of course doesn't take hotplug into account, so a command-line
> switch
> > to force one or the other should also be available.
> >
> > For example, at startup, i might have devices bound to VFIO, so IOVA_VA
> > mode is picked. However, even though at a time of startup none of the
> > devices require physical addresses, i also know that i might later
> hotplug a
> > device that requires IOVA_PA (leaving the question of hotplug brokenness
> > aside for now...) - currently, this scenario will not work, as i will be
> forced to
> > use IOVA_VA mode unless i happen to have a IOVA_PA device available at
> > startup.
> >
> > Similarly, if i'm running DPDK as root but am only using virtual devices
> like
> > pcap, i should be able to force DPDK into using VA addresses [*], yet
> > currently i will be forced to use IOVA_PA if i don't *also* have a few
> devices
> > bound exclusively to VFIO.
> >
> > [*] Do we have vdev devices that require IOVA_PA? I can't think of any...
> >
> > --
> > Thanks,
> > Anatoly
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-10-30 12:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-07 15:47 [dpdk-dev] [PATCH] eal/bus: use RTE_IOVA_PA only if phys addresses are available Darek Stojaczyk
2018-09-07 15:58 ` [dpdk-dev] [PATCH v2] " Darek Stojaczyk
2018-09-17 10:33   ` Burakov, Anatoly
2018-09-17 13:06     ` Stojaczyk, Dariusz
2018-10-30 12:58       ` Alejandro Lucero
2018-10-28 23:11     ` Thomas Monjalon
2018-10-30 10:25       ` Burakov, Anatoly

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).