From nobody Fri Dec 19 09:01:16 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88A072765D4 for ; Wed, 8 Oct 2025 19:59:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759953587; cv=none; b=bV/V7aVFCCo6pcQzqx/P/DUBpTIZNJyDjx1h6lqoBVqr4wG1bPeUm0/EzjTklOnRMJLHLzmBnifhOsb1ukNmf0n3VbdWt01Hu2nSuNlX8bYkNsN2R3yYqWVxq8embkeHUD/5h37fnHCopBjJ9qr0ccL9f/g76Gr2cj2lVQeuSUU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759953587; c=relaxed/simple; bh=CRKT0zHaJsmMMPFRY30kXvlz/uFynjoNQgPPm8aii/M=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lCuBt+27YAylKcuZF7/KU8tmFFdkfDVSS+oSPSVP7NokQUCt0VpGtdHjCYXZ6F7R+FVRLJssr5BfausyHM+GXNXLhKKwFWMnAuVUSZCXo1zZv9M7tFFoP41EDAhHi6ZNLUn4Owi3pJ2JCvDq4IdM1+nlaQwu4WYCs64ikBLHkZ8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=MPnL2XYd; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MPnL2XYd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759953583; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+cZMwP8GHtA17xgNAph6/8ACuSnK7f/y0DObajTtxvg=; b=MPnL2XYdl87AmU1XaBsigNqu5xwXM9KJkBoVd6OlsQWsoCybSkspCe+OczCvyGofQZfQod PD3HEMXXgGW6HutKCDxNgLEpsFdlgze/OzlPyMRwZZBmrdEjO5h9saimaLgYXfWDHhdcY/ Us+SF7g0cdGifTk7DCF1SNMbd4QZaFo= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-283-PQ3pN9GsP76w_z-yv9acOQ-1; Wed, 08 Oct 2025 15:59:42 -0400 X-MC-Unique: PQ3pN9GsP76w_z-yv9acOQ-1 X-Mimecast-MFC-AGG-ID: PQ3pN9GsP76w_z-yv9acOQ_1759953581 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3ee888281c3so297763f8f.3 for ; Wed, 08 Oct 2025 12:59:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759953581; x=1760558381; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+cZMwP8GHtA17xgNAph6/8ACuSnK7f/y0DObajTtxvg=; b=QTL4USTsQ/PHFYoiw1dwjb58Dy1xUuGf1e2cw6hcdHaY4KnwLB5UQcQen3qVBYP95E mBdVhrYpXUma2ZTwaV9pbDmR0FiCrBTaijdTqwTc9IdmZmDu6mXNV2qGYrycFvDERDdp M8ICcM0KwzVp6GOhA475r5WLi+nQKsoKtQzzXYPTpxkbNEXu0GpXRvt+CcOa68xOhf+9 KbUAbAmDAJC9SbA2KHa/QDwyCQ1G9TJvEZPd8pyaPe8lEf3QqLGOu7wPouWmmPVF5Uxb pcN+laGTzbu/1Bbq8iX/xd0ikdCL+t6I8fdxIBV2m5acDpV+gnHgXX20BHcY/BR05I0U BYow== X-Forwarded-Encrypted: i=1; AJvYcCUHF6eGe2y+24p/Y+p3LP0hBP0/FjN8FSXbEgxAvfg5lWWhE3nAVaqtTo9lPv8bIVTKp5RtSW9KY+eVtW0=@vger.kernel.org X-Gm-Message-State: AOJu0YxKt/wgHpRD8hJPmhB5FoRrm0LP/cy7pbaCGqamwLKOSX6O39EM huQpGqYEbojMSMIernhxPgsdZdwk/ENyDRF+MdkgCyvxBHW7SuKKfPUBgvbxWPjgi4mshNbDwlL aWJk7lsTVtH1P9my3K21oS6cTMnEXJmjaxOPUC2dTZohaZGycR3qDDNGg3wpEXWD8pw== X-Gm-Gg: ASbGncs11OgkXMiPiL6Z0UUQ+05QqzbCM8+ymevgNgYpaXCpMFtkHE5+aOqnobcrwmj +i6OsRh57iVvCstAQu948V+mYlPRL4uV78M2fC44vHwL8YzfYoxYRp49ZXz6CPYaZl7GgqqnJOg TQcaLNBKp0PlaqXcn364youjBtiEU1zqUwF45n9nx1nGFA9FZW6ZgIzCE+Sa1nC3FayrwkLkTEL 9rdRNMNII7/gMoPGa9hTMLBX8X//rN9RYBTtztC2HUvuXO0pM5cVhUL8xqEt/HsMtXMoTGN/cHH g86OtgrC4fJINU2ieYTMaXLlvQ8g51uHlFzNc9q2gxwUGZHdH5/NuVoWHMu8tCI= X-Received: by 2002:a05:6000:2285:b0:3ec:8c8:7b79 with SMTP id ffacd0b85a97d-4266e8e0bdfmr3310577f8f.61.1759953580689; Wed, 08 Oct 2025 12:59:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfAwACgTy90U+LNji26blXmsunNiKU4IHbAI1WMq5TErQiyIORWBh+WcrtQFB96YvpUkvMug== X-Received: by 2002:a05:6000:2285:b0:3ec:8c8:7b79 with SMTP id ffacd0b85a97d-4266e8e0bdfmr3310560f8f.61.1759953580176; Wed, 08 Oct 2025 12:59:40 -0700 (PDT) Received: from costa-tp.redhat.com ([2a00:a041:e2eb:5500:8728:d68a:a687:c89b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8efffasm31209583f8f.41.2025.10.08.12.59.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Oct 2025 12:59:39 -0700 (PDT) From: Costa Shulyupin To: Steven Rostedt , Tomas Glozar , Costa Shulyupin , Crystal Wood , John Kacur , Jan Stancek , Tiezhu Yang , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/5] tools/rtla: Add fatal() and replace error handling pattern Date: Wed, 8 Oct 2025 22:59:01 +0300 Message-ID: <20251008195905.333514-2-costa.shul@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251008195905.333514-1-costa.shul@redhat.com> References: <20251008195905.333514-1-costa.shul@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The code contains some technical debt in error handling, which complicates the consolidation of duplicated code. Introduce an fatal() function to replace the common pattern of err_msg() followed by exit(EXIT_FAILURE), reducing the length of an already long function. Further patches using fatal() follow. Signed-off-by: Costa Shulyupin Reviewed-by: Crystal Wood --- tools/tracing/rtla/src/osnoise_hist.c | 42 ++++++++-------------- tools/tracing/rtla/src/osnoise_top.c | 42 ++++++++-------------- tools/tracing/rtla/src/timerlat_hist.c | 50 +++++++++----------------- tools/tracing/rtla/src/timerlat_top.c | 48 +++++++++---------------- tools/tracing/rtla/src/timerlat_u.c | 12 +++---- tools/tracing/rtla/src/utils.c | 14 ++++++++ tools/tracing/rtla/src/utils.h | 1 + 7 files changed, 80 insertions(+), 129 deletions(-) diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src= /osnoise_hist.c index dffb6d0a98d7..43c323521f55 100644 --- a/tools/tracing/rtla/src/osnoise_hist.c +++ b/tools/tracing/rtla/src/osnoise_hist.c @@ -592,10 +592,8 @@ static struct common_params break; case 'e': tevent =3D trace_event_alloc(optarg); - if (!tevent) { - err_msg("Error alloc trace event"); - exit(EXIT_FAILURE); - } + if (!tevent) + fatal("Error alloc trace event"); =20 if (params->common.events) tevent->next =3D params->common.events; @@ -615,10 +613,8 @@ static struct common_params case 'H': params->common.hk_cpus =3D 1; retval =3D parse_cpu_set(optarg, ¶ms->common.hk_cpu_set); - if (retval) { - err_msg("Error parsing house keeping CPUs\n"); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Error parsing house keeping CPUs\n"); break; case 'p': params->period =3D get_llong_from_str(optarg); @@ -671,10 +667,8 @@ static struct common_params case '4': /* trigger */ if (params->common.events) { retval =3D trace_event_add_trigger(params->common.events, optarg); - if (retval) { - err_msg("Error adding trigger %s\n", optarg); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Error adding trigger %s\n", optarg); } else { osnoise_hist_usage("--trigger requires a previous -e\n"); } @@ -682,10 +676,8 @@ static struct common_params case '5': /* filter */ if (params->common.events) { retval =3D trace_event_add_filter(params->common.events, optarg); - if (retval) { - err_msg("Error adding filter %s\n", optarg); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Error adding filter %s\n", optarg); } else { osnoise_hist_usage("--filter requires a previous -e\n"); } @@ -699,18 +691,14 @@ static struct common_params case '8': retval =3D actions_parse(¶ms->common.threshold_actions, optarg, "osnoise_trace.txt"); - if (retval) { - err_msg("Invalid action %s\n", optarg); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Invalid action %s\n", optarg); break; case '9': retval =3D actions_parse(¶ms->common.end_actions, optarg, "osnoise_trace.txt"); - if (retval) { - err_msg("Invalid action %s\n", optarg); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Invalid action %s\n", optarg); break; default: osnoise_hist_usage("Invalid option"); @@ -720,10 +708,8 @@ static struct common_params if (trace_output) actions_add_trace_output(¶ms->common.threshold_actions, trace_output= ); =20 - if (geteuid()) { - err_msg("rtla needs root permission\n"); - exit(EXIT_FAILURE); - } + if (geteuid()) + fatal("rtla needs root permission\n"); =20 if (params->common.hist.no_index && !params->common.hist.with_zeros) osnoise_hist_usage("no-index set and with-zeros not set - it does not ma= ke sense"); diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/= osnoise_top.c index 95418f7ecc96..43fb50b5d936 100644 --- a/tools/tracing/rtla/src/osnoise_top.c +++ b/tools/tracing/rtla/src/osnoise_top.c @@ -426,10 +426,8 @@ struct common_params *osnoise_top_parse_args(int argc,= char **argv) break; case 'e': tevent =3D trace_event_alloc(optarg); - if (!tevent) { - err_msg("Error alloc trace event"); - exit(EXIT_FAILURE); - } + if (!tevent) + fatal("Error alloc trace event"); =20 if (params->common.events) tevent->next =3D params->common.events; @@ -443,10 +441,8 @@ struct common_params *osnoise_top_parse_args(int argc,= char **argv) case 'H': params->common.hk_cpus =3D 1; retval =3D parse_cpu_set(optarg, ¶ms->common.hk_cpu_set); - if (retval) { - err_msg("Error parsing house keeping CPUs\n"); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Error parsing house keeping CPUs\n"); break; case 'p': params->period =3D get_llong_from_str(optarg); @@ -490,10 +486,8 @@ struct common_params *osnoise_top_parse_args(int argc,= char **argv) case '0': /* trigger */ if (params->common.events) { retval =3D trace_event_add_trigger(params->common.events, optarg); - if (retval) { - err_msg("Error adding trigger %s\n", optarg); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Error adding trigger %s\n", optarg); } else { osnoise_top_usage(params, "--trigger requires a previous -e\n"); } @@ -501,10 +495,8 @@ struct common_params *osnoise_top_parse_args(int argc,= char **argv) case '1': /* filter */ if (params->common.events) { retval =3D trace_event_add_filter(params->common.events, optarg); - if (retval) { - err_msg("Error adding filter %s\n", optarg); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Error adding filter %s\n", optarg); } else { osnoise_top_usage(params, "--filter requires a previous -e\n"); } @@ -518,18 +510,14 @@ struct common_params *osnoise_top_parse_args(int argc= , char **argv) case '4': retval =3D actions_parse(¶ms->common.threshold_actions, optarg, "osnoise_trace.txt"); - if (retval) { - err_msg("Invalid action %s\n", optarg); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Invalid action %s\n", optarg); break; case '5': retval =3D actions_parse(¶ms->common.end_actions, optarg, "osnoise_trace.txt"); - if (retval) { - err_msg("Invalid action %s\n", optarg); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Invalid action %s\n", optarg); break; default: osnoise_top_usage(params, "Invalid option"); @@ -539,10 +527,8 @@ struct common_params *osnoise_top_parse_args(int argc,= char **argv) if (trace_output) actions_add_trace_output(¶ms->common.threshold_actions, trace_output= ); =20 - if (geteuid()) { - err_msg("osnoise needs root permission\n"); - exit(EXIT_FAILURE); - } + if (geteuid()) + fatal("osnoise needs root permission\n"); =20 return ¶ms->common; } diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/sr= c/timerlat_hist.c index 606c1688057b..6504556be5e4 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -913,10 +913,8 @@ static struct common_params break; case 'e': tevent =3D trace_event_alloc(optarg); - if (!tevent) { - err_msg("Error alloc trace event"); - exit(EXIT_FAILURE); - } + if (!tevent) + fatal("Error alloc trace event"); =20 if (params->common.events) tevent->next =3D params->common.events; @@ -936,10 +934,8 @@ static struct common_params case 'H': params->common.hk_cpus =3D 1; retval =3D parse_cpu_set(optarg, ¶ms->common.hk_cpu_set); - if (retval) { - err_msg("Error parsing house keeping CPUs\n"); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Error parsing house keeping CPUs\n"); break; case 'i': params->common.stop_us =3D get_llong_from_str(optarg); @@ -1005,10 +1001,8 @@ static struct common_params case '6': /* trigger */ if (params->common.events) { retval =3D trace_event_add_trigger(params->common.events, optarg); - if (retval) { - err_msg("Error adding trigger %s\n", optarg); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Error adding trigger %s\n", optarg); } else { timerlat_hist_usage("--trigger requires a previous -e\n"); } @@ -1016,20 +1010,16 @@ static struct common_params case '7': /* filter */ if (params->common.events) { retval =3D trace_event_add_filter(params->common.events, optarg); - if (retval) { - err_msg("Error adding filter %s\n", optarg); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Error adding filter %s\n", optarg); } else { timerlat_hist_usage("--filter requires a previous -e\n"); } break; case '8': params->dma_latency =3D get_llong_from_str(optarg); - if (params->dma_latency < 0 || params->dma_latency > 10000) { - err_msg("--dma-latency needs to be >=3D 0 and < 10000"); - exit(EXIT_FAILURE); - } + if (params->dma_latency < 0 || params->dma_latency > 10000) + fatal("--dma-latency needs to be >=3D 0 and < 10000"); break; case '9': params->no_aa =3D 1; @@ -1049,31 +1039,25 @@ static struct common_params case '\5': retval =3D actions_parse(¶ms->common.threshold_actions, optarg, "timerlat_trace.txt"); - if (retval) { - err_msg("Invalid action %s\n", optarg); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Invalid action %s\n", optarg); break; case '\6': retval =3D actions_parse(¶ms->common.end_actions, optarg, "timerlat_trace.txt"); - if (retval) { - err_msg("Invalid action %s\n", optarg); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Invalid action %s\n", optarg); break; default: - timerlat_hist_usage("Invalid option"); + fatal("Invalid option\n"); } } =20 if (trace_output) actions_add_trace_output(¶ms->common.threshold_actions, trace_output= ); =20 - if (geteuid()) { - err_msg("rtla needs root permission\n"); - exit(EXIT_FAILURE); - } + if (geteuid()) + fatal("rtla needs root permission\n"); =20 if (params->common.hist.no_irq && params->common.hist.no_thread) timerlat_hist_usage("no-irq and no-thread set, there is nothing to do he= re"); diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index fc479a0dcb59..03ecc38d0719 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -671,10 +671,8 @@ static struct common_params break; case 'e': tevent =3D trace_event_alloc(optarg); - if (!tevent) { - err_msg("Error alloc trace event"); - exit(EXIT_FAILURE); - } + if (!tevent) + fatal("Error alloc trace event"); =20 if (params->common.events) tevent->next =3D params->common.events; @@ -687,10 +685,8 @@ static struct common_params case 'H': params->common.hk_cpus =3D 1; retval =3D parse_cpu_set(optarg, ¶ms->common.hk_cpu_set); - if (retval) { - err_msg("Error parsing house keeping CPUs\n"); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Error parsing house keeping CPUs\n"); break; case 'i': params->common.stop_us =3D get_llong_from_str(optarg); @@ -741,10 +737,8 @@ static struct common_params case '0': /* trigger */ if (params->common.events) { retval =3D trace_event_add_trigger(params->common.events, optarg); - if (retval) { - err_msg("Error adding trigger %s\n", optarg); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Error adding trigger %s\n", optarg); } else { timerlat_top_usage("--trigger requires a previous -e\n"); } @@ -752,20 +746,16 @@ static struct common_params case '1': /* filter */ if (params->common.events) { retval =3D trace_event_add_filter(params->common.events, optarg); - if (retval) { - err_msg("Error adding filter %s\n", optarg); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Error adding filter %s\n", optarg); } else { timerlat_top_usage("--filter requires a previous -e\n"); } break; case '2': /* dma-latency */ params->dma_latency =3D get_llong_from_str(optarg); - if (params->dma_latency < 0 || params->dma_latency > 10000) { - err_msg("--dma-latency needs to be >=3D 0 and < 10000"); - exit(EXIT_FAILURE); - } + if (params->dma_latency < 0 || params->dma_latency > 10000) + fatal("--dma-latency needs to be >=3D 0 and < 10000"); break; case '3': /* no-aa */ params->no_aa =3D 1; @@ -785,18 +775,14 @@ static struct common_params case '9': retval =3D actions_parse(¶ms->common.threshold_actions, optarg, "timerlat_trace.txt"); - if (retval) { - err_msg("Invalid action %s\n", optarg); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Invalid action %s\n", optarg); break; case '\1': retval =3D actions_parse(¶ms->common.end_actions, optarg, "timerlat_trace.txt"); - if (retval) { - err_msg("Invalid action %s\n", optarg); - exit(EXIT_FAILURE); - } + if (retval) + fatal("Invalid action %s\n", optarg); break; default: timerlat_top_usage("Invalid option"); @@ -806,10 +792,8 @@ static struct common_params if (trace_output) actions_add_trace_output(¶ms->common.threshold_actions, trace_output= ); =20 - if (geteuid()) { - err_msg("rtla needs root permission\n"); - exit(EXIT_FAILURE); - } + if (geteuid()) + fatal("rtla needs root permission\n"); =20 /* * Auto analysis only happens if stop tracing, thus: diff --git a/tools/tracing/rtla/src/timerlat_u.c b/tools/tracing/rtla/src/t= imerlat_u.c index 01dbf9a6b5a5..2f85c242e1d5 100644 --- a/tools/tracing/rtla/src/timerlat_u.c +++ b/tools/tracing/rtla/src/timerlat_u.c @@ -51,10 +51,8 @@ static int timerlat_u_main(int cpu, struct timerlat_u_pa= rams *params) =20 if (!params->sched_param) { retval =3D sched_setscheduler(0, SCHED_FIFO, &sp); - if (retval < 0) { - err_msg("Error setting timerlat u default priority: %s\n", strerror(err= no)); - exit(1); - } + if (retval < 0) + fatal("Error setting timerlat u default priority: %s\n", strerror(errno= )); } else { retval =3D __set_sched_attr(getpid(), params->sched_param); if (retval) { @@ -78,10 +76,8 @@ static int timerlat_u_main(int cpu, struct timerlat_u_pa= rams *params) snprintf(buffer, sizeof(buffer), "osnoise/per_cpu/cpu%d/timerlat_fd", cpu= ); =20 timerlat_fd =3D tracefs_instance_file_open(NULL, buffer, O_RDONLY); - if (timerlat_fd < 0) { - err_msg("Error opening %s:%s\n", buffer, strerror(errno)); - exit(1); - } + if (timerlat_fd < 0) + fatal("Error opening %s:%s\n", buffer, strerror(errno)); =20 debug_msg("User-space timerlat pid %d on cpu %d\n", gettid(), cpu); =20 diff --git a/tools/tracing/rtla/src/utils.c b/tools/tracing/rtla/src/utils.c index d6ab15dcb490..bf3662313cde 100644 --- a/tools/tracing/rtla/src/utils.c +++ b/tools/tracing/rtla/src/utils.c @@ -38,6 +38,20 @@ void err_msg(const char *fmt, ...) fprintf(stderr, "%s", message); } =20 +/* + * fatal - print an error message to stderr and exit with ERROR + */ +void fatal(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + + exit(ERROR); +} + /* * debug_msg - print a debug message to stderr if debug is set */ diff --git a/tools/tracing/rtla/src/utils.h b/tools/tracing/rtla/src/utils.h index a2a6f89f342d..1be095f9a7e6 100644 --- a/tools/tracing/rtla/src/utils.h +++ b/tools/tracing/rtla/src/utils.h @@ -19,6 +19,7 @@ extern int config_debug; void debug_msg(const char *fmt, ...); void err_msg(const char *fmt, ...); +void fatal(const char *fmt, ...); =20 long parse_seconds_duration(char *val); void get_duration(time_t start_time, char *output, int output_size); --=20 2.51.0 From nobody Fri Dec 19 09:01:16 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 327292797BD for ; Wed, 8 Oct 2025 19:59:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759953591; cv=none; b=DE8MVB/vIIjnQtvlfpQePA5BQfROC/TcY/eP6sBsmtFT/DMB32YakZXJ0B1MP7EzvC1skd4tW36DnLJkzEyW6HfeQCXbEFi/SJWU8Gn2J/983AV3CMzklAu7zF8MPgozOOpjNl55nXcV+JZSJ/Os9+yefVQneeAYtAaROk4WfwU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759953591; c=relaxed/simple; bh=R01JDrYPf3T7tS3r0JRwFP7avSmaK3pXhJTdNJHaQRo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qXuRWZU4AYfVH9xqMjP4ULkYt+8CjbWvkoVNQajNiDK46MEPA43V58enk03JcC7Hx3MCacKxxxELrazUuksssILi1mTcQx6iRLpty7iqZo14l6FdsMnO8e7k2dhDIaeGCgk31d7RuTYx5q2LcTdIH1dUcmRm4180CW57Tvr79Ww= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CAqPrCTu; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CAqPrCTu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759953589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+sd0fKPLWAqOh4kQ/TQyBqgyJmAhPlQ/8KNnD12Elio=; b=CAqPrCTuiKJizR/5ZPhVBTJvL6Mc9iX01X9TGhciHZUwDSsSKo3IVeN1ptB3BjI9JyMWMF HBfMFIUNEIJtPft4uVmtYNBl0v/ab7xPtYgACyezuNGQS9ftdAl/yNNm7hZb8weoSFJEzO srDXPeJznEmHeLPs0WnxwRTtrzM3zkM= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-55-QCRKHeMxOoul_pAMrlT0Tg-1; Wed, 08 Oct 2025 15:59:48 -0400 X-MC-Unique: QCRKHeMxOoul_pAMrlT0Tg-1 X-Mimecast-MFC-AGG-ID: QCRKHeMxOoul_pAMrlT0Tg_1759953587 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3ecdd80ea44so223769f8f.1 for ; Wed, 08 Oct 2025 12:59:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759953587; x=1760558387; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+sd0fKPLWAqOh4kQ/TQyBqgyJmAhPlQ/8KNnD12Elio=; b=DS/Pzb0VhasPguXN5n15+MG02DhOB2B12WtLuM8x6baynM7l2bA6zLFW2CAG0/W6CY 2Ui22xz93e0AnOAW9m8NwO3w/cN8jE1S58fud1sB8bSb3Z29MDxL3Qg0Vu4uqAAbYlqS zIX0UxWik9hyBrVZBrZHg6b5MH1PseYV2/cdS/KhtPFZsC0Z8Phi498/xyMVdIU7OfiZ +2nsT+4dhgePOEXrLZ0Kmrh18/Vsi+PsNrz2V1OmLtjEYM7IMqrtzusACHbuw95xC7V4 8Xq22rfOX77/S9GQ7fsFb5HJGxesudEd9wgXLxGpSJxdAXylJGo9yT0s9Dh456Hl/BSV T0kg== X-Forwarded-Encrypted: i=1; AJvYcCXsMz82QFt/d+pK7XT7u9fThQn/uInJH+pZIO4si3aJLiH7s1lvKchORclIqW0OKE4PTFA+4C2Z0FlOAbY=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4oKwMvMU+fGAfd8AQfgawBa/d1tuYCPobQlRbhKCL/7Pv/DDd VnHHA2KmHzkw3i0A9kYhLU/z1z0OzuPZQnMPGrH3lHlH81zOeJwSsSSxc6cfeDBgU+0KLJP12Ed +I+anUFwYK8qGhJKTe2DRvPx+5gTcp+TPDUv0ccSie48IUrEqfo2yzFNifN8ZZhS4GQ== X-Gm-Gg: ASbGncs5X3RVOIZogfzRQ/rrMXbWSrQzwH7cFodZrzfynyF3wnkpyNHDZ2JcjOKz14L T5/gn8oi3vvEruOYhBtUtvYrS+PKHZf5qYwChKvO4vCm+4weDVGT2pdv+EeVSh2rRWi8ChEFQsY eqnp6FbK37NIIsLMEtF0vqqizemdwX7Q0279Fd3tO7ZDI4z6rxbOeC18GXfJDujBvi5AXGkTyBk H335GWvNwpjfay8A5jfDlyVuL0/McL74w7FjkHfCRIrcoipAwpwSJaCEdKGGv+IXZHj9geWrbSZ i5bBqmbOk/FeXw802HANc3cbXOfI+vOyozMqHIisOaC7FRK19aKA9304CAAej5o= X-Received: by 2002:a5d:5d85:0:b0:3d6:4596:8a3a with SMTP id ffacd0b85a97d-4266e7bf18emr3491659f8f.17.1759953586773; Wed, 08 Oct 2025 12:59:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEikjmlhNc/NKttcfoUG4lvNDzYLqq7gREx7dIbaipV6H4Hv0NV9ovVs6yS45bS8y/EUjzCng== X-Received: by 2002:a5d:5d85:0:b0:3d6:4596:8a3a with SMTP id ffacd0b85a97d-4266e7bf18emr3491651f8f.17.1759953586318; Wed, 08 Oct 2025 12:59:46 -0700 (PDT) Received: from costa-tp.redhat.com ([2a00:a041:e2eb:5500:8728:d68a:a687:c89b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8efffasm31209583f8f.41.2025.10.08.12.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Oct 2025 12:59:45 -0700 (PDT) From: Costa Shulyupin To: Steven Rostedt , Tomas Glozar , Costa Shulyupin , Crystal Wood , John Kacur , Jan Stancek , Tiezhu Yang , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 2/5] tools/rtla: Replace timerlat_top_usage("...") with fatal("...") Date: Wed, 8 Oct 2025 22:59:02 +0300 Message-ID: <20251008195905.333514-3-costa.shul@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251008195905.333514-1-costa.shul@redhat.com> References: <20251008195905.333514-1-costa.shul@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A long time ago, when the usage help was short, it was a favor to the user to show it on error. Now that the usage help has become very long, it is too noisy to dump the complete help text for each typo after the error message itself. Replace timerlat_top_usage("...") with fatal("...") on errors. Remove the already unused 'usage' argument from timerlat_top_usage(). Signed-off-by: Costa Shulyupin --- tools/tracing/rtla/src/timerlat_top.c | 32 +++++++++++---------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index 03ecc38d0719..81b9c8c59c06 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -476,7 +476,7 @@ timerlat_print_stats(struct osnoise_tool *top) /* * timerlat_top_usage - prints timerlat top usage message */ -static void timerlat_top_usage(char *usage) +static void timerlat_top_usage(void) { int i; =20 @@ -524,18 +524,12 @@ static void timerlat_top_usage(char *usage) NULL, }; =20 - if (usage) - fprintf(stderr, "%s\n", usage); - fprintf(stderr, "rtla timerlat top: a per-cpu summary of the timer latenc= y (version %s)\n", VERSION); =20 for (i =3D 0; msg[i]; i++) fprintf(stderr, "%s\n", msg[i]); =20 - if (usage) - exit(EXIT_FAILURE); - exit(EXIT_SUCCESS); } =20 @@ -648,7 +642,7 @@ static struct common_params case 'c': retval =3D parse_cpu_set(optarg, ¶ms->common.monitored_cpus); if (retval) - timerlat_top_usage("\nInvalid -c cpu list\n"); + fatal("\nInvalid -c cpu list\n"); params->common.cpus =3D optarg; break; case 'C': @@ -667,12 +661,12 @@ static struct common_params case 'd': params->common.duration =3D parse_seconds_duration(optarg); if (!params->common.duration) - timerlat_top_usage("Invalid -d duration\n"); + fatal("Invalid -d duration\n"); break; case 'e': tevent =3D trace_event_alloc(optarg); if (!tevent) - fatal("Error alloc trace event"); + fatal("Error alloc trace event\n"); =20 if (params->common.events) tevent->next =3D params->common.events; @@ -680,7 +674,7 @@ static struct common_params break; case 'h': case '?': - timerlat_top_usage(NULL); + timerlat_top_usage(); break; case 'H': params->common.hk_cpus =3D 1; @@ -700,12 +694,12 @@ static struct common_params case 'p': params->timerlat_period_us =3D get_llong_from_str(optarg); if (params->timerlat_period_us > 1000000) - timerlat_top_usage("Period longer than 1 s\n"); + fatal("Period longer than 1 s\n"); break; case 'P': retval =3D parse_prio(optarg, ¶ms->common.sched_param); if (retval =3D=3D -1) - timerlat_top_usage("Invalid -P priority"); + fatal("Invalid -P priority\n"); params->common.set_sched =3D 1; break; case 'q': @@ -740,7 +734,7 @@ static struct common_params if (retval) fatal("Error adding trigger %s\n", optarg); } else { - timerlat_top_usage("--trigger requires a previous -e\n"); + fatal("--trigger requires a previous -e\n"); } break; case '1': /* filter */ @@ -749,13 +743,13 @@ static struct common_params if (retval) fatal("Error adding filter %s\n", optarg); } else { - timerlat_top_usage("--filter requires a previous -e\n"); + fatal("--filter requires a previous -e\n"); } break; case '2': /* dma-latency */ params->dma_latency =3D get_llong_from_str(optarg); if (params->dma_latency < 0 || params->dma_latency > 10000) - fatal("--dma-latency needs to be >=3D 0 and < 10000"); + fatal("--dma-latency needs to be >=3D 0 and < 10000\n"); break; case '3': /* no-aa */ params->no_aa =3D 1; @@ -785,7 +779,7 @@ static struct common_params fatal("Invalid action %s\n", optarg); break; default: - timerlat_top_usage("Invalid option"); + fatal("Invalid option\n"); } } =20 @@ -802,10 +796,10 @@ static struct common_params params->no_aa =3D 1; =20 if (params->no_aa && params->common.aa_only) - timerlat_top_usage("--no-aa and --aa-only are mutually exclusive!"); + fatal("--no-aa and --aa-only are mutually exclusive!\n"); =20 if (params->common.kernel_workload && params->common.user_workload) - timerlat_top_usage("--kernel-threads and --user-threads are mutually exc= lusive!"); + fatal("--kernel-threads and --user-threads are mutually exclusive!\n"); =20 /* * If auto-analysis or trace output is enabled, switch from BPF mode to --=20 2.51.0 From nobody Fri Dec 19 09:01:16 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 175AF27BF7D for ; Wed, 8 Oct 2025 19:59:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759953596; cv=none; b=cxcFAd1dmVz1nfrbfU26NL7qtBJJSi5utE0fd+pRatHulddLmwCZKH4qDth0nuil97LJ5cbXbB1Yt3A1mSO44CxQStaU42FiwzHUgOTrFKYs5H3D1yrA6cv54NzJVNFJArCvIOcw//WJAYzr5W7ImPXJlL/DlfbeU5Y4Pvc/E84= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759953596; c=relaxed/simple; bh=eC6iWnNBNyM2qZxYKEtLZwJZLXCisj1zl5uKGzp7UB4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oP2R1dtYAYYDh0aUTU25RjgSN/NbJ4T92TOWY09RLlbhb4HL7nf/eUkIF/CWRW8axrOA6V3tLTsoMDFqNqrtUm4FYqAl6/50SenW2TYGSnV2MHPyrN+Sb7Z1hEsKaCy+YgJAEupBfMCnvXi3O6UvQlKS5FAn6Ib3+xo5vJTVnwU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=D3T3gU7h; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="D3T3gU7h" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759953593; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cFfsvgXlRSf6rwDo6xn40BqTVmK62+JiqJARnqqZUVw=; b=D3T3gU7hwczcHYq2wu5BHZnaO6BzbMEoTkczKJNDQ/hEXySmcA+VTCZuy7umjFglYnnUsv aMSI3fDP+LqnG8R51hda9mTNqmfeJN+7KPTo5Nan714tdcYYZhuCHyJBHxXZsfYhS20cNN TbKzyRiHW2vE1GcfPWZP7EmGCwTAAiQ= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-14-QSSoH3eEOECV2Tiw0FWKyg-1; Wed, 08 Oct 2025 15:59:52 -0400 X-MC-Unique: QSSoH3eEOECV2Tiw0FWKyg-1 X-Mimecast-MFC-AGG-ID: QSSoH3eEOECV2Tiw0FWKyg_1759953591 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-42421b15185so224089f8f.1 for ; Wed, 08 Oct 2025 12:59:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759953591; x=1760558391; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cFfsvgXlRSf6rwDo6xn40BqTVmK62+JiqJARnqqZUVw=; b=RSn9ia0y37ou+QjyXezUrUPJu7IcFFG3TVCUlJv0m+gysVLjLj91GdSsYs0owM03uk svzUuwx6VF7Dw/OIdqsXiG7QzzXZxZFZ9uwRw22cc5gGccgRs80Dajlu5asemZI6sym3 CdqfCCLF8smNUGPCZz8eu8msXe7RzmM9gCC6+ACTDiiuh14ijEv+B8sMQgc8gj+jZ+SD 0dw7/3MT+tQIfs3bVZTi+c0CPhOx7OGeujGtxjzFZxsYL15vt7Gxxt5LADA8+jssJZhG 12aTyg/NyZ5Uhad31z0sPpp0nghEIzPkjZATxdE77BOJjXNo4ogznD6wUYFFalu1DXvs i6Wg== X-Forwarded-Encrypted: i=1; AJvYcCWiU6wDRO2rhfsQBpPe3it3fn823lPBuSdLvRb5OClSLImtU4HIWdQo24bd9vf14Okt2Cap5e9O4seqRWI=@vger.kernel.org X-Gm-Message-State: AOJu0YxwwNmfQnr3DBr5dpPCSZqvRuSWcPhprxaJApgTrBlZSrLjwPn0 r76jH0XaYOGxMV3CuBtShg1uFDUibMkYdJ98lqtBggvYHHGeemnZ5rHEdkveUnGWndtHMhHJhxz sS4K/5Mq534WFfSG6Bgjp/tOfjreHLMa8fiClmwbsb14Uqjg+k1CFReBAW7p70V/+ow== X-Gm-Gg: ASbGncttVfT+Od86HBHNKdJCIe8bSjDsuG+RZlpR39hj8OW7JUI1NDkhtZbjmXy+k1U U7K9U0r5I44CYWH59MWHo/5iY7LyTh5Ds7h44WxwDdY12GhxuBS+XvrdytrcehQkW3ITLACzusR pVlFGVPr0Qg9EGMER3fFXTN9pUEfPkswZTp5UX8JFOufjqfoYJ/O0gcO547ygjn50OErZJyrtWb fGxKbsnKbbR1150IPnLUtc6QYa4vuZzZn5bwB0BFdPw7SL+kjrOHx9RFvRODhtoeFzi8A/16X74 6toD56Y1IPYcw+QVdENrFcjSbkAJ55+PKJA5gAMobTRYtQJuIuk10PVZQmCeKiQ= X-Received: by 2002:a05:6000:2210:b0:407:77f9:949f with SMTP id ffacd0b85a97d-4266e7c61aemr2522386f8f.28.1759953591302; Wed, 08 Oct 2025 12:59:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFDzNUKc6b/ceMuaj4GD/u+xwcihuiULQIOyPD0gPH1NRrkBwWHaQIL25rVPGtipU8o4UOfBw== X-Received: by 2002:a05:6000:2210:b0:407:77f9:949f with SMTP id ffacd0b85a97d-4266e7c61aemr2522377f8f.28.1759953590902; Wed, 08 Oct 2025 12:59:50 -0700 (PDT) Received: from costa-tp.redhat.com ([2a00:a041:e2eb:5500:8728:d68a:a687:c89b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8efffasm31209583f8f.41.2025.10.08.12.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Oct 2025 12:59:50 -0700 (PDT) From: Costa Shulyupin To: Steven Rostedt , Tomas Glozar , Costa Shulyupin , Crystal Wood , John Kacur , Jan Stancek , Tiezhu Yang , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 3/5] tools/rtla: Replace timerlat_hist_usage("...") with fatal("...") Date: Wed, 8 Oct 2025 22:59:03 +0300 Message-ID: <20251008195905.333514-4-costa.shul@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251008195905.333514-1-costa.shul@redhat.com> References: <20251008195905.333514-1-costa.shul@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A long time ago, when the usage help was short, it was a favor to the user to show it on error. Now that the usage help has become very long, it is too noisy to dump the complete help text for each typo after the error message itself. Replace timerlat_hist_usage("...") with fatal("...") on errors. Remove the already unused 'usage' argument from timerlat_hist_usage(). Signed-off-by: Costa Shulyupin --- tools/tracing/rtla/src/timerlat_hist.c | 36 +++++++++++--------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/sr= c/timerlat_hist.c index 6504556be5e4..fcc4f2e9213b 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -710,7 +710,7 @@ timerlat_print_stats(struct osnoise_tool *tool) /* * timerlat_hist_usage - prints timerlat top usage message */ -static void timerlat_hist_usage(char *usage) +static void timerlat_hist_usage(void) { int i; =20 @@ -766,18 +766,12 @@ static void timerlat_hist_usage(char *usage) NULL, }; =20 - if (usage) - fprintf(stderr, "%s\n", usage); - fprintf(stderr, "rtla timerlat hist: a per-cpu histogram of the timer lat= ency (version %s)\n", VERSION); =20 for (i =3D 0; msg[i]; i++) fprintf(stderr, "%s\n", msg[i]); =20 - if (usage) - exit(EXIT_FAILURE); - exit(EXIT_SUCCESS); } =20 @@ -884,7 +878,7 @@ static struct common_params case 'c': retval =3D parse_cpu_set(optarg, ¶ms->common.monitored_cpus); if (retval) - timerlat_hist_usage("\nInvalid -c cpu list\n"); + fatal("\nInvalid -c cpu list\n"); params->common.cpus =3D optarg; break; case 'C': @@ -901,7 +895,7 @@ static struct common_params params->common.hist.bucket_size =3D get_llong_from_str(optarg); if (params->common.hist.bucket_size =3D=3D 0 || params->common.hist.bucket_size >=3D 1000000) - timerlat_hist_usage("Bucket size needs to be > 0 and <=3D 1000000\n"); + fatal("Bucket size needs to be > 0 and <=3D 1000000\n"); break; case 'D': config_debug =3D 1; @@ -909,12 +903,12 @@ static struct common_params case 'd': params->common.duration =3D parse_seconds_duration(optarg); if (!params->common.duration) - timerlat_hist_usage("Invalid -D duration\n"); + fatal("Invalid -D duration\n"); break; case 'e': tevent =3D trace_event_alloc(optarg); if (!tevent) - fatal("Error alloc trace event"); + fatal("Error alloc trace event\n"); =20 if (params->common.events) tevent->next =3D params->common.events; @@ -925,11 +919,11 @@ static struct common_params params->common.hist.entries =3D get_llong_from_str(optarg); if (params->common.hist.entries < 10 || params->common.hist.entries > 9999999) - timerlat_hist_usage("Entries must be > 10 and < 9999999\n"); + fatal("Entries must be > 10 and < 9999999\n"); break; case 'h': case '?': - timerlat_hist_usage(NULL); + timerlat_hist_usage(); break; case 'H': params->common.hk_cpus =3D 1; @@ -949,12 +943,12 @@ static struct common_params case 'p': params->timerlat_period_us =3D get_llong_from_str(optarg); if (params->timerlat_period_us > 1000000) - timerlat_hist_usage("Period longer than 1 s\n"); + fatal("Period longer than 1 s\n"); break; case 'P': retval =3D parse_prio(optarg, ¶ms->common.sched_param); if (retval =3D=3D -1) - timerlat_hist_usage("Invalid -P priority"); + fatal("Invalid -P priority\n"); params->common.set_sched =3D 1; break; case 's': @@ -1004,7 +998,7 @@ static struct common_params if (retval) fatal("Error adding trigger %s\n", optarg); } else { - timerlat_hist_usage("--trigger requires a previous -e\n"); + fatal("--trigger requires a previous -e\n"); } break; case '7': /* filter */ @@ -1013,13 +1007,13 @@ static struct common_params if (retval) fatal("Error adding filter %s\n", optarg); } else { - timerlat_hist_usage("--filter requires a previous -e\n"); + fatal("--filter requires a previous -e\n"); } break; case '8': params->dma_latency =3D get_llong_from_str(optarg); if (params->dma_latency < 0 || params->dma_latency > 10000) - fatal("--dma-latency needs to be >=3D 0 and < 10000"); + fatal("--dma-latency needs to be >=3D 0 and < 10000\n"); break; case '9': params->no_aa =3D 1; @@ -1060,10 +1054,10 @@ static struct common_params fatal("rtla needs root permission\n"); =20 if (params->common.hist.no_irq && params->common.hist.no_thread) - timerlat_hist_usage("no-irq and no-thread set, there is nothing to do he= re"); + fatal("no-irq and no-thread set, there is nothing to do here\n"); =20 if (params->common.hist.no_index && !params->common.hist.with_zeros) - timerlat_hist_usage("no-index set with with-zeros is not set - it does n= ot make sense"); + fatal("no-index set with with-zeros is not set - it does not make sense\= n"); =20 /* * Auto analysis only happens if stop tracing, thus: @@ -1072,7 +1066,7 @@ static struct common_params params->no_aa =3D 1; =20 if (params->common.kernel_workload && params->common.user_workload) - timerlat_hist_usage("--kernel-threads and --user-threads are mutually ex= clusive!"); + fatal("--kernel-threads and --user-threads are mutually exclusive!\n"); =20 /* * If auto-analysis or trace output is enabled, switch from BPF mode to --=20 2.51.0 From nobody Fri Dec 19 09:01:16 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B16D27877B for ; Wed, 8 Oct 2025 19:59:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759953601; cv=none; b=CkBpu9PjF+Lt+0vHRx8xnTqDy0QcXTpCSFp3DBhCKHjHHg0HUixRh3ijaQEZ8sYYgZVsJhLIsUbTbwDqymVtMKDWEuvMDfbfuz9C6sT550Y5Glk8I5znC7ChCFqrxxIuI5cwH4vxlMFTDZNH69eXyWD9dkyEO8BRvCi+OTByqhM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759953601; c=relaxed/simple; bh=YxZxGVPgrbcUQf05HaafiT1TjMGPobJaNf5XRQb6JKU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kUMOYKstBsuoc6Hz12GnhCaHXI9d3afYpKN40XmbTggvjlhMcpeTOOOaBhcxSTzoJeKSkl7ETCHZyaMDZyUbKabBispKFLWEy+LPlaj3QjSvuhwRlvKjQqXU3inT+a4oIwGnsU4Ekp5OjufHu2cePcT1icTN9gyMevJ5LlXZ0TU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=VNp8oLD8; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VNp8oLD8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759953599; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hg94taPX5CGEY2YLQCYWgTJzRNpALaMB5K0LUWzUztM=; b=VNp8oLD8IsyVE6aIJN5gpx/BOnCXoOjHpwUCCr/fU8dlMY1ZiIFu2h2rDYM9RsnbuLXBBp FIsgMixRz0xuc1Is7/nhrDegfl8IkUf89JmBC7V4ZlbNhz+/Lji+yR9aFYlZZzggq7xxxL v6G9mCikf/TbzLvFZgniY7lr4/fjkGw= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-657-PrE_mHe7NseyPSNWdqaQDw-1; Wed, 08 Oct 2025 15:59:58 -0400 X-MC-Unique: PrE_mHe7NseyPSNWdqaQDw-1 X-Mimecast-MFC-AGG-ID: PrE_mHe7NseyPSNWdqaQDw_1759953597 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-40fd1b17d2bso125751f8f.1 for ; Wed, 08 Oct 2025 12:59:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759953597; x=1760558397; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hg94taPX5CGEY2YLQCYWgTJzRNpALaMB5K0LUWzUztM=; b=NOwhadcrkFt3o9g4NFAi9scng+JpXN2gwKiSNIc1SpN8M3qOJuC5WueB9pC3dnu57c eSGIpfEmVgcZxZKiOs8z1Ll8M+tFyIh7DdbC7cV0fUmAkcKaFWxU2GvzFlLs66pS3+NX VkDMKE45KeYt5tI7pn0ADrt24G2uWgeTulcd12HmsvZspxNRkJgLQjQD9jyRiP3MfomU nBiNIsNY7nzXb8XNpgEz+On/0cBfM2knnf2xQHqLVmxKVcciMalmbq5YeN3yMgs3vBrd 8lDTKlDdISJ5Sj4crtOYierMzfaJZj0GDHwfL7gJbpDXtTZ7EVdknyzu1xrcr41zwgFQ IF0A== X-Forwarded-Encrypted: i=1; AJvYcCUwc8yWV0cPFzXRmYQnmGkuGn+J4dQAORbYOLGrNBwGysaliFuUAfjP4c0RZA7SqsNxwlJRA1T1MV6kiTI=@vger.kernel.org X-Gm-Message-State: AOJu0Yz1APhtl0z3O9yGjN9w3t3DQg98uoAy6OdlIY9YwSKdL0a/h/0b db8KIMs1KVCkRB+6MqUjzLkvMDKzEK/u7TT38A4bkH0BOXeZXzwtWnW9uA7VX1vy3q4Yw761V8w OdmhpaQjRdJpzfaFY0vjDRwGF374DxibJkqQVGT/mZTHrrF/cl4ttvcDWyUh7u5+Xmg== X-Gm-Gg: ASbGnctGQzbdD4cAIM5Xnzpj9Jj/Ex/Rv/2GLGeZqrXy2LVXYKW6tiqK8lvAfO1VplU YgPPIdex0+s76NTd+TvxN5hfFz9al9elkDGYfhTGOLENj59yMBVlysUm39uPdmT4nDb08Htdo1I aMMtMHn0lFtqU5Efusn/eDBVC/ehfr0lzf89yKnu3jxcW66x1K5os2JLhHhSF8/12AVx98/wBFo +wzU6QY0h0QILeQDwbWp1WTxprmxfm6ilOcYMTVQRGzYryIU+uh1hg3VD2vv2q1Qjwo2lavunKc vthLGZ0wwfg+MeSwx/zpFCUNjEmePXQLQqIYAY9f/2+CmXkyzXGv3PUFtwq9fZQ= X-Received: by 2002:a05:6000:1862:b0:3e7:492f:72b4 with SMTP id ffacd0b85a97d-4266e7df7f7mr3015746f8f.42.1759953596837; Wed, 08 Oct 2025 12:59:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0dEKdVVbbefPxraYSKbfgy6wGcFkOVkvZ4hpJR6iApWTuCQJvWeYWquxXyKMzAk9ArVEwTQ== X-Received: by 2002:a05:6000:1862:b0:3e7:492f:72b4 with SMTP id ffacd0b85a97d-4266e7df7f7mr3015729f8f.42.1759953596310; Wed, 08 Oct 2025 12:59:56 -0700 (PDT) Received: from costa-tp.redhat.com ([2a00:a041:e2eb:5500:8728:d68a:a687:c89b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8efffasm31209583f8f.41.2025.10.08.12.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Oct 2025 12:59:55 -0700 (PDT) From: Costa Shulyupin To: Steven Rostedt , Tomas Glozar , Costa Shulyupin , Crystal Wood , John Kacur , Jan Stancek , Tiezhu Yang , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 4/5] tools/rtla: Replace osnoise_hist_usage("...") with fatal("...") Date: Wed, 8 Oct 2025 22:59:04 +0300 Message-ID: <20251008195905.333514-5-costa.shul@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251008195905.333514-1-costa.shul@redhat.com> References: <20251008195905.333514-1-costa.shul@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A long time ago, when the usage help was short, it was a favor to the user to show it on error. Now that the usage help has become very long, it is too noisy to dump the complete help text for each typo after the error message itself. Replace osnoise_hist_usage("...") with fatal("...") on errors. Remove the already unused 'usage' argument from osnoise_hist_usage(). Signed-off-by: Costa Shulyupin --- tools/tracing/rtla/src/osnoise_hist.c | 34 +++++++++++---------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src= /osnoise_hist.c index 43c323521f55..3c4d8e25fd55 100644 --- a/tools/tracing/rtla/src/osnoise_hist.c +++ b/tools/tracing/rtla/src/osnoise_hist.c @@ -421,7 +421,7 @@ osnoise_print_stats(struct osnoise_tool *tool) /* * osnoise_hist_usage - prints osnoise hist usage message */ -static void osnoise_hist_usage(char *usage) +static void osnoise_hist_usage(void) { int i; =20 @@ -467,18 +467,12 @@ static void osnoise_hist_usage(char *usage) NULL, }; =20 - if (usage) - fprintf(stderr, "%s\n", usage); - fprintf(stderr, "rtla osnoise hist: a per-cpu histogram of the OS noise (= version %s)\n", VERSION); =20 for (i =3D 0; msg[i]; i++) fprintf(stderr, "%s\n", msg[i]); =20 - if (usage) - exit(EXIT_FAILURE); - exit(EXIT_SUCCESS); } =20 @@ -564,12 +558,12 @@ static struct common_params params->common.hist.bucket_size =3D get_llong_from_str(optarg); if (params->common.hist.bucket_size =3D=3D 0 || params->common.hist.bucket_size >=3D 1000000) - osnoise_hist_usage("Bucket size needs to be > 0 and <=3D 1000000\n"); + fatal("Bucket size needs to be > 0 and <=3D 1000000\n"); break; case 'c': retval =3D parse_cpu_set(optarg, ¶ms->common.monitored_cpus); if (retval) - osnoise_hist_usage("\nInvalid -c cpu list\n"); + fatal("\nInvalid -c cpu list\n"); params->common.cpus =3D optarg; break; case 'C': @@ -588,12 +582,12 @@ static struct common_params case 'd': params->common.duration =3D parse_seconds_duration(optarg); if (!params->common.duration) - osnoise_hist_usage("Invalid -D duration\n"); + fatal("Invalid -D duration\n"); break; case 'e': tevent =3D trace_event_alloc(optarg); if (!tevent) - fatal("Error alloc trace event"); + fatal("Error alloc trace event\n"); =20 if (params->common.events) tevent->next =3D params->common.events; @@ -604,11 +598,11 @@ static struct common_params params->common.hist.entries =3D get_llong_from_str(optarg); if (params->common.hist.entries < 10 || params->common.hist.entries > 9999999) - osnoise_hist_usage("Entries must be > 10 and < 9999999\n"); + fatal("Entries must be > 10 and < 9999999\n"); break; case 'h': case '?': - osnoise_hist_usage(NULL); + osnoise_hist_usage(); break; case 'H': params->common.hk_cpus =3D 1; @@ -619,18 +613,18 @@ static struct common_params case 'p': params->period =3D get_llong_from_str(optarg); if (params->period > 10000000) - osnoise_hist_usage("Period longer than 10 s\n"); + fatal("Period longer than 10 s\n"); break; case 'P': retval =3D parse_prio(optarg, ¶ms->common.sched_param); if (retval =3D=3D -1) - osnoise_hist_usage("Invalid -P priority"); + fatal("Invalid -P priority\n"); params->common.set_sched =3D 1; break; case 'r': params->runtime =3D get_llong_from_str(optarg); if (params->runtime < 100) - osnoise_hist_usage("Runtime shorter than 100 us\n"); + fatal("Runtime shorter than 100 us\n"); break; case 's': params->common.stop_us =3D get_llong_from_str(optarg); @@ -670,7 +664,7 @@ static struct common_params if (retval) fatal("Error adding trigger %s\n", optarg); } else { - osnoise_hist_usage("--trigger requires a previous -e\n"); + fatal("--trigger requires a previous -e\n"); } break; case '5': /* filter */ @@ -679,7 +673,7 @@ static struct common_params if (retval) fatal("Error adding filter %s\n", optarg); } else { - osnoise_hist_usage("--filter requires a previous -e\n"); + fatal("--filter requires a previous -e\n"); } break; case '6': @@ -701,7 +695,7 @@ static struct common_params fatal("Invalid action %s\n", optarg); break; default: - osnoise_hist_usage("Invalid option"); + fatal("Invalid option\n"); } } =20 @@ -712,7 +706,7 @@ static struct common_params fatal("rtla needs root permission\n"); =20 if (params->common.hist.no_index && !params->common.hist.with_zeros) - osnoise_hist_usage("no-index set and with-zeros not set - it does not ma= ke sense"); + fatal("no-index set and with-zeros not set - it does not make sense\n"); =20 return ¶ms->common; } --=20 2.51.0 From nobody Fri Dec 19 09:01:16 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7CEA29B8FE for ; Wed, 8 Oct 2025 20:00:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759953606; cv=none; b=KarJTTtdfG1g0XuJtjGWtDXDqKYJSzlFtTtbZkdJoMB3fjySHySYeXp/4a+NMYz9plk5ZQiBw9MSMG0ENjyR4Md6t2jhCYBoniyOiqjMCU5kpMZpTFJRszz9NWVgtsjD5iArLFaEzPq5uH9ByFotanlYv2LCdpp5oJkVoY3MenA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759953606; c=relaxed/simple; bh=TqWu55z+5wYc6F+NJ10bIT+HOTq+7ULpdasuP+yIBq8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kga3Wa+4fQV0hcH1mJwEXJJBhtVeo6eWf7j5cKPBdScVUw1ZcLHEaPFrSX3Mhmjc+e+mGeYluJtZ7fKnTGfq7BCi6lgAwReR01/ubdqifAq02SVrEend711uxIlEl+pqID1gAvm2tD9mX5Ne9N9PH0thmh0mT50sMl0sNvXVyDk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=jRLnF0Ga; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jRLnF0Ga" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759953603; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=II5hn3aPlMfjpXnd9vhycCVPNkV61JFwnfuK1k3g2ms=; b=jRLnF0Ga8foIsjkQ4cXMveQ/isbNrjpa/DdAxNJiSfB6GOKMUCg3l3ojjULshmoeDsAIzz pQr/QZjq7n72gKC1CRUtIIu8eRSeWnUyL/Jlm4vZ6QN8HSBFxq7hS2MABoRfTL3dgYIFWc xJSu4Z37/ZxMIbx26cNhnqcLFM/ZjY4= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-516-NqNWfOF2OlWZBtr7E5Ld0A-1; Wed, 08 Oct 2025 16:00:02 -0400 X-MC-Unique: NqNWfOF2OlWZBtr7E5Ld0A-1 X-Mimecast-MFC-AGG-ID: NqNWfOF2OlWZBtr7E5Ld0A_1759953601 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e2c11b94cso1766345e9.3 for ; Wed, 08 Oct 2025 13:00:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759953601; x=1760558401; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=II5hn3aPlMfjpXnd9vhycCVPNkV61JFwnfuK1k3g2ms=; b=gmLfO+FRfskl/l4GaGB3DoiuyeWjOWjo8KiFQei1xvQioByov3ISXXs/VMun9gD6tq Lx5rHgON5CdojYFYRcgBIjJWALJjcpfxrWEZ+bTYZomQenIx8htPqbw6t+nwY/yiuBWJ naR5q7g538jI5/2Ls50m3Xm4g3shVDrgafqKtlBBeckk1HyvLHDZcgnx2CmEgWW22WeS a6lfMezkNfnSj6Nq7cfJWN3FHTyv4Xkf+eqsEJlsOClw6iS4C9ytg3tamarjvT1Wh8Pa s7Gd7cPlKDPp7ppcYB8Ru4g1c6+eYS+KoZgegt7Mf7DgD+tVL8oea4KLvn76GvXJGaLN SzMA== X-Forwarded-Encrypted: i=1; AJvYcCVzIKdmt+hK34KxMbGAOEp4wPGHyqzUh75l+1ggwVxRJV3Dgl4MWB9ElUFwiS9WOTP823l3kFePXwtA/HQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yxua+7UK9D0KBgqxGgZoMCTemZa24xHLvbb5ZAxEa+V3WT0P0Xk lK2dsxr77CwBe2b7r0l6NTkQB8xvv69DhbpSmRDeJZFSen7zagbCjdz5G4vG+IiN1WN3eFCvM+w 6CQOcQWnJkrHMc0pdHY17mfAZ8IORgxBA3dUiQmHZ3JltjRG6PWg90UYXTAzLSoxqFxJxBVQOCq xx X-Gm-Gg: ASbGncul/Kbz/QdmVybdiMFhrpjX463M8enSruPGlkJHMIP9kXZ8RP1w2jmBFIKHT52 NQ2qL6A8J5ic9OuPZ2uBp8AzUgQKGYwLZFOJfOv6tGkgN6/fZal2/sEHI/RrnA3z8A9105p9bbr jZZfD6cZUzpl7DcWRG1LWPuYMjHaqxIVshdIV8EYA4KP4me7BMc4lwfELdGt/rn3YLrtbvnW9dO rC3MCYp5TPp98RpoA4SlwnD8pQJ8pjqkI/PJlFiGfzYFG3v2E5wY6Fa6ohc9Kip6TJpBWaDcIZ2 GRwPUHdJ9/LmR521L2CYhZf66lBIVFqIq9Ep7YANt8PeuOQNlM3XMeRb1xXbzvA= X-Received: by 2002:a05:600c:c0c3:20b0:46e:39ef:be77 with SMTP id 5b1f17b1804b1-46faef4161fmr8064885e9.14.1759953600713; Wed, 08 Oct 2025 13:00:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFlxgZDNU+hfJsuo3gBuETXOFe1aN2DF1fu0vRNbtwpm+xr3TxS17m0h+/cEvx8qvo/IT5uqg== X-Received: by 2002:a05:600c:c0c3:20b0:46e:39ef:be77 with SMTP id 5b1f17b1804b1-46faef4161fmr8064765e9.14.1759953600318; Wed, 08 Oct 2025 13:00:00 -0700 (PDT) Received: from costa-tp.redhat.com ([2a00:a041:e2eb:5500:8728:d68a:a687:c89b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8efffasm31209583f8f.41.2025.10.08.12.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Oct 2025 12:59:59 -0700 (PDT) From: Costa Shulyupin To: Steven Rostedt , Tomas Glozar , Costa Shulyupin , Crystal Wood , John Kacur , Jan Stancek , Tiezhu Yang , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 5/5] tools/rtla: Replace osnoise_top_usage("...") with fatal("...") Date: Wed, 8 Oct 2025 22:59:05 +0300 Message-ID: <20251008195905.333514-6-costa.shul@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251008195905.333514-1-costa.shul@redhat.com> References: <20251008195905.333514-1-costa.shul@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A long time ago, when the usage help was short, it was a favor to the user to show it on error. Now that the usage help has become very long, it is too noisy to dump the complete help text for each typo after the error message itself. Replace osnoise_top_usage("...") with fatal("...") on errors. Remove the already unused 'usage' argument from osnoise_top_usage(). Signed-off-by: Costa Shulyupin --- tools/tracing/rtla/src/osnoise_top.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/= osnoise_top.c index 43fb50b5d936..604a068ed77f 100644 --- a/tools/tracing/rtla/src/osnoise_top.c +++ b/tools/tracing/rtla/src/osnoise_top.c @@ -257,7 +257,7 @@ osnoise_print_stats(struct osnoise_tool *top) /* * osnoise_top_usage - prints osnoise top usage message */ -static void osnoise_top_usage(struct osnoise_params *params, char *usage) +static void osnoise_top_usage(struct osnoise_params *params) { int i; =20 @@ -296,9 +296,6 @@ static void osnoise_top_usage(struct osnoise_params *pa= rams, char *usage) NULL, }; =20 - if (usage) - fprintf(stderr, "%s\n", usage); - if (params->mode =3D=3D MODE_OSNOISE) { fprintf(stderr, "rtla osnoise top: a per-cpu summary of the OS noise (version %s)\n", @@ -318,9 +315,6 @@ static void osnoise_top_usage(struct osnoise_params *pa= rams, char *usage) for (i =3D 0; msg[i]; i++) fprintf(stderr, "%s\n", msg[i]); =20 - if (usage) - exit(EXIT_FAILURE); - exit(EXIT_SUCCESS); } =20 @@ -403,7 +397,7 @@ struct common_params *osnoise_top_parse_args(int argc, = char **argv) case 'c': retval =3D parse_cpu_set(optarg, ¶ms->common.monitored_cpus); if (retval) - osnoise_top_usage(params, "\nInvalid -c cpu list\n"); + fatal("\nInvalid -c cpu list\n"); params->common.cpus =3D optarg; break; case 'C': @@ -422,12 +416,12 @@ struct common_params *osnoise_top_parse_args(int argc= , char **argv) case 'd': params->common.duration =3D parse_seconds_duration(optarg); if (!params->common.duration) - osnoise_top_usage(params, "Invalid -d duration\n"); + fatal("Invalid -d duration\n"); break; case 'e': tevent =3D trace_event_alloc(optarg); if (!tevent) - fatal("Error alloc trace event"); + fatal("Error alloc trace event\n"); =20 if (params->common.events) tevent->next =3D params->common.events; @@ -436,7 +430,7 @@ struct common_params *osnoise_top_parse_args(int argc, = char **argv) break; case 'h': case '?': - osnoise_top_usage(params, NULL); + osnoise_top_usage(params); break; case 'H': params->common.hk_cpus =3D 1; @@ -447,12 +441,12 @@ struct common_params *osnoise_top_parse_args(int argc= , char **argv) case 'p': params->period =3D get_llong_from_str(optarg); if (params->period > 10000000) - osnoise_top_usage(params, "Period longer than 10 s\n"); + fatal("Period longer than 10 s\n"); break; case 'P': retval =3D parse_prio(optarg, ¶ms->common.sched_param); if (retval =3D=3D -1) - osnoise_top_usage(params, "Invalid -P priority"); + fatal("Invalid -P priority\n"); params->common.set_sched =3D 1; break; case 'q': @@ -461,7 +455,7 @@ struct common_params *osnoise_top_parse_args(int argc, = char **argv) case 'r': params->runtime =3D get_llong_from_str(optarg); if (params->runtime < 100) - osnoise_top_usage(params, "Runtime shorter than 100 us\n"); + fatal("Runtime shorter than 100 us\n"); break; case 's': params->common.stop_us =3D get_llong_from_str(optarg); @@ -489,7 +483,7 @@ struct common_params *osnoise_top_parse_args(int argc, = char **argv) if (retval) fatal("Error adding trigger %s\n", optarg); } else { - osnoise_top_usage(params, "--trigger requires a previous -e\n"); + fatal("--trigger requires a previous -e\n"); } break; case '1': /* filter */ @@ -498,7 +492,7 @@ struct common_params *osnoise_top_parse_args(int argc, = char **argv) if (retval) fatal("Error adding filter %s\n", optarg); } else { - osnoise_top_usage(params, "--filter requires a previous -e\n"); + fatal("--filter requires a previous -e\n"); } break; case '2': @@ -520,7 +514,7 @@ struct common_params *osnoise_top_parse_args(int argc, = char **argv) fatal("Invalid action %s\n", optarg); break; default: - osnoise_top_usage(params, "Invalid option"); + fatal("Invalid option\n"); } } =20 --=20 2.51.0