diff --git a/src/bio/bio_buffer.c b/src/bio/bio_buffer.c index 1f6baae521b..1d29594ad1f 100644 --- a/src/bio/bio_buffer.c +++ b/src/bio/bio_buffer.c @@ -231,6 +231,7 @@ dma_buffer_create(unsigned int init_cnt, int tgt_id) rc = dma_buffer_grow(buf, init_cnt); if (rc != 0) { + D_ERROR("Failed to grow DMA buffer (%u chunks)\n", buf->bdb_tot_cnt); dma_buffer_destroy(buf); return NULL; } @@ -867,8 +868,10 @@ dma_map_one(struct bio_desc *biod, struct bio_iov *biov, void *arg) */ if (pg_cnt > bio_chk_sz) { chk = dma_alloc_chunk(pg_cnt); - if (chk == NULL) + if (chk == NULL) { + D_ERROR("Failed to allocate %u pages DMA buffer\n", pg_cnt); return -DER_NOMEM; + } chk->bdc_type = biod->bd_chk_type; rc = iod_add_chunk(biod, chk); diff --git a/src/bio/bio_xstream.c b/src/bio/bio_xstream.c index 1396689e892..d26a5f4bee1 100644 --- a/src/bio/bio_xstream.c +++ b/src/bio/bio_xstream.c @@ -31,8 +31,8 @@ /* SPDK blob parameters */ #define DAOS_BS_CLUSTER_SZ (1ULL << 25) /* 32MB */ /* DMA buffer parameters */ -#define DAOS_DMA_CHUNK_CNT_INIT 24 /* Per-xstream init chunks, 192MB */ -#define DAOS_DMA_CHUNK_CNT_MAX 128 /* Per-xstream max chunks, 1GB */ +#define DAOS_DMA_CHUNK_INIT_PCT 60 /* Default pre-xstream init chunks, in percentage */ +#define DAOS_DMA_CHUNK_CNT_MAX 128 /* Default per-xstream max chunks, 1GB */ #define DAOS_DMA_CHUNK_CNT_MIN 32 /* Per-xstream min chunks, 256MB */ /* Max in-flight blob IOs per io channel */ @@ -48,8 +48,8 @@ unsigned int bio_chk_sz; unsigned int bio_chk_cnt_max; /* NUMA node affinity */ unsigned int bio_numa_node; -/* Per-xstream initial DMA buffer size (in chunk count) */ -static unsigned int bio_chk_cnt_init; +/* Per-xstream initial DMA buffer size (in percentage) */ +static unsigned int bio_chk_init_pct; /* Diret RDMA over SCM */ bool bio_scm_rdma; /* Whether SPDK inited */ @@ -203,6 +203,14 @@ bypass_health_collect() return nvme_glb.bd_bypass_health_collect; } +static inline unsigned int +init_chk_cnt() +{ + unsigned init_cnt = (bio_chk_cnt_max * bio_chk_init_pct / 100); + + return (init_cnt == 0) ? 1 : init_cnt; +} + int bio_nvme_init(const char *nvme_conf, int numa_node, unsigned int mem_size, unsigned int hugepage_size, unsigned int tgt_nr, bool bypass_health_collect) @@ -249,7 +257,7 @@ bio_nvme_init(const char *nvme_conf, int numa_node, unsigned int mem_size, */ glb_criteria.fc_max_csum_errs = UINT32_MAX; - bio_chk_cnt_init = DAOS_DMA_CHUNK_CNT_INIT; + bio_chk_init_pct = DAOS_DMA_CHUNK_INIT_PCT; bio_chk_cnt_max = DAOS_DMA_CHUNK_CNT_MAX; bio_chk_sz = ((uint64_t)size_mb << 20) >> BIO_DMA_PAGE_SHIFT; @@ -291,8 +299,13 @@ bio_nvme_init(const char *nvme_conf, int numa_node, unsigned int mem_size, mem_size, tgt_nr); return -DER_INVAL; } - D_INFO("Set per-xstream DMA buffer upper bound to %u %uMB chunks\n", - bio_chk_cnt_max, size_mb); + + d_getenv_uint("DAOS_DMA_INIT_PCT", &bio_chk_init_pct); + if (bio_chk_init_pct == 0 || bio_chk_init_pct >= 100) + bio_chk_init_pct = DAOS_DMA_CHUNK_INIT_PCT; + + D_INFO("Set per-xstream DMA buffer upper bound to %u %uMB chunks, prealloc %u chunks\n", + bio_chk_cnt_max, size_mb, init_chk_cnt()); spdk_bs_opts_init(&nvme_glb.bd_bs_opts, sizeof(nvme_glb.bd_bs_opts)); nvme_glb.bd_bs_opts.cluster_sz = DAOS_BS_CLUSTER_SZ; @@ -1560,7 +1573,7 @@ bio_xsctxt_alloc(struct bio_xs_context **pctxt, int tgt_id, bool self_polling) /* Skip NVMe context setup if the daos_nvme.conf isn't present */ if (!bio_nvme_configured(SMD_DEV_TYPE_MAX)) { - ctxt->bxc_dma_buf = dma_buffer_create(bio_chk_cnt_init, tgt_id); + ctxt->bxc_dma_buf = dma_buffer_create(init_chk_cnt(), tgt_id); if (ctxt->bxc_dma_buf == NULL) { D_FREE(ctxt); *pctxt = NULL; @@ -1673,7 +1686,7 @@ bio_xsctxt_alloc(struct bio_xs_context **pctxt, int tgt_id, bool self_polling) D_ASSERT(d_bdev != NULL); } - ctxt->bxc_dma_buf = dma_buffer_create(bio_chk_cnt_init, tgt_id); + ctxt->bxc_dma_buf = dma_buffer_create(init_chk_cnt(), tgt_id); if (ctxt->bxc_dma_buf == NULL) { D_ERROR("failed to initialize dma buffer\n"); rc = -DER_NOMEM; diff --git a/utils/test_memcheck.supp b/utils/test_memcheck.supp index 3134d89d0ee..256a1e0619e 100644 --- a/utils/test_memcheck.supp +++ b/utils/test_memcheck.supp @@ -418,3 +418,12 @@ ... fun:runtime.persistentalloc } +{ + DAOS-16866 + Memcheck:Leak + match-leak-kinds: reachable + fun:malloc + fun:mem_map_get_map_1gb + fun:spdk_mem_map_set_translation + ... +}