Commit 2d65fd75 authored by Krzysztof Karas's avatar Krzysztof Karas Committed by Tomasz Zawadzki
Browse files

lib/event: shorten opts descriptions' lines



Currently we display some of our app opts descriptions without any
length limit. This means that these lines will wrap only when hitting
the horizontal terminal size. To improve readability and overall
visual experience, make sure the lines do not exceed 100 characters.

Change-Id: If002cba7c4ef4178f11f2bb0e37269c5626852c0
Signed-off-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/21999


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Community-CI: Mellanox Build Bot
parent a3839c04
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -979,7 +979,8 @@ usage(void (*app_usage)(void))
	printf("%s [options]\n", g_executable_name);
	/* Keep entries inside categories roughly sorted by frequency of use. */
	printf("\nCPU options:\n");
	printf(" -m, --cpumask <mask or list>    core mask (like 0xF) or core list of '[]' embraced (like [0,1,10]) for DPDK\n");
	printf(" -m, --cpumask <mask or list>    core mask (like 0xF) or core list of '[]' embraced for DPDK\n");
	printf("                                 (like [0,1,10])\n");
	printf("     --lcores <list>       lcore to CPU mapping list. The list is in the format:\n");
	printf("                           <lcores[@CPUs]>[<,lcores[@CPUs]>...]\n");
	printf("                           lcores and cpus list are grouped by '(' and ')', e.g '--lcores \"(5-7)@(10-12)\"'\n");
@@ -988,7 +989,8 @@ usage(void (*app_usage)(void))
	printf("                           '( )' can be omitted for single element group,\n");
	printf("                           '@' can be omitted if cpus and lcores have the same value\n");
	printf("     --disable-cpumask-locks    Disable CPU core lock files.\n");
	printf("     --interrupt-mode      set app to interrupt mode (Warning: CPU usage will be reduced only if all pollers in the app support interrupt mode)\n");
	printf("     --interrupt-mode      set app to interrupt mode (Warning: CPU usage will be reduced only if all\n");
	printf("                           pollers in the app support interrupt mode)\n");
	printf(" -p, --main-core <id>      main (primary) core for DPDK\n");

	printf("\nConfiguration options:\n");
@@ -1010,8 +1012,7 @@ usage(void (*app_usage)(void))
	       SPDK_DEFAULT_MSG_MEMPOOL_SIZE);
	printf("     --no-huge             run without using hugepages\n");
	printf(" -i, --shm-id <id>         shared memory ID (optional)\n");
	printf(" -g, --single-file-segments\n");
	printf("                           force creating just one hugetlbfs file\n");
	printf(" -g, --single-file-segments   force creating just one hugetlbfs file\n");

	printf("\nPCI options:\n");
	printf(" -A, --pci-allowed <bdf>   pci addr to allow (-B and -A cannot be used at the same time)\n");
@@ -1024,7 +1025,8 @@ usage(void (*app_usage)(void))
	printf("     --silence-noticelog   disable notice level logging to stderr\n");

	printf("\nTrace options:\n");
	printf("     --num-trace-entries <num>   number of trace entries for each core, must be power of 2, setting 0 to disable trace (default %d)\n",
	printf("     --num-trace-entries <num>   number of trace entries for each core, must be power of 2,\n");
	printf("                                 setting 0 to disable trace (default %d)\n",
	       SPDK_APP_DEFAULT_NUM_TRACE_ENTRIES);
	printf("                                 Tracepoints vary in size and can use more than one trace entry.\n");
	spdk_trace_mask_usage(stdout, "-e");
+30 −3
Original line number Diff line number Diff line
@@ -7,7 +7,8 @@

#include "spdk/log.h"

static TAILQ_HEAD(, spdk_log_flag) g_log_flags = TAILQ_HEAD_INITIALIZER(g_log_flags);
static TAILQ_HEAD(spdk_log_flag_head,
		  spdk_log_flag) g_log_flags = TAILQ_HEAD_INITIALIZER(g_log_flags);

static struct spdk_log_flag *
get_log_flag(const char *name)
@@ -112,11 +113,37 @@ spdk_log_get_next_flag(struct spdk_log_flag *flag)
void
spdk_log_usage(FILE *f, const char *log_arg)
{
#define LINE_PREFIX			"                           "
#define ENTRY_SEPARATOR			", "
#define MAX_LINE_LENGTH			100
	uint64_t prefix_len = strlen(LINE_PREFIX);
	uint64_t separator_len = strlen(ENTRY_SEPARATOR);
	const char *first_entry = "--logflag <flag>      enable log flag (all, ";
	uint64_t curr_line_len;
	uint64_t curr_entry_len;
	struct spdk_log_flag *flag;
	fprintf(f, " %s, --logflag <flag>    enable log flag (all", log_arg);
	char first_line[MAX_LINE_LENGTH] = {};

	snprintf(first_line, sizeof(first_line), " %s, %s", log_arg, first_entry);
	fprintf(f, "%s", first_line);
	curr_line_len = strlen(first_line);

	TAILQ_FOREACH(flag, &g_log_flags, tailq) {
		fprintf(f, ", %s", flag->name);
		curr_entry_len = strlen(flag->name);
		if ((curr_line_len + curr_entry_len + separator_len) > MAX_LINE_LENGTH) {
			fprintf(f, "\n%s", LINE_PREFIX);
			curr_line_len = prefix_len;
		}

		fprintf(f, "%s", flag->name);
		curr_line_len += curr_entry_len;

		if (TAILQ_LAST(&g_log_flags, spdk_log_flag_head) == flag) {
			break;
		}

		fprintf(f, "%s", ENTRY_SEPARATOR);
		curr_line_len += separator_len;
	}

	fprintf(f, ")\n");
+36 −17
Original line number Diff line number Diff line
@@ -191,33 +191,52 @@ spdk_trace_disable_tpoint_group(const char *group_name)
void
spdk_trace_mask_usage(FILE *f, const char *tmask_arg)
{
#define LINE_PREFIX			"                           "
#define ENTRY_SEPARATOR			", "
#define MAX_LINE_LENGTH			100
	uint64_t prefix_len = strlen(LINE_PREFIX);
	uint64_t separator_len = strlen(ENTRY_SEPARATOR);
	const char *first_entry = "group_name - tracepoint group name for spdk trace buffers (";
	const char *last_entry = "all).";
	uint64_t curr_line_len;
	uint64_t curr_entry_len;
	struct spdk_trace_register_fn *register_fn;
	bool first_group_name = true;

	fprintf(f, " %s, --tpoint-group <group-name>[:<tpoint_mask>]\n", tmask_arg);
	fprintf(f, "                           group_name - tracepoint group name ");
	fprintf(f, "for spdk trace buffers (");
	fprintf(f, "%s%s", LINE_PREFIX, first_entry);
	curr_line_len = prefix_len + strlen(first_entry);

	register_fn = g_reg_fn_head;
	while (register_fn) {
		if (first_group_name) {
			fprintf(f, "%s", register_fn->name);
			first_group_name = false;
		} else {
			fprintf(f, ", %s", register_fn->name);
		curr_entry_len = strlen(register_fn->name);
		if ((curr_line_len + curr_entry_len + separator_len > MAX_LINE_LENGTH)) {
			fprintf(f, "\n%s", LINE_PREFIX);
			curr_line_len = prefix_len;
		}

		fprintf(f, "%s%s", register_fn->name, ENTRY_SEPARATOR);
		curr_line_len += curr_entry_len + separator_len;

		if (register_fn->next == NULL) {
			if (curr_line_len + strlen(last_entry) > MAX_LINE_LENGTH) {
				fprintf(f, " ");
			}
			fprintf(f, "%s\n", last_entry);
			break;
		}

		register_fn = register_fn->next;
	}

	fprintf(f, ", all)\n");
	fprintf(f, "                           tpoint_mask - tracepoint mask for enabling individual");
	fprintf(f, " tpoints inside a tracepoint group.");
	fprintf(f, " First tpoint inside a group can be");
	fprintf(f, " enabled by setting tpoint_mask to 1 (e.g. bdev:0x1).\n");
	fprintf(f, "                            Groups and masks can be combined (e.g.");
	fprintf(f, " thread,bdev:0x1).\n");
	fprintf(f, "                            All available tpoints can be found in");
	fprintf(f, " /include/spdk_internal/trace_defs.h\n");
	fprintf(f, "%stpoint_mask - tracepoint mask for enabling individual tpoints inside\n",
		LINE_PREFIX);
	fprintf(f, "%sa tracepoint group. First tpoint inside a group can be enabled by\n",
		LINE_PREFIX);
	fprintf(f, "%ssetting tpoint_mask to 1 (e.g. bdev:0x1). Groups and masks can be\n",
		LINE_PREFIX);
	fprintf(f, "%scombined (e.g. thread,bdev:0x1). All available tpoints can be found\n",
		LINE_PREFIX);
	fprintf(f, "%sin /include/spdk_internal/trace_defs.h\n", LINE_PREFIX);
}

void