mem: clarify documentation for rte_mem_virt2iova

Message ID 9ac0f4b480cec8cbe8a9910a68f9d564641c2f41.1573740779.git.anatoly.burakov@intel.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series mem: clarify documentation for rte_mem_virt2iova |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-compilation success Compile Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot warning Travis build: failed

Commit Message

Burakov, Anatoly Nov. 14, 2019, 2:13 p.m. UTC
  It may not be immediately clear that rte_mem_virt2iova does not actually
check the internal memseg table, and will instead either return VA (in
IOVA as VA mode), or will fall back to kernel page table walk (in IOVA
as PA mode).

Add a note to API documentation indicating the above.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/include/rte_memory.h | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Olivier Matz Nov. 18, 2019, 1:14 p.m. UTC | #1
On Thu, Nov 14, 2019 at 02:13:06PM +0000, Anatoly Burakov wrote:
> It may not be immediately clear that rte_mem_virt2iova does not actually
> check the internal memseg table, and will instead either return VA (in
> IOVA as VA mode), or will fall back to kernel page table walk (in IOVA
> as PA mode).
> 
> Add a note to API documentation indicating the above.
> 
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>

Reviewed-by: Olivier Matz <olivier.matz@6wind.com>
  
Thomas Monjalon Nov. 25, 2019, 11:32 p.m. UTC | #2
18/11/2019 14:14, Olivier Matz:
> On Thu, Nov 14, 2019 at 02:13:06PM +0000, Anatoly Burakov wrote:
> > It may not be immediately clear that rte_mem_virt2iova does not actually
> > check the internal memseg table, and will instead either return VA (in
> > IOVA as VA mode), or will fall back to kernel page table walk (in IOVA
> > as PA mode).
> > 
> > Add a note to API documentation indicating the above.
> > 
> > Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> 
> Reviewed-by: Olivier Matz <olivier.matz@6wind.com>

Applied, thanks
  
Burakov, Anatoly Nov. 26, 2019, 12:54 p.m. UTC | #3
On 25-Nov-19 11:32 PM, Thomas Monjalon wrote:
> 18/11/2019 14:14, Olivier Matz:
>> On Thu, Nov 14, 2019 at 02:13:06PM +0000, Anatoly Burakov wrote:
>>> It may not be immediately clear that rte_mem_virt2iova does not actually
>>> check the internal memseg table, and will instead either return VA (in
>>> IOVA as VA mode), or will fall back to kernel page table walk (in IOVA
>>> as PA mode).
>>>
>>> Add a note to API documentation indicating the above.
>>>
>>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
>>
>> Reviewed-by: Olivier Matz <olivier.matz@6wind.com>
> 
> Applied, thanks
> 

There are multiple places where this function is used, and its use is 
not compatible with external memory. I think we should replace all 
usages of this function to rte_mem_virt2memseg(), and rename this 
function, because its actual intended usage is *not* VA->IOVA 
translation, but instead is akin to figuring out what IOVA address 
*should* be with current IOVA settings, regardless of any internal page 
table and current VFIO mappings.
  

Patch

diff --git a/lib/librte_eal/common/include/rte_memory.h b/lib/librte_eal/common/include/rte_memory.h
index bf81a2faa8..3d8d0bd697 100644
--- a/lib/librte_eal/common/include/rte_memory.h
+++ b/lib/librte_eal/common/include/rte_memory.h
@@ -110,6 +110,11 @@  phys_addr_t rte_mem_virt2phy(const void *virt);
 /**
  * Get IO virtual address of any mapped virtual address in the current process.
  *
+ * @note This function will not check internal page table. Instead, in IOVA as
+ *       PA mode, it will fall back to getting real physical address (which may
+ *       not match the expected IOVA, such as what was specified for external
+ *       memory).
+ *
  * @param virt
  *   The virtual address.
  * @return