tools/tracing/rtla/src/cli.c

Source file repositories/reference/linux-study-clean/tools/tracing/rtla/src/cli.c

File Facts

System
Linux kernel
Corpus path
tools/tracing/rtla/src/cli.c
Extension
.c
Size
13300 bytes
Lines
540
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (C) 2021 Red Hat Inc, Daniel Bristot de Oliveira <bristot@kernel.org>
 */

#define _GNU_SOURCE
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>

#include <linux/compiler.h>

#define RTLA_ALLOW_CLI_P_H
#include "cli_p.h"

static const char * const osnoise_top_usage[] = {
	"rtla osnoise [top] [<options>] [-h|--help]",
	NULL,
};

static const char * const osnoise_hist_usage[] = {
	"rtla osnoise hist [<options>] [-h|--help]",
	NULL,
};

static const char * const timerlat_top_usage[] = {
	"rtla timerlat [top] [<options>] [-h|--help]",
	NULL,
};

static const char * const timerlat_hist_usage[] = {
	"rtla timerlat hist [<options>] [-h|--help]",
	NULL,
};

static const char * const hwnoise_usage[] = {
	"rtla hwnoise [<options>] [-h|--help]",
	NULL,
};

static const int common_parse_options_flags = PARSE_OPT_OPTARG_ALLOW_NEXT;

bool in_unit_test;

/*
 * osnoise_top_parse_args - allocs, parse and fill the cmd line parameters
 */
struct common_params *osnoise_top_parse_args(int argc, char **argv)
{
	struct osnoise_params *params;
	struct osnoise_cb_data cb_data;
	const char * const *usage;

	params = calloc_fatal(1, sizeof(*params));

	cb_data.params = params;
	cb_data.trace_output = NULL;

	if (strcmp(argv[0], "hwnoise") == 0) {
		params->mode = MODE_HWNOISE;
		/*
		 * Reduce CPU usage for 75% to avoid killing the system.
		 */
		params->runtime = 750000;
		params->period = 1000000;
		usage = hwnoise_usage;
	} else {
		usage = osnoise_top_usage;
	}

	const struct option osnoise_top_options[] = {
	OPT_GROUP("Tracing Options:"),
		OSNOISE_OPT_PERIOD,
		OSNOISE_OPT_RUNTIME,
		RTLA_OPT_STOP('s', "stop", "single sample"),
		RTLA_OPT_STOP_TOTAL('S', "stop-total", "total sample"),
		OSNOISE_OPT_THRESHOLD,
		RTLA_OPT_TRACE_OUTPUT("osnoise", opt_osnoise_trace_output_cb),

	OPT_GROUP("Event Configuration:"),
		RTLA_OPT_EVENT,
		RTLA_OPT_FILTER,
		RTLA_OPT_TRIGGER,

	OPT_GROUP("CPU Configuration:"),
		RTLA_OPT_CPUS,
		RTLA_OPT_HOUSEKEEPING,

Annotation

Implementation Notes