tools/tracing/rtla/src/timerlat.c

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

File Facts

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

if (retval) {
			debug_msg("Could not enable BPF\n");
			params->mode = TRACING_MODE_TRACEFS;
		}
	}

	/* Check if BPF action program is requested but BPF is not available */
	if (params->bpf_action_program) {
		if (params->mode == TRACING_MODE_TRACEFS) {
			err_msg("BPF actions are not supported in tracefs-only mode\n");
			goto out_err;
		}

		if (timerlat_load_bpf_action_program(params->bpf_action_program))
			goto out_err;
	}

	retval = osnoise_set_timerlat_period_us(tool->context,
						params->timerlat_period_us ?
						params->timerlat_period_us :
						DEFAULT_TIMERLAT_PERIOD);
	if (retval) {
		err_msg("Failed to set timerlat period\n");
		goto out_err;
	}


	retval = osnoise_set_print_stack(tool->context, params->print_stack);
	if (retval) {
		err_msg("Failed to set print stack\n");
		goto out_err;
	}

	retval = osnoise_set_timerlat_align(tool->context, params->timerlat_align);
	if (retval && params->timerlat_align) {
		/*
		 * We might be running on a kernel that does not support timerlat align.
		 * Unless user requested it explicitly, ignore the error.
		 */
		err_msg("Failed to enable timerlat align\n");
		goto out_err;
	}

	if (params->timerlat_align) {
		retval = osnoise_set_timerlat_align_us(tool->context, params->timerlat_align_us);
		if (retval) {
			err_msg("Failed to set timerlat align us\n");
			goto out_err;
		}
	}

	/*
	 * If the user did not specify a type of thread, try user-threads first.
	 * Fall back to kernel threads otherwise.
	 */
	if (!params->common.kernel_workload && !params->common.user_data) {
		retval = tracefs_file_exists(NULL, "osnoise/per_cpu/cpu0/timerlat_fd");
		if (retval) {
			debug_msg("User-space interface detected, setting user-threads\n");
			params->common.user_workload = 1;
			params->common.user_data = 1;
		} else {
			debug_msg("User-space interface not detected, setting kernel-threads\n");
			params->common.kernel_workload = 1;
		}
	}

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

out_err:
	return -1;
}

int timerlat_enable(struct osnoise_tool *tool)
{
	struct timerlat_params *params = to_timerlat_params(tool->params);
	int retval, i;

	if (params->dma_latency >= 0) {
		dma_latency_fd = set_cpu_dma_latency(params->dma_latency);
		if (dma_latency_fd < 0) {
			err_msg("Could not set /dev/cpu_dma_latency.\n");
			return -1;
		}
	}

	if (params->deepest_idle_state >= -1) {
		if (!have_libcpupower_support()) {
			err_msg("rtla built without libcpupower, --deepest-idle-state is not supported\n");
			return -1;

Annotation

Implementation Notes