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: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17508 Community-CI: Mellanox Build Bot Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
30f52282f4
commit
cb9e0db853
@ -255,6 +255,7 @@ posix_sock_alloc_pipe(struct spdk_posix_sock *sock, int sz)
|
|||||||
struct iovec diov[2];
|
struct iovec diov[2];
|
||||||
int sbytes;
|
int sbytes;
|
||||||
ssize_t bytes;
|
ssize_t bytes;
|
||||||
|
int rc;
|
||||||
|
|
||||||
if (sock->recv_buf_sz == sz) {
|
if (sock->recv_buf_sz == sz) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -273,11 +274,12 @@ posix_sock_alloc_pipe(struct spdk_posix_sock *sock, int sz)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Round up to next 64 byte multiple */
|
/* Round up to next 64 byte multiple */
|
||||||
new_buf = calloc(SPDK_ALIGN_CEIL(sz, 64), sizeof(uint8_t));
|
rc = posix_memalign((void **)&new_buf, 64, sz);
|
||||||
if (!new_buf) {
|
if (rc != 0) {
|
||||||
SPDK_ERRLOG("socket recv buf allocation failed\n");
|
SPDK_ERRLOG("socket recv buf allocation failed\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
memset(new_buf, 0, sz);
|
||||||
|
|
||||||
new_pipe = spdk_pipe_create(new_buf, sz);
|
new_pipe = spdk_pipe_create(new_buf, sz);
|
||||||
if (new_pipe == NULL) {
|
if (new_pipe == NULL) {
|
||||||
|
@ -275,6 +275,7 @@ uring_sock_alloc_pipe(struct spdk_uring_sock *sock, int sz)
|
|||||||
struct iovec diov[2];
|
struct iovec diov[2];
|
||||||
int sbytes;
|
int sbytes;
|
||||||
ssize_t bytes;
|
ssize_t bytes;
|
||||||
|
int rc;
|
||||||
|
|
||||||
if (sock->recv_buf_sz == sz) {
|
if (sock->recv_buf_sz == sz) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -293,11 +294,12 @@ uring_sock_alloc_pipe(struct spdk_uring_sock *sock, int sz)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Round up to next 64 byte multiple */
|
/* Round up to next 64 byte multiple */
|
||||||
new_buf = calloc(SPDK_ALIGN_CEIL(sz, 64), sizeof(uint8_t));
|
rc = posix_memalign((void **)&new_buf, 64, sz);
|
||||||
if (!new_buf) {
|
if (rc != 0) {
|
||||||
SPDK_ERRLOG("socket recv buf allocation failed\n");
|
SPDK_ERRLOG("socket recv buf allocation failed\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
memset(new_buf, 0, sz);
|
||||||
|
|
||||||
new_pipe = spdk_pipe_create(new_buf, sz);
|
new_pipe = spdk_pipe_create(new_buf, sz);
|
||||||
if (new_pipe == NULL) {
|
if (new_pipe == NULL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user