On 04-Nov-19 10:25 AM, Burakov, Anatoly wrote:
On 30-Oct-19 7:50 PM, Rajesh Ravi wrote:
Thanks Anatoly.
Please find inline below:
[Anatoly] vfio_mem_event_callback() is called every time memory is
added to a
heap. That includes internal and external memory
[Rajesh] malloc_heap_add_external_memory() does call
eal_memalloc_mem_event_notify [ instead of vfio_mem_event_callback() ]
But, no callback function is getting called from inside
eal_memalloc_mem_event_notify()
execution flow is not entering inside following loop:
/TAILQ_FOREACH(entry, &mem_event_callback_list, next) {/
/ RTE_LOG(DEBUG, EAL, "Calling mem event callback
'%s:%p'\n",
entry->name, entry->arg);
entry->clb(event, start, len, entry->arg);
}/
Do you mean to say, we are supposed to explicitly register a callback
which separately builds iommu tables in addition to calling
rte_malloc_heap_memory_add() API?
Hi,
No, the callback in VFIO should be registered automatically [1] at EAL
initialization (or, more precisely, when default container is
initialized). Does that not happen in your case?
[1] http://git.dpdk.org/dpdk/tree/lib/librte_eal/linux/eal/eal_vfio.c#n791
Hi Rajesh,
I think i figured it out. It is a defect in design of how external
memory heaps are handled.
When VFIO initializes, it will find first VFIO-bound device, initialize
the container, and set up DMA mappings. Then, you can add more memory
through creating custom memory regions without adding them to heap
(mmap() + rte_extmem_register() + rte_dev_dma_map()), or with adding
them to heap (mmap() + rte_malloc_heap_add_memory()).
The problem is, memory registered through rte_dev_dma_map() will get
added into a list of user maps, while heap memory will not - the
assumption is that the DMA mapping will happen through the callback, but
there is no record left anywhere that this memory is supposed to be mapped.
This makes it so that, if there are no VFIO-bound devices at startup,
then you create a heap, and *then* you hotplug a device, the heap will
not be mapped because (as you have correctly pointed out) type1_map()
skips it, and it's not present in a list of user mem maps either,
because it is heap memory, so EAL is supposed to handle it by itself and
not through user map list.
There could be two fixes here. The easiest one is to just add another
flag to the memseglist - that will work for 19.11, and that's what i
intend on doing since we're breaking ABI anyway.
For older releases, a different approach would be required (i think
scanning heaps is best we can do here) in order to keep the ABI and not
introduce new stuff into rte_memseg_list.
I'll submit a patch shortly, it would be great if you could test it.
--
Thanks,
Anatoly