> -----Original Message----- > From: Thomas Monjalon <tho...@monjalon.net> > Sent: Saturday, June 5, 2021 15:49 > To: Wang, Haiyue <haiyue.w...@intel.com> > Cc: dev@dpdk.org; Elena Agostini <eagost...@nvidia.com>; > andrew.rybche...@oktetlabs.ru; Yigit, Ferruh > <ferruh.yi...@intel.com>; jer...@marvell.com > Subject: Re: [dpdk-dev] [PATCH] gpudev: introduce memory API > > 04/06/2021 20:04, Wang, Haiyue: > > From: Thomas Monjalon <tho...@monjalon.net> > > > 04/06/2021 15:25, Wang, Haiyue: > > > > From: Thomas Monjalon <tho...@monjalon.net> > > > > > Another question is about the function rte_gpu_free(). > > > > > How do we recognize that a memory chunk is from the CPU and GPU > > > > > visible, > > > > > or just from GPU? > > > > > > > > > > > > > I didn't find the rte_gpu_free_visible definition, and the > > > > rte_gpu_free's > > > > comment just says: deallocate a chunk of memory allocated with > > > > rte_gpu_malloc* > > > > > > > > Looks like the rte_gpu_free can handle this case ? > > > > > > This is the proposal, yes. > > > > > > > And from the definition "rte_gpu_free(uint16_t gpu_id, void *ptr)", the > > > > free needs to check whether this memory belong to the GPU or not, so it > > > > also can recognize the memory type, I think. > > > > > > Yes that's the idea behind having a single free function. > > > We could have some metadata in front of the memory chunk. > > > My question is to confirm whether it is a good design or not, > > > and whether it should be driver specific or have a common struct in the > > > lib. > > > > > > Opinions? > > > > > > > Make the GPU memory to be registered into the common lib API with the > > metadata > > like address, size etc, and also some GPU specific callbacks like to handle > > how > > to make GPU memory visible to CPU ? > > > > And the memory register can be like the exist external memory function: > > > > int > > rte_extmem_register(void *va_addr, size_t len, rte_iova_t iova_addrs[], > > unsigned int n_pages, size_t page_sz) > > How do you specify the device ID
I mean that take the current external memory register as an example, it is not a real proto-type. The GPU memory management library can provide the this kind of API for GPU driver to register its memory at probe time or start time ? > I may have missed something. > >