trace: detect out of shared memory
Now that we do not unlink shared memory trace files if the user has specified tracepoint flags, it is possible to run out of shm space. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I713eb15a4067969ffcb6c95009c589d8e71e8d55 Reviewed-on: https://review.gerrithub.io/424356 Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
b7b7c04609
commit
094e980dfa
@ -102,6 +102,20 @@ spdk_trace_init(const char *shm_name)
|
|||||||
goto trace_init_err;
|
goto trace_init_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: On FreeBSD, mlock on shm_open'd memory doesn't seem to work. Docs say that kern.ipc.shm_use_phys=1
|
||||||
|
* should allow it, but forcing that doesn't seem to work either. So for now just skip mlock on FreeBSD
|
||||||
|
* altogether.
|
||||||
|
*/
|
||||||
|
#if defined(__linux__)
|
||||||
|
if (mlock(g_trace_histories, sizeof(*g_trace_histories)) != 0) {
|
||||||
|
fprintf(stderr, "Could not mlock shm for tracing - %s.\n", spdk_strerror(errno));
|
||||||
|
if (errno == ENOMEM) {
|
||||||
|
fprintf(stderr, "Check /dev/shm for old tracing files that can be deleted.\n");
|
||||||
|
}
|
||||||
|
goto trace_init_err;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
memset(g_trace_histories, 0, sizeof(*g_trace_histories));
|
memset(g_trace_histories, 0, sizeof(*g_trace_histories));
|
||||||
|
|
||||||
g_trace_flags = &g_trace_histories->flags;
|
g_trace_flags = &g_trace_histories->flags;
|
||||||
@ -117,9 +131,13 @@ spdk_trace_init(const char *shm_name)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
trace_init_err:
|
trace_init_err:
|
||||||
|
if (g_trace_histories != MAP_FAILED) {
|
||||||
|
munmap(g_trace_histories, sizeof(*g_trace_histories));
|
||||||
|
}
|
||||||
close(g_trace_fd);
|
close(g_trace_fd);
|
||||||
g_trace_fd = -1;
|
g_trace_fd = -1;
|
||||||
shm_unlink(shm_name);
|
shm_unlink(shm_name);
|
||||||
|
g_trace_histories = NULL;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user