trace, trace_parser: support 4-byte INT/PTR arguments

This allows us to pack more arguments into the same
amount of shared memory, for cases where those arguments
don't need a full 8 bytes.

1- and 2-byte sizes not supported for now, variadic args
do automatic promotion of types smaller than int, so
support for those may need more work.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Iec56cfa851b408a77d7995126d2111b0bf3d7f95
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13999
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Dong Yi <dongx.yi@intel.com>
Reviewed-by: Jacek Kalwas <jacek.kalwas@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
This commit is contained in:
Jim Harris 2022-08-11 05:34:47 +00:00 committed by Tomasz Zawadzki
parent 081f080a49
commit cdb0726b95
3 changed files with 12 additions and 4 deletions

View File

@ -82,9 +82,13 @@ _spdk_trace_record(uint64_t tsc, uint16_t tpoint_id, uint16_t poller_id, uint32_
break; break;
case SPDK_TRACE_ARG_TYPE_INT: case SPDK_TRACE_ARG_TYPE_INT:
case SPDK_TRACE_ARG_TYPE_PTR: case SPDK_TRACE_ARG_TYPE_PTR:
intval = va_arg(vl, uint64_t); if (argument->size == 8) {
intval = va_arg(vl, uint64_t);
} else {
intval = va_arg(vl, uint32_t);
}
argval = &intval; argval = &intval;
arglen = sizeof(uint64_t); arglen = argument->size;
break; break;
default: default:
assert(0 && "Invalid trace argument type"); assert(0 && "Invalid trace argument type");

View File

@ -289,8 +289,8 @@ trace_register_description(const struct spdk_trace_tpoint_opts *opts)
switch (opts->args[i].type) { switch (opts->args[i].type) {
case SPDK_TRACE_ARG_TYPE_INT: case SPDK_TRACE_ARG_TYPE_INT:
case SPDK_TRACE_ARG_TYPE_PTR: case SPDK_TRACE_ARG_TYPE_PTR:
/* The integers and pointers have to be exactly 64b long */ /* The integers and pointers have to be exactly 4 or 8 bytes */
assert(opts->args[i].size == sizeof(uint64_t)); assert(opts->args[i].size == 4 || opts->args[i].size == 8);
break; break;
case SPDK_TRACE_ARG_TYPE_STR: case SPDK_TRACE_ARG_TYPE_STR:
/* Strings need to have at least one byte for the NULL terminator */ /* Strings need to have at least one byte for the NULL terminator */

View File

@ -127,6 +127,10 @@ spdk_trace_parser::build_arg(argument_context *argctx, const spdk_trace_argument
size_t curlen, argoff; size_t curlen, argoff;
argoff = 0; argoff = 0;
/* Make sure that if we only copy a 4-byte integer, that the upper bytes have already been
* zeroed.
*/
pe->args[argid].integer = 0;
while (argoff < arg->size) { while (argoff < arg->size) {
if (argctx->offset == sizeof(buffer->data)) { if (argctx->offset == sizeof(buffer->data)) {
buffer = get_next_buffer(buffer, argctx->lcore); buffer = get_next_buffer(buffer, argctx->lcore);