event/app: use PID for trace ID if shm_id is unset
Change-Id: If79a09e109a3885e1282f3e834b531c250e59512 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
ac9b92c853
commit
60fc74584a
@ -94,7 +94,6 @@ struct object_stats g_stats[SPDK_TRACE_MAX_OBJECT];
|
|||||||
|
|
||||||
static char *exe_name;
|
static char *exe_name;
|
||||||
static int verbose = 1;
|
static int verbose = 1;
|
||||||
static int g_shm_id = 0;
|
|
||||||
static int g_fudge_factor = 20;
|
static int g_fudge_factor = 20;
|
||||||
|
|
||||||
static uint64_t tsc_rate;
|
static uint64_t tsc_rate;
|
||||||
@ -306,7 +305,9 @@ static void usage(void)
|
|||||||
fprintf(stderr, " '-c' to display single lcore history\n");
|
fprintf(stderr, " '-c' to display single lcore history\n");
|
||||||
fprintf(stderr, " '-f' to specify number of events to ignore at\n");
|
fprintf(stderr, " '-f' to specify number of events to ignore at\n");
|
||||||
fprintf(stderr, " beginning and end of trace (default: 20)\n");
|
fprintf(stderr, " beginning and end of trace (default: 20)\n");
|
||||||
fprintf(stderr, " '-i' to specify the shared memory ID, (required)\n");
|
fprintf(stderr, " '-i' to specify the shared memory ID\n");
|
||||||
|
fprintf(stderr, " '-p' to specify the trace PID\n");
|
||||||
|
fprintf(stderr, " (One of -i or -p must be specified)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
@ -319,9 +320,10 @@ int main(int argc, char **argv)
|
|||||||
const char *app_name = "ids";
|
const char *app_name = "ids";
|
||||||
int op;
|
int op;
|
||||||
char shm_name[64];
|
char shm_name[64];
|
||||||
|
int shm_id = -1, shm_pid = -1;
|
||||||
|
|
||||||
exe_name = argv[0];
|
exe_name = argv[0];
|
||||||
while ((op = getopt(argc, argv, "c:f:i:qs:")) != -1) {
|
while ((op = getopt(argc, argv, "c:f:i:p:qs:")) != -1) {
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case 'c':
|
case 'c':
|
||||||
lcore = atoi(optarg);
|
lcore = atoi(optarg);
|
||||||
@ -336,7 +338,10 @@ int main(int argc, char **argv)
|
|||||||
g_fudge_factor = atoi(optarg);
|
g_fudge_factor = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
g_shm_id = atoi(optarg);
|
shm_id = atoi(optarg);
|
||||||
|
break;
|
||||||
|
case 'p':
|
||||||
|
shm_pid = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case 'q':
|
case 'q':
|
||||||
verbose = 0;
|
verbose = 0;
|
||||||
@ -350,7 +355,11 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(shm_name, sizeof(shm_name), "/%s_trace.%d", app_name, g_shm_id);
|
if (shm_id >= 0) {
|
||||||
|
snprintf(shm_name, sizeof(shm_name), "/%s_trace.%d", app_name, shm_id);
|
||||||
|
} else {
|
||||||
|
snprintf(shm_name, sizeof(shm_name), "/%s_trace.pid%d", app_name, shm_pid);
|
||||||
|
}
|
||||||
fd = shm_open(shm_name, O_RDONLY, 0600);
|
fd = shm_open(shm_name, O_RDONLY, 0600);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
fprintf(stderr, "Could not open shm %s.\n", shm_name);
|
fprintf(stderr, "Could not open shm %s.\n", shm_name);
|
||||||
|
@ -387,7 +387,12 @@ spdk_app_init(struct spdk_app_opts *opts)
|
|||||||
sigaddset(&signew, SIGHUP);
|
sigaddset(&signew, SIGHUP);
|
||||||
pthread_sigmask(SIG_SETMASK, &signew, NULL);
|
pthread_sigmask(SIG_SETMASK, &signew, NULL);
|
||||||
|
|
||||||
snprintf(shm_name, sizeof(shm_name), "/%s_trace.%d", opts->name, opts->shm_id);
|
if (opts->shm_id >= 0) {
|
||||||
|
snprintf(shm_name, sizeof(shm_name), "/%s_trace.%d", opts->name, opts->shm_id);
|
||||||
|
} else {
|
||||||
|
snprintf(shm_name, sizeof(shm_name), "/%s_trace.pid%d", opts->name, (int)getpid());
|
||||||
|
}
|
||||||
|
|
||||||
spdk_trace_init(shm_name);
|
spdk_trace_init(shm_name);
|
||||||
|
|
||||||
if (opts->tpoint_group_mask == NULL) {
|
if (opts->tpoint_group_mask == NULL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user