tools/tracing/rtla/src/osnoise.c

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

File Facts

System
Linux kernel
Corpus path
tools/tracing/rtla/src/osnoise.c
Extension
.c
Size
33271 bytes
Lines
1385
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

else if (tool->trace.missed_events > 0) {
		total_events = tool->trace.processed_events + tool->trace.missed_events;

		printf("%lld (%.2f%%) events missed, results might not be accurate\n",
		       tool->trace.missed_events,
		       (double) tool->trace.missed_events / total_events * 100.0);
	}
}

/*
 * osnoise_apply_config - apply osnoise configs to the initialized tool
 */
int
osnoise_apply_config(struct osnoise_tool *tool, struct osnoise_params *params)
{
	int retval;

	params->common.kernel_workload = true;

	if (params->runtime || params->period) {
		retval = osnoise_set_runtime_period(tool->context,
						    params->runtime,
						    params->period);
	} else {
		retval = osnoise_set_runtime_period(tool->context,
						    DEFAULT_SAMPLE_PERIOD,
						    DEFAULT_SAMPLE_RUNTIME);
	}

	if (retval) {
		err_msg("Failed to set runtime and/or period\n");
		goto out_err;
	}

	retval = osnoise_set_tracing_thresh(tool->context, params->threshold);
	if (retval) {
		err_msg("Failed to set tracing_thresh\n");
		goto out_err;
	}

	return common_apply_config(tool, &params->common);

out_err:
	return -1;
}

int osnoise_enable(struct osnoise_tool *tool)
{
	struct osnoise_params *params = to_osnoise_params(tool->params);
	int retval;

	/*
	 * Start the tracer here, after having set all instances.
	 *
	 * Let the trace instance start first for the case of hitting a stop
	 * tracing while enabling other instances. The trace instance is the
	 * one with most valuable information.
	 */
	if (tool->record)
		trace_instance_start(&tool->record->trace);
	trace_instance_start(&tool->trace);

	if (params->common.warmup > 0) {
		debug_msg("Warming up for %d seconds\n", params->common.warmup);
		sleep(params->common.warmup);
		if (stop_tracing)
			return -1;

		/*
		 * Clean up the buffer. The osnoise workload do not run
		 * with tracing off to avoid creating a performance penalty
		 * when not needed.
		 */
		retval = tracefs_instance_file_write(tool->trace.inst, "trace", "");
		if (retval < 0) {
			debug_msg("Error cleaning up the buffer");
			return retval;
		}
	}

	retval = osn_set_stop(tool);
	if (retval)
		return retval;

	return 0;
}

__noreturn static void osnoise_usage(int err)
{
	int i;

Annotation

Implementation Notes