examples/nvme/arbitration: simplify log page allocation

spdk_nvme_ctrlr_cmd_get_log_page() now allocates a physically contiguous
buffer internally, so the caller does not need to provide special
DPDK-allocated memory.

Change-Id: Ic9964fdea3532303b172e591536b57d102d1d0b1
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2016-09-22 13:06:18 -07:00 committed by Jim Harris
parent afd2fc556e
commit df56ab7711

View File

@ -49,7 +49,7 @@
struct ctrlr_entry {
struct spdk_nvme_ctrlr *ctrlr;
struct spdk_nvme_intel_rw_latency_page *latency_page;
struct spdk_nvme_intel_rw_latency_page latency_page;
struct ctrlr_entry *next;
char name[1024];
};
@ -258,7 +258,7 @@ static void
register_ctrlr(struct spdk_nvme_ctrlr *ctrlr)
{
int nsid, num_ns;
struct ctrlr_entry *entry = malloc(sizeof(struct ctrlr_entry));
struct ctrlr_entry *entry = calloc(1, sizeof(struct ctrlr_entry));
const struct spdk_nvme_ctrlr_data *cdata = spdk_nvme_ctrlr_get_data(ctrlr);
if (entry == NULL) {
@ -266,13 +266,6 @@ register_ctrlr(struct spdk_nvme_ctrlr *ctrlr)
exit(1);
}
entry->latency_page = rte_zmalloc("nvme latency", sizeof(struct spdk_nvme_intel_rw_latency_page),
4096);
if (entry->latency_page == NULL) {
printf("Allocation error (latency page)\n");
exit(1);
}
snprintf(entry->name, sizeof(entry->name), "%-20.20s (%-20.20s)", cdata->mn, cdata->sn);
entry->ctrlr = ctrlr;
@ -619,19 +612,19 @@ print_latency_page(struct ctrlr_entry *entry)
printf("--------------------------------------------------------\n");
for (i = 0; i < 32; i++) {
if (entry->latency_page->buckets_32us[i])
if (entry->latency_page.buckets_32us[i])
printf("Bucket %dus - %dus: %d\n", i * 32, (i + 1) * 32,
entry->latency_page->buckets_32us[i]);
entry->latency_page.buckets_32us[i]);
}
for (i = 0; i < 31; i++) {
if (entry->latency_page->buckets_1ms[i])
if (entry->latency_page.buckets_1ms[i])
printf("Bucket %dms - %dms: %d\n", i + 1, i + 2,
entry->latency_page->buckets_1ms[i]);
entry->latency_page.buckets_1ms[i]);
}
for (i = 0; i < 31; i++) {
if (entry->latency_page->buckets_32ms[i])
if (entry->latency_page.buckets_32ms[i])
printf("Bucket %dms - %dms: %d\n", (i + 1) * 32, (i + 2) * 32,
entry->latency_page->buckets_32ms[i]);
entry->latency_page.buckets_32ms[i]);
}
}
@ -648,7 +641,7 @@ print_latency_statistics(const char *op_name, enum spdk_nvme_intel_log_page log_
if (spdk_nvme_ctrlr_cmd_get_log_page(
ctrlr->ctrlr, log_page,
SPDK_NVME_GLOBAL_NS_TAG,
ctrlr->latency_page,
&ctrlr->latency_page,
sizeof(struct spdk_nvme_intel_rw_latency_page),
enable_latency_tracking_complete,
NULL)) {
@ -941,7 +934,6 @@ unregister_controllers(void)
while (entry) {
struct ctrlr_entry *next = entry->next;
rte_free(entry->latency_page);
if (g_arbitration.latency_tracking_enable &&
spdk_nvme_ctrlr_is_feature_supported(entry->ctrlr, SPDK_NVME_INTEL_FEAT_LATENCY_TRACKING))
set_latency_tracking_feature(entry->ctrlr, false);