Content-Type: multipart/mixed; boundary="===============1878279477955317913==" MIME-Version: 1.0 From: yzhu Subject: Re: [SPDK] Memory Buffer Allocation in SPDK Date: Tue, 13 Dec 2016 10:49:58 -0500 Message-ID: <3120b8c6154d07c0c4a421351479810a@cs.fsu.edu> In-Reply-To: 6EE29130-9ABD-4825-89D1-77DEBEFDC162@intel.com List-ID: To: spdk@lists.01.org --===============1878279477955317913== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi Jim, Thanks for your quick reply. So I was wondering if spdk_malloc() is the = only safe and correct way to allocate buffer for writing to NVMe device = via spdk_nvme_ns_cmd_write. Previously, I tried to lock the buffer allocated by malloc() in RAM by = mlock(), and immediately write the buffer to NVMe device by = spdk_nvme_ns_cmd_write. However, the write failed because of the failure = of converting virtual address to physical address. The error was "could = not find 2MB vfn 0x11 in DPDK mem config". Based on this, I was also = wondering how to correctly write to NVMe device via spdk if we still = have to use the buffer allocated by malloc()? Thank you, Yue On 2016-12-12 23:46, Harris, James R wrote: >> On Dec 12, 2016, at 9:13 PM, yzhu wrote: >> = >> Hi All, >> = >> Is there any way to directly use the memory allocated by the malloc() = >> function? The spdk_malloc() allocates a pinned memory buffer in huge = >> page, and the spdk_nvme_ns_cmd_write also uses the pinned memory for = >> write. However, if we allocate a memory buffer by malloc(), how could = >> we directly write data to NVMe device by SPDK without copying data to = >> the buffer allocated by spdk_malloc()? >> = > = > Hi Yue, > = > There is no safe way to use a malloc() buffer for DMA, since the > buffer could be swapped out at any time. mlock() can be used to > ensure the buffer stays present in RAM, but it does not guarantee the > buffer will not get migrated to a different physical location. > mlock() also has a lot of software overhead and is not something you > would want to call for every I/O. > = > -Jim > = > _______________________________________________ > SPDK mailing list > SPDK(a)lists.01.org > https://lists.01.org/mailman/listinfo/spdk --===============1878279477955317913==--