Commit cdb0726b authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

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: default avatarJim 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: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarDong Yi <dongx.yi@intel.com>
Reviewed-by: default avatarJacek Kalwas <jacek.kalwas@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent 081f080a
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -82,9 +82,13 @@ _spdk_trace_record(uint64_t tsc, uint16_t tpoint_id, uint16_t poller_id, uint32_
			break;
		case SPDK_TRACE_ARG_TYPE_INT:
		case SPDK_TRACE_ARG_TYPE_PTR:
			if (argument->size == 8) {
				intval = va_arg(vl, uint64_t);
			} else {
				intval = va_arg(vl, uint32_t);
			}
			argval = &intval;
			arglen = sizeof(uint64_t);
			arglen = argument->size;
			break;
		default:
			assert(0 && "Invalid trace argument type");
+2 −2
Original line number Diff line number Diff line
@@ -289,8 +289,8 @@ trace_register_description(const struct spdk_trace_tpoint_opts *opts)
		switch (opts->args[i].type) {
		case SPDK_TRACE_ARG_TYPE_INT:
		case SPDK_TRACE_ARG_TYPE_PTR:
			/* The integers and pointers have to be exactly 64b long */
			assert(opts->args[i].size == sizeof(uint64_t));
			/* The integers and pointers have to be exactly 4 or 8 bytes */
			assert(opts->args[i].size == 4 || opts->args[i].size == 8);
			break;
		case SPDK_TRACE_ARG_TYPE_STR:
			/* Strings need to have at least one byte for the NULL terminator */
+4 −0
Original line number Diff line number Diff line
@@ -127,6 +127,10 @@ spdk_trace_parser::build_arg(argument_context *argctx, const spdk_trace_argument
	size_t curlen, argoff;

	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) {
		if (argctx->offset == sizeof(buffer->data)) {
			buffer = get_next_buffer(buffer, argctx->lcore);