Replace rte_get_tsc calls with spdk_get_ticks

Change-Id: I809b900321433693ff9f2498183ad0dcdbb15030
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Ben Walker 2016-08-18 12:52:48 -07:00
parent 2224ff2162
commit 0aa2986475
16 changed files with 63 additions and 72 deletions

View File

@ -39,7 +39,6 @@
#include <rte_config.h>
#include <rte_eal.h>
#include <rte_lcore.h>
#include <rte_cycles.h>
#include <rte_mempool.h>
#include "spdk/ioat.h"
@ -298,11 +297,11 @@ work_fn(void *arg)
return 1;
}
tsc_end = rte_get_timer_cycles() + g_user_config.time_in_sec * rte_get_timer_hz();
tsc_end = spdk_get_ticks() + g_user_config.time_in_sec * spdk_get_ticks_hz();
// begin to submit transfers
submit_xfers(t, g_user_config.queue_depth);
while (rte_get_timer_cycles() < tsc_end) {
while (spdk_get_ticks() < tsc_end) {
spdk_ioat_process_events(t->chan);
}

View File

@ -39,7 +39,6 @@
#include <rte_config.h>
#include <rte_lcore.h>
#include <rte_eal.h>
#include <rte_cycles.h>
#include <rte_mempool.h>
#include "spdk/ioat.h"
@ -348,10 +347,10 @@ work_fn(void *arg)
return 1;
}
tsc_end = rte_get_timer_cycles() + g_user_config.time_in_sec * rte_get_timer_hz();
tsc_end = spdk_get_ticks() + g_user_config.time_in_sec * spdk_get_ticks_hz();
submit_xfers(t, g_user_config.queue_depth);
while (rte_get_timer_cycles() < tsc_end) {
while (spdk_get_ticks() < tsc_end) {
spdk_ioat_process_events(t->chan);
}

View File

@ -37,7 +37,6 @@
#include <unistd.h>
#include <rte_config.h>
#include <rte_cycles.h>
#include <rte_mempool.h>
#include <rte_lcore.h>
@ -461,7 +460,7 @@ work_fn(void *arg)
ns_ctx = ns_ctx->next;
}
tsc_end = rte_get_timer_cycles() + g_arbitration.time_in_sec * g_arbitration.tsc_rate;
tsc_end = spdk_get_ticks() + g_arbitration.time_in_sec * g_arbitration.tsc_rate;
/* Submit initial I/O for each namespace. */
ns_ctx = worker->ns_ctx;
@ -483,7 +482,7 @@ work_fn(void *arg)
ns_ctx = ns_ctx->next;
}
if (rte_get_timer_cycles() > tsc_end) {
if (spdk_get_ticks() > tsc_end) {
break;
}
}
@ -1133,7 +1132,7 @@ main(int argc, char **argv)
64, 0, NULL, NULL, task_ctor, NULL,
SOCKET_ID_ANY, 0);
g_arbitration.tsc_rate = rte_get_timer_hz();
g_arbitration.tsc_rate = spdk_get_ticks_hz();
if (register_workers() != 0) {
return 1;

View File

@ -37,7 +37,6 @@
#include <unistd.h>
#include <rte_config.h>
#include <rte_cycles.h>
#include <rte_mempool.h>
#include <rte_lcore.h>
@ -423,7 +422,7 @@ submit_single_io(struct ns_worker_ctx *ns_ctx)
}
}
task->submit_tsc = rte_get_timer_cycles();
task->submit_tsc = spdk_get_ticks();
if ((g_rw_percentage == 100) ||
(g_rw_percentage != 0 && ((rand_r(&seed) % 100) < g_rw_percentage))) {
@ -468,7 +467,7 @@ task_complete(struct perf_task *task)
ns_ctx = task->ns_ctx;
ns_ctx->current_queue_depth--;
ns_ctx->io_completed++;
tsc_diff = rte_get_timer_cycles() - task->submit_tsc;
tsc_diff = spdk_get_ticks() - task->submit_tsc;
ns_ctx->total_tsc += tsc_diff;
if (ns_ctx->min_tsc > tsc_diff) {
ns_ctx->min_tsc = tsc_diff;
@ -589,7 +588,7 @@ work_fn(void *arg)
ns_ctx = ns_ctx->next;
}
tsc_end = rte_get_timer_cycles() + g_time_in_sec * g_tsc_rate;
tsc_end = spdk_get_ticks() + g_time_in_sec * g_tsc_rate;
/* Submit initial I/O for each namespace. */
ns_ctx = worker->ns_ctx;
@ -610,7 +609,7 @@ work_fn(void *arg)
ns_ctx = ns_ctx->next;
}
if (rte_get_timer_cycles() > tsc_end) {
if (spdk_get_ticks() > tsc_end) {
break;
}
}
@ -1113,7 +1112,7 @@ int main(int argc, char **argv)
64, 0, NULL, NULL, task_ctor, NULL,
SOCKET_ID_ANY, 0);
g_tsc_rate = rte_get_timer_hz();
g_tsc_rate = spdk_get_ticks_hz();
if (register_workers() != 0) {
rc = -1;

View File

@ -48,7 +48,6 @@
#endif
#include <rte_config.h>
#include <rte_cycles.h>
#include <rte_mempool.h>
#include <rte_ring.h>
@ -56,6 +55,7 @@
#include "spdk/log.h"
#include "spdk/io_channel.h"
#include "spdk/env.h"
#define SPDK_MAX_SOCKET 64
@ -341,14 +341,14 @@ _spdk_reactor_run(void *arg)
set_reactor_thread_name();
SPDK_NOTICELOG("Reactor started on core 0x%x\n", rte_lcore_id());
spin_cycles = SPDK_REACTOR_SPIN_TIME_US * rte_get_timer_hz() / 1000000ULL;
sleep_cycles = reactor->max_delay_us * rte_get_timer_hz() / 1000000ULL;
last_action = rte_get_timer_cycles();
spin_cycles = SPDK_REACTOR_SPIN_TIME_US * spdk_get_ticks_hz() / 1000000ULL;
sleep_cycles = reactor->max_delay_us * spdk_get_ticks_hz() / 1000000ULL;
last_action = spdk_get_ticks();
while (1) {
event_count = spdk_event_queue_run_all(rte_lcore_id());
if (event_count > 0) {
last_action = rte_get_timer_cycles();
last_action = spdk_get_ticks();
}
poller = TAILQ_FIRST(&reactor->active_pollers);
@ -362,12 +362,12 @@ _spdk_reactor_run(void *arg)
poller->state = SPDK_POLLER_STATE_WAITING;
TAILQ_INSERT_TAIL(&reactor->active_pollers, poller, tailq);
}
last_action = rte_get_timer_cycles();
last_action = spdk_get_ticks();
}
poller = TAILQ_FIRST(&reactor->timer_pollers);
if (poller) {
now = rte_get_timer_cycles();
now = spdk_get_ticks();
if (now >= poller->next_run_tick) {
TAILQ_REMOVE(&reactor->timer_pollers, poller, tailq);
@ -384,7 +384,7 @@ _spdk_reactor_run(void *arg)
/* Determine if the thread can sleep */
if (sleep_cycles > 0) {
now = rte_get_timer_cycles();
now = spdk_get_ticks();
if (now >= (last_action + spin_cycles)) {
sleep_us = reactor->max_delay_us;
@ -396,7 +396,7 @@ _spdk_reactor_run(void *arg)
if (poller->next_run_tick <= now) {
sleep_us = 0;
} else {
sleep_us = ((poller->next_run_tick - now) * 1000000ULL) / rte_get_timer_hz();
sleep_us = ((poller->next_run_tick - now) * 1000000ULL) / spdk_get_ticks_hz();
}
}
}
@ -668,7 +668,7 @@ _spdk_event_add_poller(spdk_event_t event)
struct spdk_event *next = spdk_event_get_next(event);
if (poller->period_ticks) {
spdk_poller_insert_timer(reactor, poller, rte_get_timer_cycles());
spdk_poller_insert_timer(reactor, poller, spdk_get_ticks());
} else {
TAILQ_INSERT_TAIL(&reactor->active_pollers, poller, tailq);
}
@ -698,7 +698,7 @@ spdk_poller_register(struct spdk_poller **ppoller, spdk_poller_fn fn, void *arg,
poller->arg = arg;
if (period_microseconds) {
poller->period_ticks = (rte_get_timer_hz() * period_microseconds) / 1000000ULL;
poller->period_ticks = (spdk_get_ticks_hz() * period_microseconds) / 1000000ULL;
} else {
poller->period_ticks = 0;
}

View File

@ -46,9 +46,9 @@
#include <rte_config.h>
#include <rte_mempool.h>
#include <rte_cycles.h>
#include "spdk/endian.h"
#include "spdk/env.h"
#include "spdk/event.h"
#include "spdk/trace.h"
#include "spdk/log.h"
@ -63,7 +63,7 @@
memset(&(conn)->portal, 0, sizeof(*(conn)) - \
offsetof(struct spdk_iscsi_conn, portal));
#define MICROSECOND_TO_TSC(x) ((x) * rte_get_timer_hz()/1000000)
#define MICROSECOND_TO_TSC(x) ((x) * spdk_get_ticks_hz()/1000000)
static int64_t g_conn_idle_interval_in_tsc = -1;
#define DEFAULT_CONNECTIONS_PER_LCORE 4
@ -321,7 +321,7 @@ spdk_iscsi_conn_construct(struct spdk_iscsi_portal *portal,
pthread_mutex_lock(&g_spdk_iscsi.mutex);
conn->timeout = g_spdk_iscsi.timeout;
conn->nopininterval = g_spdk_iscsi.nopininterval;
conn->nopininterval *= rte_get_timer_hz(); /* seconds to TSC */
conn->nopininterval *= spdk_get_ticks_hz(); /* seconds to TSC */
conn->nop_outstanding = false;
conn->data_out_cnt = 0;
conn->data_in_cnt = 0;
@ -393,7 +393,7 @@ error_return:
conn->logout_timer = NULL;
conn->shutdown_timer = NULL;
SPDK_NOTICELOG("Launching connection on acceptor thread\n");
conn->last_activity_tsc = rte_get_timer_cycles();
conn->last_activity_tsc = spdk_get_ticks();
conn->pending_task_cnt = 0;
conn->pending_activate_event = false;
@ -837,7 +837,7 @@ process_task_mgmt_completion(spdk_event_t event)
struct spdk_iscsi_conn *conn = spdk_event_get_arg1(event);
struct spdk_iscsi_task *task = spdk_event_get_arg2(event);
conn->last_activity_tsc = rte_get_timer_cycles();
conn->last_activity_tsc = spdk_get_ticks();
spdk_iscsi_task_mgmt_response(conn, task);
spdk_iscsi_task_put(task);
}
@ -902,7 +902,7 @@ void process_task_completion(spdk_event_t event)
assert(task != NULL);
spdk_trace_record(TRACE_ISCSI_TASK_DONE, conn->id, 0, (uintptr_t)task, 0);
conn->last_activity_tsc = rte_get_timer_cycles();
conn->last_activity_tsc = spdk_get_ticks();
primary = spdk_iscsi_task_get_primary(task);
@ -965,9 +965,9 @@ spdk_iscsi_conn_handle_nop(struct spdk_iscsi_conn *conn)
uint64_t tsc;
/* Check for nop interval expiration */
tsc = rte_get_timer_cycles();
tsc = spdk_get_ticks();
if (conn->nop_outstanding) {
if ((tsc - conn->last_nopin) > (conn->timeout * rte_get_timer_hz())) {
if ((tsc - conn->last_nopin) > (conn->timeout * spdk_get_ticks_hz())) {
SPDK_ERRLOG("Timed out waiting for NOP-Out response from initiator\n");
SPDK_ERRLOG(" tsc=0x%lx, last_nopin=0x%lx\n", tsc, conn->last_nopin);
return -1;
@ -1204,7 +1204,7 @@ spdk_iscsi_conn_handle_incoming_pdus(struct spdk_iscsi_conn *conn)
static void spdk_iscsi_conn_handle_idle(struct spdk_iscsi_conn *conn)
{
uint64_t current_tsc = rte_get_timer_cycles();
uint64_t current_tsc = spdk_get_ticks();
if (g_conn_idle_interval_in_tsc > 0 &&
((int64_t)(current_tsc - conn->last_activity_tsc)) >= g_conn_idle_interval_in_tsc &&
@ -1240,7 +1240,7 @@ spdk_iscsi_conn_execute(struct spdk_iscsi_conn *conn)
}
/* If flush timer has expired, flush all PDUs */
tsc = rte_get_timer_cycles();
tsc = spdk_get_ticks();
if (tsc - conn->last_flush > g_spdk_iscsi.flush_timeout) {
conn->last_flush = tsc;
if (spdk_iscsi_conn_flush_pdus(conn) != 0) {
@ -1313,7 +1313,7 @@ spdk_iscsi_conn_full_feature_do_work(void *arg)
if (rc < 0) {
return;
} else if (rc > 0) {
conn->last_activity_tsc = rte_get_timer_cycles();
conn->last_activity_tsc = spdk_get_ticks();
}
/* Check if the session was idle during this access pass. If it was,
@ -1353,7 +1353,7 @@ void spdk_iscsi_conn_idle_do_work(void *arg)
assert(tconn->is_idle == 1);
if (tconn->pending_activate_event == false) {
tsc = rte_get_timer_cycles();
tsc = spdk_get_ticks();
if (tsc - tconn->last_nopin > tconn->nopininterval) {
tconn->pending_activate_event = true;
}
@ -1366,7 +1366,7 @@ void spdk_iscsi_conn_idle_do_work(void *arg)
/* remove connection from idle list */
STAILQ_REMOVE(&g_idle_conn_list_head, tconn, spdk_iscsi_conn, link);
tconn->last_activity_tsc = rte_get_timer_cycles();
tconn->last_activity_tsc = spdk_get_ticks();
tconn->pending_activate_event = false;
tconn->is_idle = 0;
del_idle_conn(tconn);

View File

@ -66,9 +66,9 @@
#include <rte_log.h>
#include <rte_mempool.h>
#include <rte_string_fns.h>
#include <rte_cycles.h>
#include "spdk/endian.h"
#include "spdk/env.h"
#include "spdk/trace.h"
#include "spdk/string.h"
#include "spdk/queue.h"
@ -3446,7 +3446,7 @@ spdk_iscsi_op_nopout(struct spdk_iscsi_conn *conn, struct spdk_iscsi_pdu *pdu)
to_be32(&rsph->max_cmd_sn, conn->sess->MaxCmdSN);
spdk_iscsi_write_pdu(conn, rsp_pdu);
conn->last_nopin = rte_get_timer_cycles();
conn->last_nopin = spdk_get_ticks();
return SPDK_SUCCESS;
}

View File

@ -48,7 +48,6 @@
#include <rte_log.h>
#include <rte_mempool.h>
#include <rte_string_fns.h>
#include <rte_cycles.h>
#include <rte_version.h>
#include <inttypes.h>
@ -816,9 +815,9 @@ spdk_iscsi_app_read_parameters(void)
val = spdk_conf_section_get_val(sp, "FlushTimeout");
if (val == NULL) {
g_spdk_iscsi.flush_timeout = DEFAULT_FLUSH_TIMEOUT * (rte_get_timer_hz() >> 20);
g_spdk_iscsi.flush_timeout = DEFAULT_FLUSH_TIMEOUT * (spdk_get_ticks_hz() >> 20);
} else {
g_spdk_iscsi.flush_timeout = strtoul(val, NULL, 10) * (rte_get_timer_hz() >> 20);
g_spdk_iscsi.flush_timeout = strtoul(val, NULL, 10) * (spdk_get_ticks_hz() >> 20);
}
SPDK_TRACELOG(SPDK_TRACE_DEBUG, "FlushTimeout %"PRIu64"\n", g_spdk_iscsi.flush_timeout);

View File

@ -41,7 +41,6 @@
#include <stdint.h>
#include <rte_config.h>
#include <rte_cycles.h>
#include <rte_lcore.h>
#include "nvmf_internal.h"

View File

@ -47,6 +47,7 @@
#include "spdk/queue.h"
#include "spdk/rpc.h"
#include "spdk/env.h"
#include "spdk/event.h"
#include "spdk/conf.h"
#include "spdk/log.h"

View File

@ -31,6 +31,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "spdk/env.h"
#include "spdk/trace.h"
#include <assert.h>
@ -46,7 +47,6 @@
#include <errno.h>
#include <rte_config.h>
#include <rte_cycles.h>
#include <rte_lcore.h>
static char g_shm_name[64];
@ -79,7 +79,7 @@ spdk_trace_record(uint16_t tpoint_id, uint16_t poller_id, uint32_t size,
}
lcore_history = &g_trace_histories->per_lcore_history[lcore];
tsc = rte_get_timer_cycles();
tsc = spdk_get_ticks();
lcore_history->tpoint_count[tpoint_id]++;
@ -186,7 +186,7 @@ spdk_trace_init(const char *shm_name)
memset(g_trace_histories, 0, sizeof(*g_trace_histories));
g_trace_histories->tsc_rate = rte_get_timer_hz();
g_trace_histories->tsc_rate = spdk_get_ticks_hz();
for (i = 0; i < SPDK_TRACE_MAX_LCORE; i++) {
g_trace_histories->per_lcore_history[i].lcore = i;

View File

@ -41,7 +41,6 @@
#include <rte_config.h>
#include <rte_eal.h>
#include <rte_mempool.h>
#include <rte_cycles.h>
#include <rte_ring.h>
#include <rte_lcore.h>

View File

@ -40,10 +40,10 @@
#include <rte_config.h>
#include <rte_eal.h>
#include <rte_mempool.h>
#include <rte_cycles.h>
#include <rte_ring.h>
#include <rte_lcore.h>
#include "spdk/env.h"
#include "spdk/event.h"
#include "spdk/log.h"
@ -74,7 +74,7 @@ event_work_fn(void *arg)
{
uint64_t tsc_end;
tsc_end = rte_get_timer_cycles() + g_time_in_sec * g_tsc_rate;
tsc_end = spdk_get_ticks() + g_time_in_sec * g_tsc_rate;
submit_new_event(NULL);
submit_new_event(NULL);
@ -85,7 +85,7 @@ event_work_fn(void *arg)
spdk_event_queue_run_all(rte_lcore_id());
if (rte_get_timer_cycles() > tsc_end) {
if (spdk_get_ticks() > tsc_end) {
break;
}
}
@ -152,7 +152,7 @@ main(int argc, char **argv)
spdk_app_init(&opts);
g_tsc_rate = rte_get_timer_hz();
g_tsc_rate = spdk_get_ticks_hz();
g_tsc_us_rate = g_tsc_rate / (1000 * 1000);
printf("Running I/O for %d seconds...", g_time_in_sec);

View File

@ -37,7 +37,6 @@
#include <unistd.h>
#include <rte_config.h>
#include <rte_cycles.h>
#include <rte_mempool.h>
#include <rte_lcore.h>
@ -291,7 +290,7 @@ submit_single_io(void)
offset_in_ios = rand_r(&seed) % entry->size_in_ios;
start = rte_get_tsc_cycles();
start = spdk_get_ticks();
rte_mb();
#if HAVE_LIBAIO
if (entry->type == ENTRY_TYPE_AIO_FILE) {
@ -306,7 +305,7 @@ submit_single_io(void)
}
rte_mb();
tsc_submit = rte_get_tsc_cycles() - start;
tsc_submit = spdk_get_ticks() - start;
g_tsc_submit += tsc_submit;
if (tsc_submit < g_tsc_submit_min) {
g_tsc_submit_min = tsc_submit;
@ -344,7 +343,7 @@ check_io(void)
spdk_nvme_qpair_process_completions(g_ns->u.nvme.qpair, 0);
}
rte_mb();
end = rte_get_tsc_cycles();
end = spdk_get_ticks();
if (g_ns->current_queue_depth == 1) {
/*
* Account for race condition in AIO case where interrupt occurs
@ -370,7 +369,7 @@ check_io(void)
if (!g_ns->is_draining) {
submit_single_io();
}
g_complete_tsc_start = rte_get_tsc_cycles();
g_complete_tsc_start = spdk_get_ticks();
}
}
@ -440,11 +439,11 @@ work_fn(void)
return 1;
}
tsc_end = rte_get_tsc_cycles() + g_time_in_sec * g_tsc_rate;
tsc_end = spdk_get_ticks() + g_time_in_sec * g_tsc_rate;
/* Submit initial I/O for each namespace. */
submit_single_io();
g_complete_tsc_start = rte_get_tsc_cycles();
g_complete_tsc_start = spdk_get_ticks();
while (1) {
/*
@ -454,7 +453,7 @@ work_fn(void)
*/
check_io();
if (rte_get_tsc_cycles() > tsc_end) {
if (spdk_get_ticks() > tsc_end) {
break;
}
}
@ -612,7 +611,7 @@ int main(int argc, char **argv)
exit(1);
}
g_tsc_rate = rte_get_tsc_hz();
g_tsc_rate = spdk_get_ticks_hz();
#if HAVE_LIBAIO
if (g_aio_optind < argc) {

View File

@ -37,7 +37,6 @@
#include <unistd.h>
#include <rte_config.h>
#include <rte_cycles.h>
#include <rte_mempool.h>
#include <rte_lcore.h>
@ -268,7 +267,7 @@ drain_io(struct ns_worker_ctx *ns_ctx)
static int
work_fn(void *arg)
{
uint64_t tsc_end = rte_get_timer_cycles() + g_time_in_sec * g_tsc_rate;
uint64_t tsc_end = spdk_get_ticks() + g_time_in_sec * g_tsc_rate;
struct worker_thread *worker = (struct worker_thread *)arg;
struct ns_worker_ctx *ns_ctx = NULL;
bool did_reset = false;
@ -299,7 +298,7 @@ work_fn(void *arg)
ns_ctx = ns_ctx->next;
}
if (!did_reset && ((tsc_end - rte_get_timer_cycles()) / g_tsc_rate) > (uint64_t)g_time_in_sec / 2) {
if (!did_reset && ((tsc_end - spdk_get_ticks()) / g_tsc_rate) > (uint64_t)g_time_in_sec / 2) {
ns_ctx = worker->ns_ctx;
while (ns_ctx != NULL) {
if (spdk_nvme_ctrlr_reset(ns_ctx->entry->ctrlr) < 0) {
@ -311,7 +310,7 @@ work_fn(void *arg)
did_reset = true;
}
if (rte_get_timer_cycles() > tsc_end) {
if (spdk_get_ticks() > tsc_end) {
break;
}
}
@ -640,7 +639,7 @@ int main(int argc, char **argv)
64, 0, NULL, NULL, task_ctor, NULL,
SOCKET_ID_ANY, 0);
g_tsc_rate = rte_get_timer_hz();
g_tsc_rate = spdk_get_ticks_hz();
if (register_workers() != 0) {
return 1;

View File

@ -39,9 +39,8 @@ SPDK_LIBS += $(SPDK_ROOT_DIR)/lib/log/libspdk_log.a \
$(SPDK_ROOT_DIR)/lib/trace/libspdk_trace.a \
$(SPDK_ROOT_DIR)/lib/util/libspdk_util.a
CFLAGS += -I$(SPDK_ROOT_DIR)/lib/scsi
LIBS += $(SPDK_LIBS)
LIBS += $(DPDK_LIB)
CFLAGS += -I$(SPDK_ROOT_DIR)/lib/scsi $(ENV_CFLAGS)
LIBS += $(SPDK_LIBS) $(ENV_LINKER_ARGS)
LIBS += -lcunit
APP = init_ut
@ -49,7 +48,7 @@ C_SRCS = init_ut.c
all: $(APP)
$(APP): $(OBJS) $(SPDK_LIBS)
$(APP): $(OBJS) $(SPDK_LIBS) $(ENV_LIBS)
$(LINK_C)
clean: