Commit cb9e0db8 authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

sock: Do aligned allocations for the pipes



Use posix_memalign to ensure aligned allocations. In reality, we'd get
64 byte alignment using even calloc, but this makes sure of it.

Change-Id: I6066e57c95b0f42cff439d452e4aed853189a523
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17508


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 30f52282
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -255,6 +255,7 @@ posix_sock_alloc_pipe(struct spdk_posix_sock *sock, int sz)
	struct iovec diov[2];
	int sbytes;
	ssize_t bytes;
	int rc;

	if (sock->recv_buf_sz == sz) {
		return 0;
@@ -273,11 +274,12 @@ posix_sock_alloc_pipe(struct spdk_posix_sock *sock, int sz)
	}

	/* Round up to next 64 byte multiple */
	new_buf = calloc(SPDK_ALIGN_CEIL(sz, 64), sizeof(uint8_t));
	if (!new_buf) {
	rc = posix_memalign((void **)&new_buf, 64, sz);
	if (rc != 0) {
		SPDK_ERRLOG("socket recv buf allocation failed\n");
		return -ENOMEM;
	}
	memset(new_buf, 0, sz);

	new_pipe = spdk_pipe_create(new_buf, sz);
	if (new_pipe == NULL) {
+4 −2
Original line number Diff line number Diff line
@@ -275,6 +275,7 @@ uring_sock_alloc_pipe(struct spdk_uring_sock *sock, int sz)
	struct iovec diov[2];
	int sbytes;
	ssize_t bytes;
	int rc;

	if (sock->recv_buf_sz == sz) {
		return 0;
@@ -293,11 +294,12 @@ uring_sock_alloc_pipe(struct spdk_uring_sock *sock, int sz)
	}

	/* Round up to next 64 byte multiple */
	new_buf = calloc(SPDK_ALIGN_CEIL(sz, 64), sizeof(uint8_t));
	if (!new_buf) {
	rc = posix_memalign((void **)&new_buf, 64, sz);
	if (rc != 0) {
		SPDK_ERRLOG("socket recv buf allocation failed\n");
		return -ENOMEM;
	}
	memset(new_buf, 0, sz);

	new_pipe = spdk_pipe_create(new_buf, sz);
	if (new_pipe == NULL) {