Skip to content

Commit a416f72

Browse files
sshaulnvHassanKhadour
authored andcommitted
Perftest: Fix payload modification length bug
This commit fix an implementation bug . currently perftest get the payload length using strlen. strlen returns the length of null-terminated string, since the payload contains 0 values, the returned length is incorrect. Signed-off-by: Shmuel Shaul <[email protected]>
1 parent 89029a9 commit a416f72

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/perftest_parameters.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ struct perftest_parameters {
549549
int has_payload_modification;
550550
char* payload_file_path;
551551
char* payload_content;
552+
int payload_length;
552553
#ifdef HAVE_CUDA
553554
int use_cuda;
554555
int cuda_device_id;

src/perftest_resources.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,9 +1946,8 @@ int create_single_mr(struct pingpong_context *ctx, struct perftest_parameters *u
19461946
} else {
19471947
if (user_param->has_payload_modification) {
19481948
int i;
1949-
int payload_len = strlen(user_param->payload_content);
19501949
for (i = 0; i < ctx->buff_size; i++) {
1951-
((char*)ctx->buf[qp_index])[i] = user_param->payload_content[i % payload_len];
1950+
((char*)ctx->buf[qp_index])[i] = user_param->payload_content[i % user_param->payload_length];
19521951
}
19531952
} else {
19541953
random_data(ctx->buf[qp_index], ctx->buff_size);
@@ -2025,6 +2024,7 @@ static int create_payload(struct perftest_parameters *user_param)
20252024
return 1;
20262025
}
20272026
user_param->payload_content[counter] = (char) strtol(current_byte_chars, NULL, 16);
2027+
20282028
counter++;
20292029
if (counter == user_param->size)
20302030
break;
@@ -2033,7 +2033,7 @@ static int create_payload(struct perftest_parameters *user_param)
20332033
} while (token != NULL && counter < user_param->size);
20342034

20352035
user_param->payload_content[counter] = '\0';
2036-
2036+
user_param->payload_length = counter;
20372037
free(file_content);
20382038
fclose(fptr);
20392039

0 commit comments

Comments
 (0)