nvme: only invoke request free macro in one place

Rename the nvme_free_request macro to nvme_dealloc_request to match
nvme_alloc_request and add a wrapper function to nvme.c so that the
macro contents are only expanded once.

The DPDK nvme_impl.h uses rte_mempool_put(), which generates a large
amount of code inline.  Moving this macro expansion to a wrapper
function avoids inlining it in the multiple places nvme_free_request()
gets called, most of which are error handling cases that are not in the
hot I/O path.

Change-Id: I64ea9c39ba47e26672eee8d5058f1489e07eee5b
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2015-10-19 17:03:04 -07:00
parent 38997df85d
commit 4f677a1d4c
5 changed files with 16 additions and 2 deletions

View File

@ -159,6 +159,13 @@ nvme_allocate_request(void *payload, uint32_t payload_size,
return req;
}
void
nvme_free_request(struct nvme_request *req)
{
nvme_assert(req != NULL, ("nvme_free_request(NULL)\n"));
nvme_dealloc_request(req);
}
static int
nvme_allocate_ioq_index(void)
{

View File

@ -111,7 +111,7 @@ extern struct rte_mempool *request_mempool;
/**
* Free a buffer previously allocated with nvme_alloc_request().
*/
#define nvme_free_request(buf) rte_mempool_put(request_mempool, buf)
#define nvme_dealloc_request(buf) rte_mempool_put(request_mempool, buf)
/**
*

View File

@ -432,5 +432,6 @@ void nvme_ns_destruct(struct nvme_namespace *ns);
struct nvme_request *
nvme_allocate_request(void *payload, uint32_t payload_size,
nvme_cb_fn_t cb_fn, void *cb_arg);
void nvme_free_request(struct nvme_request *req);
#endif /* __NVME_INTERNAL_H__ */

View File

@ -72,7 +72,7 @@ do \
} \
while (0)
#define nvme_free_request(buf) free(buf)
#define nvme_dealloc_request(buf) free(buf)
#define nvme_pcicfg_read32(handle, var, offset) do { *(var) = 0xFFFFFFFFu; } while (0)
#define nvme_pcicfg_write32(handle, var, offset) do { (void)(var); } while (0)

View File

@ -101,6 +101,12 @@ nvme_allocate_request(void *payload, uint32_t payload_size,
return req;
}
void
nvme_free_request(struct nvme_request *req)
{
nvme_dealloc_request(req);
}
void
test1(void)
{