util: make spdk_io_channel_get_ctx() inline
This requires exposing struct spdk_io_channel in the public header - mark it as internal with Doxygen comments to make it extra clear that applications should not use the data structure directly. This is a very hot function in the main I/O path, so making this function inline has a significant performance benefit. A bdevperf microbenchmark using null bdevs shows a 11% improvement. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I70e30e184000705704bb004e8da1c7476a6aceeb Reviewed-on: https://review.gerrithub.io/393824 Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
5b9b47fae5
commit
fb8acd90aa
@ -47,7 +47,6 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
struct spdk_thread;
|
||||
struct spdk_io_channel;
|
||||
struct spdk_io_channel_iter;
|
||||
struct spdk_poller;
|
||||
|
||||
@ -70,6 +69,30 @@ typedef void (*spdk_io_device_unregister_cb)(void *io_device);
|
||||
typedef void (*spdk_channel_msg)(struct spdk_io_channel_iter *i);
|
||||
typedef void (*spdk_channel_for_each_cpl)(struct spdk_io_channel_iter *i, int status);
|
||||
|
||||
/**
|
||||
* \brief Represents a per-thread channel for accessing an I/O device.
|
||||
*
|
||||
* An I/O device may be a physical entity (i.e. NVMe controller) or a software
|
||||
* entity (i.e. a blobstore).
|
||||
*
|
||||
* This structure is not part of the API - all accesses should be done through
|
||||
* spdk_io_channel function calls.
|
||||
*/
|
||||
struct spdk_io_channel {
|
||||
struct spdk_thread *thread;
|
||||
struct io_device *dev;
|
||||
uint32_t ref;
|
||||
TAILQ_ENTRY(spdk_io_channel) tailq;
|
||||
spdk_io_channel_destroy_cb destroy_cb;
|
||||
|
||||
/*
|
||||
* Modules will allocate extra memory off the end of this structure
|
||||
* to store references to hardware-specific references (i.e. NVMe queue
|
||||
* pairs, or references to child device spdk_io_channels (i.e.
|
||||
* virtual bdevs).
|
||||
*/
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Initializes the calling thread for I/O channel allocation.
|
||||
*
|
||||
@ -198,7 +221,11 @@ void spdk_put_io_channel(struct spdk_io_channel *ch);
|
||||
/**
|
||||
* \brief Returns the context buffer associated with an I/O channel.
|
||||
*/
|
||||
void *spdk_io_channel_get_ctx(struct spdk_io_channel *ch);
|
||||
static inline void *
|
||||
spdk_io_channel_get_ctx(struct spdk_io_channel *ch)
|
||||
{
|
||||
return (uint8_t *)ch + sizeof(*ch);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Returns an I/O channel from a context buffer. This is
|
||||
|
@ -60,21 +60,6 @@ struct io_device {
|
||||
|
||||
static TAILQ_HEAD(, io_device) g_io_devices = TAILQ_HEAD_INITIALIZER(g_io_devices);
|
||||
|
||||
struct spdk_io_channel {
|
||||
struct spdk_thread *thread;
|
||||
struct io_device *dev;
|
||||
uint32_t ref;
|
||||
TAILQ_ENTRY(spdk_io_channel) tailq;
|
||||
spdk_io_channel_destroy_cb destroy_cb;
|
||||
|
||||
/*
|
||||
* Modules will allocate extra memory off the end of this structure
|
||||
* to store references to hardware-specific references (i.e. NVMe queue
|
||||
* pairs, or references to child device spdk_io_channels (i.e.
|
||||
* virtual bdevs).
|
||||
*/
|
||||
};
|
||||
|
||||
struct spdk_thread {
|
||||
pthread_t thread_id;
|
||||
spdk_thread_pass_msg msg_fn;
|
||||
@ -496,12 +481,6 @@ spdk_put_io_channel(struct spdk_io_channel *ch)
|
||||
spdk_thread_send_msg(ch->thread, _spdk_put_io_channel, ch);
|
||||
}
|
||||
|
||||
void *
|
||||
spdk_io_channel_get_ctx(struct spdk_io_channel *ch)
|
||||
{
|
||||
return (uint8_t *)ch + sizeof(*ch);
|
||||
}
|
||||
|
||||
struct spdk_io_channel *
|
||||
spdk_io_channel_from_ctx(void *ctx)
|
||||
{
|
||||
|
@ -37,9 +37,7 @@
|
||||
uint8_t *g_dev_buffer;
|
||||
|
||||
/* Define here for UT only. */
|
||||
struct spdk_io_channel {
|
||||
struct spdk_thread *thread;
|
||||
} g_io_channel;
|
||||
struct spdk_io_channel g_io_channel;
|
||||
|
||||
static struct spdk_io_channel *
|
||||
dev_create_channel(struct spdk_bs_dev *dev)
|
||||
|
@ -45,14 +45,6 @@ struct spdk_conf_section {
|
||||
struct spdk_conf_item *item;
|
||||
};
|
||||
|
||||
struct spdk_io_channel {
|
||||
struct spdk_thread *thread;
|
||||
struct io_device *dev;
|
||||
uint32_t ref;
|
||||
TAILQ_ENTRY(spdk_io_channel) tailq;
|
||||
spdk_io_channel_destroy_cb destroy_cb;
|
||||
};
|
||||
|
||||
DEFINE_STUB(spdk_ring_enqueue, size_t, (struct spdk_ring *ring, void **objs, size_t count), 0);
|
||||
DEFINE_STUB(spdk_ring_dequeue, size_t, (struct spdk_ring *ring, void **objs, size_t count), 0);
|
||||
DEFINE_STUB(spdk_vhost_vq_get_desc, int, (struct spdk_vhost_dev *vdev,
|
||||
|
Loading…
x
Reference in New Issue
Block a user