Hi John,
The new API is intended to allow memory that is shared and not DMA-able, so spdk_dma_malloc() wouldn’t be an appropriate name; also, we did not want to break public API by adding a new flags
parameter to the existing function. We intend to update the internal SPDK callers of spdk_dma_malloc() to all use spdk_malloc() with the appropriate flags (leaving the old names for backwards compatibility for now).
If the user passes flags == 0 to the new spdk_malloc() call, this could be implemented by malloc() or equivalent behind the scenes, since the memory does not need to be DMA-able or shared across
multi-process boundaries (it has no special properties). Does this suffice for your use case?
Thanks,
-- Daniel
From: SPDK [mailto:spdk-bounces@lists.01.org]
On Behalf Of Meneghini, John
Sent: Thursday, May 3, 2018 10:53 AM
To: Harris, James R <james.r.harris@intel.com>; Walker, Benjamin <benjamin.walker@intel.com>; z.khatami88@gmail.com; Storage Performance Development Kit <spdk@lists.01.org>
Cc: Meneghini, John <John.Meneghini@netapp.com>
Subject: [SPDK] spdk_malloc vs. malloc
Hi Jim, Ben, and Zahra.
I am sorry I didn’t catch this during the code review, but it’s really hard to keep track of all of the changes that are going on.
https://review.gerrithub.io/#/c/spdk/spdk/+/402334/
As you may recall, we wanted to use spdk_malloc and spdk_calloc to abstract the POSIX malloc and calloc calls. This is still an issue in multiple places as we want a non-blocking malloc and calloc call that
returns a status rather than setting errno (e.g. to ENOMEM). Remember, not all execution environments support errno.
Can we revert change a77cd3f7, and use the spdk_malloc/calloc/free api for that purpose?
Also, I don’t see the point of introducing an additional API for dma-able memory. We went through this once before.
* a77cd3f7 2018-04-24 env: add malloc variants with DMA/shareable flags [ Ben Walker /
z.khatami88@gmail.com ]
* 8a44220b 2017-05-31 env: Rename spdk_malloc/zmalloc/realloc/free to spdk_dma_(func) [ Jim Harris /
johnm@netapp.com ]
I fully support adding the SPDK_MALLOC_DMA and SPDK_MALLOC_SHARE flag and socket_id to spdk_dma_malloc/zmalloc(), and I prefer to do this rather than invent a new API for allocating dma-able memory.
void *spdk_dma_malloc(size_t size, size_t align, uint64_t *phys_addr);
void *spdk_malloc(size_t size, size_t align, uint64_t *phys_addr, int socket_id, uint32_t flags);
I’m proposing:
void *spdk_dma_malloc(size_t size, size_t align, uint64_t *phys_addr, int socket_id, uint32_t flags);
/John
P.S. What I really need is a filter that allows me to watch all of the headers in include/spdk/{api}.h. Looking at the GerritHub documentation, I see no way to do this. It appears all I can do is watch the
master branch.
https://review.gerrithub.io/Documentation/intro-user.html#watch