Commit 1fd3d8e9 authored by Sylvain Didelot's avatar Sylvain Didelot Committed by Tomasz Zawadzki
Browse files

lib/trace: Don't initialize traces if requested num entries is 0



Context:
Every-time the SPDK starts, it creates a large file under
/dev/shm (130 MB in my setup) which is never removed when
the application terminates.

The number of trace entries can be tuned using the SPDK runtime
option 'num_entries'. A value of 0 for this option considerably
reduces the size of the trace file (few MBs) but it is still
created.

This patch adds a special case in the code when num_entries=0:
the trace system would not be initialized, and the trace file
would not be created in this case.

The rest of the code properly handle the case where the trace
system is never initialized.

Signed-off-by: default avatarSylvain Didelot <sdidelot@ddn.com>
Change-Id: If54a548de4a2ce2def8e57d527d0dc20bc55fe4d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/606


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent a11aab73
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -87,6 +87,11 @@ spdk_trace_init(const char *shm_name, uint64_t num_entries)
	int histories_size;
	uint64_t lcore_offsets[SPDK_TRACE_MAX_LCORE + 1];

	/* 0 entries requested - skip trace initialization */
	if (num_entries == 0) {
		return 0;
	}

	lcore_offsets[0] = sizeof(struct spdk_trace_flags);
	for (i = 1; i < (int)SPDK_COUNTOF(lcore_offsets); i++) {
		lcore_offsets[i] = spdk_get_trace_history_size(num_entries) + lcore_offsets[i - 1];