From nobody Fri Dec 19 08:52:58 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 BEFD4233707 for ; Sat, 11 Oct 2025 08:28:21 +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=1760171307; cv=none; b=TgolMTOiqhEMDprGtb1jroQsJNZHRYFKkunYc0DEzaaDZz8Ffm5CQNWSqAe8MPUJ82eOIvx7hZLifNYxe8lgK9hv93kCSX+fi9OFI0RoU207mfW1XHmwj+v8JVy6h9sr9MCzL/G2NFGwqsALq4RWyrPMOANRDiqsKCutduced3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760171307; c=relaxed/simple; bh=sw/eUhg7ntrMyVMWEv6qjvW/NWC36Ul4rMRtgOWP1SU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y+6SGd6puyACefov2A3t/3bOTbvuTQftjDJRQKTKfm5mE3UbtpBpk2k4wy2tOE3jKfaQhlkhQU4sBD1exURdo/s/OGwD0JXbyzrUvq/+ovaeYD5wkjqzsbDiPHMsqnjjhpySi1JTt1T+JaB3N//xtStc4rSPXKnIoH6ccF21QZ8= 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=ZcBx+BtF; 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="ZcBx+BtF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760171300; 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=LdAbsTu/nbtO3/GQV0uj3bpCPqqqyHXpfr0jY1rXrBE=; b=ZcBx+BtFEYYstzU0xC4BLVM22DKLzthWYcNz0CCv/NCireaDWZ2Rj2DPQGY7lVEj1Frlrp om7hach+/+sgZvGOo5KcakVlDy89z501UYsabC95a7LMhzXqpAL6yknfDxSJ340FD0enuh d5HGJf9Q4JJF6yhW9ZQhvOiBbfCBmV8= 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-364-pT_w50abMfqbZREVw7qwVg-1; Sat, 11 Oct 2025 04:28:19 -0400 X-MC-Unique: pT_w50abMfqbZREVw7qwVg-1 X-Mimecast-MFC-AGG-ID: pT_w50abMfqbZREVw7qwVg_1760171298 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3ee888281c3so3149134f8f.3 for ; Sat, 11 Oct 2025 01:28:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760171298; x=1760776098; 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=LdAbsTu/nbtO3/GQV0uj3bpCPqqqyHXpfr0jY1rXrBE=; b=QfXmudTY8RfHkZhrLLSLkoicGBAml4b5Ch+/+6vXLuTtjElyeeI+974iuR4AqXBERD CW1adIDoj6lvHdN4ZOlpy4Z3nHa4OGK0lgqL1y1/gtc+fSaxsVYWKBgbGRLnzUfQ1wjy b3ufayAL3gKxQt5D38hHf19m6866Iv2K+5nTV8sccUmRKzrJicLni81Q6uwzHdQH5RlA FS3ofmY3GsHB1kg7ttQqhY/pWlF8ZLOSL8Vv3Tz1mKAS3RZ5zCPKzp6KeQEw9voN992Q 6MFmE0YA8PK1Z4SRdpW9IXQ/DAJq5yA7hqGDzqviiEQbaVZ+7NbAwYEwXvSJMj9lL0Ii N/TQ== X-Forwarded-Encrypted: i=1; AJvYcCVKavtcf9SODBKOWMb1wwzqurENbvNJd+1VpxVxiV6P/1xBvYgLva6QvxxcQWcH/FOqTrTpDgGek0BxMEo=@vger.kernel.org X-Gm-Message-State: AOJu0YyqpktlzYY7o6WTEhmL5essEy3tYh2/fZkLiPJAa+xGwj9h/VDv 0Pp/k32kK4OW0SoefCkUzUg58JDYAHCgh4dcuWyBpa9wJAOKqCTJGRc3/Jg9UTpvVtXyMUKatqo iOziZsYvXVKD2vLV4ZPr5P1MjOxQJZtRbPqlWO9TjK+ACwEWxKEoUG1Jj6tkNEnw1/Q== X-Gm-Gg: ASbGncttyAX2L7bwy67hamWJlrhQ9vKXjicopOYHVk1dC12Yzv69OCX21g0CLH3znVn Wqo74qachkdBEndZ7Au97elr1BkT9AsLdf85gNU2NtNlMg9XWPUtvvdfS78378QznCmphJkbraC aB6MfAENn7TTrD4w4OCdgh7glElmFNIXd1G5D3l9lhPdWQyE6RawLCAvF0hsZNljs1yycOjSYLn u7XxKgF5CCoktBDfD8QHU3SBYG1Zpl64g8mvAuGyWXT3YHVB16i2R9lBvGoUfnPojYO/CkW0+m6 qfLNHZx+Qn/N+UX92hEkP4nDh1RsZTeV/2kHSU5lF3SP X-Received: by 2002:a05:6000:26c2:b0:3d0:b3cc:c1ff with SMTP id ffacd0b85a97d-4266e7d917bmr10008616f8f.39.1760171297907; Sat, 11 Oct 2025 01:28:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGIs00Fs2VZIdBz4nLKaEWYSTXqidn//HOPAo/VlO7701RgYJ0tYfNy8TrDMU86pcLnNhghTA== X-Received: by 2002:a05:6000:26c2:b0:3d0:b3cc:c1ff with SMTP id ffacd0b85a97d-4266e7d917bmr10008599f8f.39.1760171297411; Sat, 11 Oct 2025 01:28:17 -0700 (PDT) Received: from localhost ([2a00:a041:e2eb:5500:8728:d68a:a687:c89b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5d0006sm8022580f8f.34.2025.10.11.01.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Oct 2025 01:28:17 -0700 (PDT) From: Costa Shulyupin To: Steven Rostedt , Tomas Glozar , Costa Shulyupin , Crystal Wood , John Kacur , Tiezhu Yang , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/5] tools/rtla: Add fatal() and replace error handling pattern Date: Sat, 11 Oct 2025 11:27:34 +0300 Message-ID: <20251011082738.173670-2-costa.shul@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251011082738.173670-1-costa.shul@redhat.com> References: <20251011082738.173670-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: Tomas Glozar --- Changes since v1: - fatal() prints "\n" insteasd of caller as suggested 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 | 15 ++++++++ tools/tracing/rtla/src/utils.h | 1 + 7 files changed, 81 insertions(+), 129 deletions(-) diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src= /osnoise_hist.c index dffb6d0a98d7..31a2c9cf97f5 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"); 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", 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", 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", 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", 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"); =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..87f282e8c145 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"); 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", 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", 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", 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", 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"); =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..ab5d8ca4593c 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"); 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", 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", 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", 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", optarg); break; default: - timerlat_hist_usage("Invalid option"); + fatal("Invalid option"); } } =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"); =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..d8e60f823b25 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"); 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", 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", 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", 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", 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"); =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..ce68e39d25fd 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", 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", 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..54334c676a22 100644 --- a/tools/tracing/rtla/src/utils.c +++ b/tools/tracing/rtla/src/utils.c @@ -56,6 +56,21 @@ void debug_msg(const char *fmt, ...) fprintf(stderr, "%s", message); } =20 +/* + * fatal - print an error message and EOL 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); + fprintf(stderr, "\n"); + + exit(ERROR); +} + /* * get_llong_from_str - get a long long int from a string */ 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 08:52:58 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 ED039239E81 for ; Sat, 11 Oct 2025 08:28:26 +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=1760171312; cv=none; b=g8JwU2jekqON8zJM2QQGxPPQmV5AbguBxoyMeEgmAs37mI/PAmln2904DYFi81a6gofmTIqJwoF24y5axBYdWmXGCLkSn9LCjLK0//J+++JYx0VUTl8eRLdrbjREthCu1JjPumV+KEKi+dqU7h3lZmgHtM7BBXFe7jp1maW8ARY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760171312; c=relaxed/simple; bh=bK9ZbbRSu/RcSrw1tHd8Ioosrltuz2a83Oe9kALhMi0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RqyFRt1MmodDGKPATsuwV7SMALKn2pGKi+DmPb0QbHDD1DlgIluU4mc6E4JmFvtNpKnhvJs2cxYmOzA1Th3m0XkrPiyZ+kyU6deWO+lEfkMBne5kWv/68UABvFx53sOMx73giDSLOhXI1T7NyCJlqEKvioW5Yp4Hs8grTpQKRCE= 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=FsQSZVV0; 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="FsQSZVV0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760171306; 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=dBAgrUtuAZgF1r3Y0+9jCP35gSNzVvlFmIc27nq44Uk=; b=FsQSZVV08HllJ9V0bq5smicJRwHIpVVRzWo4B4h9k11bDWIc0L3qx6Lr/ghNPgVsqqByOc t92erbgwAO+ecleGQB02bTcVXuBSoayuSJ3LZoK3LD2mPZ+pqtpPas49nbHRSYEFVyD2yS B2kG7Kc2BENEGlKjD1VhH4D80xrTKgM= 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-323-GX7HhJG0M4y795EJvzNw7w-1; Sat, 11 Oct 2025 04:28:24 -0400 X-MC-Unique: GX7HhJG0M4y795EJvzNw7w-1 X-Mimecast-MFC-AGG-ID: GX7HhJG0M4y795EJvzNw7w_1760171303 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3ece0fd841cso2291987f8f.0 for ; Sat, 11 Oct 2025 01:28:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760171303; x=1760776103; 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=dBAgrUtuAZgF1r3Y0+9jCP35gSNzVvlFmIc27nq44Uk=; b=rW0MK1lhXLIlp8NFuUMLqapMitry3WkDu3/J9DniW+OiwNOErD043sBhyZf9WG8B15 yHNz/1EjIcV+AvVQyl5HftnK3uGgFpkLwRQpMO1KgvXgzWonC/HVd4H6vAbzk8pGV7Bt 3CVu16CHzEZuMWVwV5wDmjAJVM+O6WskjEVGN+ThdmCXlGIx8hlX14on6FZej+NiQ1eo sVMx9WWBnloNAAQSjLk4Jl61ZiH6gaNFZmBsrwDSXPI/qTOIy7+vPhYhx/i9cKV6mjmt Y9Vqd2Rb5mwD3psOyFix9Y2Gi6OcJB8vPVk3tWsuhZ21RtSSXE8w1SfZyfWd7La4FMv5 7hjA== X-Forwarded-Encrypted: i=1; AJvYcCUivQqO719VKI/pDbW/nl+034tjFmsUtRmeIOFlcyqQPOyfatqmvZ29dLkYF1yyGrCm3K+l0Rr9kNpokmU=@vger.kernel.org X-Gm-Message-State: AOJu0YyQ0qO//mdCe7Mzatvt39DQNjZ+uACJisZyI86bib0SDQwQjoxg 5exCNtTA6ipfR/l105oSDGB0cCZhKdtczYC56oHOuLw9TUmRzqcctwgIQ3gb9SJdgF/HFY+apNO XZpPQ6jyxxTZhJIciwqu0uKT0IypB9oPpMR0/mwqqysPzLXzTNCga1Cep8tVdwVzUMg== X-Gm-Gg: ASbGnctmSg/jSRZ9QKybmC71D+zrL5A7N3F06Az6C0vsOjs0rxItuInM/FprBd9Y0Na jYrpXY/amo8A/ecd5c61uULXB3gbtc6b88sStJ6zPcXU05OV7U07ftMp5bGeSvviuX+oBtB7h5v L4IoVUg+uiDLQqqOj1HtJjP+8FvuP4pGPiAPpQIC/4eO/EnXdTdrkvFuynW78YNcrM1RE7zSZlZ ycCuN25n5zrxe/6i3Y/Se5DK5imlPDmFBrWublFjZRnjJjxlQGQVO9mw+zsagr0TK2Ezp5IuT9T eIOExe+rSKz3X1agxLC8ZJR8MM9bC4fF3GNQ21OesXBk X-Received: by 2002:a05:6000:659:10b0:426:d82f:889e with SMTP id ffacd0b85a97d-426d82f88cbmr276600f8f.14.1760171303106; Sat, 11 Oct 2025 01:28:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrOrLxL1eNdz8ZKW238q93rZX5VW6RjLN0F6KEdjI7rPURwhL8djYrNs8pRcGaxQcWksUQkg== X-Received: by 2002:a05:6000:659:10b0:426:d82f:889e with SMTP id ffacd0b85a97d-426d82f88cbmr276582f8f.14.1760171302720; Sat, 11 Oct 2025 01:28:22 -0700 (PDT) Received: from localhost ([2a00:a041:e2eb:5500:8728:d68a:a687:c89b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5d0006sm8022580f8f.34.2025.10.11.01.28.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Oct 2025 01:28:22 -0700 (PDT) From: Costa Shulyupin To: Steven Rostedt , Tomas Glozar , Costa Shulyupin , Crystal Wood , John Kacur , Tiezhu Yang , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/5] tools/rtla: Replace timerlat_top_usage("...") with fatal("...") Date: Sat, 11 Oct 2025 11:27:35 +0300 Message-ID: <20251011082738.173670-3-costa.shul@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251011082738.173670-1-costa.shul@redhat.com> References: <20251011082738.173670-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("...\n") with fatal("...") on errors. Remove the already unused 'usage' argument from timerlat_top_usage(). Signed-off-by: Costa Shulyupin Reviewed-by: Tomas Glozar --- Changes since v1: - fatal() prints "\n" insteasd of caller as suggested by Crystal Wood --- tools/tracing/rtla/src/timerlat_top.c | 28 +++++++++++---------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index d8e60f823b25..27b64bdc5b18 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("Invalid -c cpu list"); params->common.cpus =3D optarg; break; case 'C': @@ -667,7 +661,7 @@ 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"); break; case 'e': tevent =3D trace_event_alloc(optarg); @@ -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"); 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"); params->common.set_sched =3D 1; break; case 'q': @@ -740,7 +734,7 @@ static struct common_params if (retval) fatal("Error adding trigger %s", optarg); } else { - timerlat_top_usage("--trigger requires a previous -e\n"); + fatal("--trigger requires a previous -e"); } break; case '1': /* filter */ @@ -749,7 +743,7 @@ static struct common_params if (retval) fatal("Error adding filter %s", optarg); } else { - timerlat_top_usage("--filter requires a previous -e\n"); + fatal("--filter requires a previous -e"); } break; case '2': /* dma-latency */ @@ -785,7 +779,7 @@ static struct common_params fatal("Invalid action %s", optarg); break; default: - timerlat_top_usage("Invalid option"); + fatal("Invalid option"); } } =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!"); =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!"); =20 /* * If auto-analysis or trace output is enabled, switch from BPF mode to --=20 2.51.0 From nobody Fri Dec 19 08:52:58 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 BA77523AE9A for ; Sat, 11 Oct 2025 08:28:29 +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=1760171315; cv=none; b=EovoaMUbH2VPZbRTAgXs0tZXdsg2FLP2tt08qHcFMMMGMcpSk8dhPJs7HV0VPNsRGXEigzQpNyIN6bBb3CZAjl2dqMka/iuAZMrf4lbC3hG1xl/KdL1w3VpWJV8qlXUzHPOa9I/yTC06Pqq4O7yz6hm5LsP+TXiwLGnjj7SJRK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760171315; c=relaxed/simple; bh=LRfI47UB2UnyFYw/FWC26NL7Yq0N9R5zYg3HcLRgkdM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YCCKgkWBDlARYys6K03L43mfPpB1QeTmL9orey9wp/gN816V+cx1u7QGm95vBnnknfOktCHOR8wpRbLUrQ61agNSnzm9yerWCATEDBfIeoBne4gLb3Cn8OdqyAYJPsRz2KVEjP3umjSElVzwO0CV76fBGI9dOFqthcF9vdO58Q8= 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=ZM4REZ1R; 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="ZM4REZ1R" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760171308; 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=rHj98cou2Y19csOC6HqCSeOGSHvHBg7RYgMNCaj5iUM=; b=ZM4REZ1RUaVDjhOsW/6NfWsVufy6YL+hOdT4mVaz/DlG7EtRpgLtklsvRPQf/vvlCMnghT ORZopC3rq675yQ+YdHPXZ+6O3TVRNirtyxkgejA/SBUjZJnH/GAuH04yNBWMosgt2iMC5Y 4IYloiWGnX3vg4ZROKff0azw/e41NUc= 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-380-dytZ8QJDPaWMDnCZlGNPKg-1; Sat, 11 Oct 2025 04:28:27 -0400 X-MC-Unique: dytZ8QJDPaWMDnCZlGNPKg-1 X-Mimecast-MFC-AGG-ID: dytZ8QJDPaWMDnCZlGNPKg_1760171306 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e4fa584e7so15385735e9.0 for ; Sat, 11 Oct 2025 01:28:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760171306; x=1760776106; 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=rHj98cou2Y19csOC6HqCSeOGSHvHBg7RYgMNCaj5iUM=; b=q9horJUFLVBo5QvZHtlhOrYW8mwsdrbpS7f5QFF4uwpzywvIRVKwTYO7fdzWDM4MuO tnDnu68YxE33eITtpofN3b17xqCf5zaacHSCgQNps6Zu3/ZO2hrtwj8HILTMAjx64SBJ cpo52HAvDAJbmsK9RAt1sK6q1jXooOziSZwalFXwN62Y1iu1lJ5vHXuFF4b+yxmDnewk 0Zrmsn4NcH0GoJ12EB4ZUj2E8mSNEvd3Ls1rLlbeztfwg5F45+C4MukOv/cg0Y+dc2A0 xtexiR5jrQ6k26v04uK0G3NeDZa/h6lx7Nl77RGNZMYOr2czTgt4s+G8zHLLyqdCVOIw A0ug== X-Forwarded-Encrypted: i=1; AJvYcCVQS9Q/0SFn3HZT4SyfnsjgQjd745P4/gpEgOet+Qmv5/tLB+hSsKtSca5za58qq471BmYE7hcXsQ27548=@vger.kernel.org X-Gm-Message-State: AOJu0YypszC02yrrhPfmg4Me9gAWs9Um7ybq1QW7G5gb8int34kFfak9 mJyux9ZNEI/aPzaFJAXRP6tj03te7dQx/b62Sf05/SyC1FsZeaYbE+G1IFW/Ot1xAtIvyt5spkr dTr8EOvOA4t4/GjZOQFURcwkOR7lcXFXHc/+O98mi1dtSa79OhnVrIM5xINglL0TlyA== X-Gm-Gg: ASbGncuYD/2uneLQACPLAVXwCxlQEiU6/+2aLHFLIbQMqgThrHm0U5N/VACI1oCpQEw ginVB8QHtZNfkJZIbc35nXuZvXU2AOwEG0jj7GRx2dNz84eWvTyFZIrfEyF0i0iw7PgQpUBMClf AzfaYEvcIXB8/Sr82Xy3QPLv15vQ2MU6/G5H3QfK9i9p13QCr+xGnkMHMliUHVHNVC5WzyRxVgm ifDM7c67goPu3cXBLgCJCpwmUhQa7gSMMZvo21aMrL4MUWsFhebgZafnr0G+wI02Fw9YWrFHOKQ ZS2ojwCXbRRpro+llJyANiuMq0ZB2+QYy1oKEIInSDZq X-Received: by 2002:a05:6000:4305:b0:3ec:d78d:8fcc with SMTP id ffacd0b85a97d-42666ab85a7mr8999682f8f.14.1760171305776; Sat, 11 Oct 2025 01:28:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHqokUQUSflqj2ie1uzhEOzTJOaDkXEKNoBKE1a5t+pgJEbZNk3LxtrY+4KW6G+rzLsLPIdSg== X-Received: by 2002:a05:6000:4305:b0:3ec:d78d:8fcc with SMTP id ffacd0b85a97d-42666ab85a7mr8999670f8f.14.1760171305390; Sat, 11 Oct 2025 01:28:25 -0700 (PDT) Received: from localhost ([2a00:a041:e2eb:5500:8728:d68a:a687:c89b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5d0006sm8022580f8f.34.2025.10.11.01.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Oct 2025 01:28:25 -0700 (PDT) From: Costa Shulyupin To: Steven Rostedt , Tomas Glozar , Costa Shulyupin , Crystal Wood , John Kacur , Tiezhu Yang , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/5] tools/rtla: Replace timerlat_hist_usage("...") with fatal("...") Date: Sat, 11 Oct 2025 11:27:36 +0300 Message-ID: <20251011082738.173670-4-costa.shul@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251011082738.173670-1-costa.shul@redhat.com> References: <20251011082738.173670-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("...\n") with fatal("...") on errors. Remove the already unused 'usage' argument from timerlat_hist_usage(). Signed-off-by: Costa Shulyupin Reviewed-by: Tomas Glozar --- Changes since v1: - fatal() prints "\n" insteasd of caller as suggested by Crystal Wood --- tools/tracing/rtla/src/timerlat_hist.c | 32 +++++++++++--------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/sr= c/timerlat_hist.c index ab5d8ca4593c..71557f5751a6 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("Invalid -c cpu list"); 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"); break; case 'D': config_debug =3D 1; @@ -909,7 +903,7 @@ 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"); break; case 'e': tevent =3D trace_event_alloc(optarg); @@ -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"); 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"); 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"); params->common.set_sched =3D 1; break; case 's': @@ -1004,7 +998,7 @@ static struct common_params if (retval) fatal("Error adding trigger %s", optarg); } else { - timerlat_hist_usage("--trigger requires a previous -e\n"); + fatal("--trigger requires a previous -e"); } break; case '7': /* filter */ @@ -1013,7 +1007,7 @@ static struct common_params if (retval) fatal("Error adding filter %s", optarg); } else { - timerlat_hist_usage("--filter requires a previous -e\n"); + fatal("--filter requires a previous -e"); } break; case '8': @@ -1060,10 +1054,10 @@ static struct common_params fatal("rtla needs root permission"); =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"); =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"= ); =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!"); =20 /* * If auto-analysis or trace output is enabled, switch from BPF mode to --=20 2.51.0 From nobody Fri Dec 19 08:52:58 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 2567C23BCE4 for ; Sat, 11 Oct 2025 08:28:31 +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=1760171317; cv=none; b=DCbj+vLPyDIBSEijpZw8xwkTl5B7UQq79vLP4K2d0P17MuqCz6FHlj5ROuQWejTh46+N5FnIq9Ufne7uruWaE4lFvJsKl4PwZRdB4T76HG5U/f2J+YP+Xac8dspWRwy58qhBn5xy2CRE82D3Zcwgo4YMKdORtdB9EK6tCGe/zOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760171317; c=relaxed/simple; bh=jRcrQx61y9kXssdrhnsAAhEbZBbsrGaVtE/xowsZG3U=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=puZzYPrljfh0Jvl0kSUr5Q98nwpPPxFI85K5+XFbxvi6xVzz9HHXZt2i8zfWuU5HwOLwnwTEKOC+E+TrUDOBoVr5tpWf23DxJoYxCPKDgJvx+CULng1khiITocvJNs3UADQKoNJ6MvTIHnMFjrXzw7EU8p6g9tFxNFwciyVgqMw= 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=BnzaxpOp; 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="BnzaxpOp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760171311; 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=izEDGnACaGb+UE+AiB6Iu8Q3+pibeALVxmn3zVNoFFk=; b=BnzaxpOpgvmnxtctGld9OIFFFhmtCaxpcvn2B0CqTTZIUNAbhIB25xmV2AMoCGeyEn9sZY eWHtGaljRO75Jc6RqlmbFqYoYv0QCNh6XqVoj641eTACrnZzgmvfaA22OS2U62/9nmJ61c zVZVUCdQtH7RGSr3cHiDviBybbI7X10= 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-475-UqCaJ_ZRM2CK26Q5PcLKmw-1; Sat, 11 Oct 2025 04:28:29 -0400 X-MC-Unique: UqCaJ_ZRM2CK26Q5PcLKmw-1 X-Mimecast-MFC-AGG-ID: UqCaJ_ZRM2CK26Q5PcLKmw_1760171308 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3f7b5c27d41so1720040f8f.0 for ; Sat, 11 Oct 2025 01:28:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760171308; x=1760776108; 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=izEDGnACaGb+UE+AiB6Iu8Q3+pibeALVxmn3zVNoFFk=; b=B7ocj51EsEHhQegu9EjPGJNyO40cAPC0VJOKtH/+g/DuZ4ESH3yBPdFNuXnO4TQntj C4uLnZdFI8+f0Aez0a5lo8NrQYWOIZ0dHIDvclr5IFZo4zyYeijn1OyJkC4nbU0HYjZ1 dYwQl/TJk5Xk7UtyLGcwt5Q2Zrqyxfav/TC1InOQzGDgMdauRfjaNXNaBgkq0O2NoGhM Zw6/RfvQnZd1Mn6uGThmQtzC3mjo6/vABF7Tk6tEAjrbAj8vtxoYBtMLtA02/Kx5Xv1C Z9LZlATca6ZkyL6ACiu0nv+HAXIPNFicXUipQ06jUaA3xeiCW6z8bdZQJ8kmdQrW5PYZ EcBQ== X-Forwarded-Encrypted: i=1; AJvYcCU/Fl/+WKvl0DN2JKOP0gpnK87xBhMGAHu5R1/pTwhN1BDFg2FAC0C+Gb3DMFLrndJ9NqarndqiLoLabMg=@vger.kernel.org X-Gm-Message-State: AOJu0Yx7p7dU9EkYZrOxuURLwTx/N2QzfqYKwCowNUKwW93QQOAImcK4 LRRYjc3MYHm54GwcsQR53Qj9BJjWwEeV7Y+BdGWcKl40KM4pjIEYenPkh7VSo7+q0t0AwGI8ZKA Qkx+IOQyPdZp7kV3YD5sajJGyVTP2ZzT0EaUXzaLRXzTtIeKoHZbHcOwlYfyefv+xMw== X-Gm-Gg: ASbGncviqQF746JVBIdxqznRiCVXadTw/A48LU7b5ck1Kd9OGGdFCEJijTe7564kpqG pwYKThfztzO1s3dN6Y18+RAD9xkFSVVPrMJzwgbolgS9onrtxRuj1x9xZAmN+rf3JXAiuFEGoPj Dcrq7BOtxj4Opy5wdqlDCCNsMG/QiG//hwmsViHovlfhlX1Q89ghqrEPLOIpFil6KnkUTNQITfd /D+UnQ0eeNEFwoSAj2lu+8RBqULJcd4JiIkkD3dL9PtdCi3COaySIdJsQquFdtCNv1TiM0khhxs C7wch2b/x6vzo/NnH2zYJA/I5Nxx65iiNft/wCyIrwTK X-Received: by 2002:a05:6000:2f86:b0:404:2fe4:3a80 with SMTP id ffacd0b85a97d-425829ee8c7mr11070489f8f.25.1760171308256; Sat, 11 Oct 2025 01:28:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6+EqJMpQvaelkIXVEWLlIUO2XxTYtzFkl/y1HXogC30uU15snwvq85P0+PcPFAzDMeu1IWA== X-Received: by 2002:a05:6000:2f86:b0:404:2fe4:3a80 with SMTP id ffacd0b85a97d-425829ee8c7mr11070479f8f.25.1760171307888; Sat, 11 Oct 2025 01:28:27 -0700 (PDT) Received: from localhost ([2a00:a041:e2eb:5500:8728:d68a:a687:c89b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5d0006sm8022580f8f.34.2025.10.11.01.28.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Oct 2025 01:28:27 -0700 (PDT) From: Costa Shulyupin To: Steven Rostedt , Tomas Glozar , Costa Shulyupin , Crystal Wood , John Kacur , Tiezhu Yang , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/5] tools/rtla: Replace osnoise_top_usage("...") with fatal("...") Date: Sat, 11 Oct 2025 11:27:37 +0300 Message-ID: <20251011082738.173670-5-costa.shul@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251011082738.173670-1-costa.shul@redhat.com> References: <20251011082738.173670-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 Reviewed-by: Tomas Glozar --- Changes since v1: - fatal() prints "\n" insteasd of caller as suggested Crystal Wood --- tools/tracing/rtla/src/osnoise_top.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/= osnoise_top.c index 87f282e8c145..f0782c5ed0b1 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("Invalid -c cpu list"); params->common.cpus =3D optarg; break; case 'C': @@ -422,7 +416,7 @@ 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"); break; case 'e': tevent =3D trace_event_alloc(optarg); @@ -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"); 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"); 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"); 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", optarg); } else { - osnoise_top_usage(params, "--trigger requires a previous -e\n"); + fatal("--trigger requires a previous -e"); } 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", optarg); } else { - osnoise_top_usage(params, "--filter requires a previous -e\n"); + fatal("--filter requires a previous -e"); } break; case '2': @@ -520,7 +514,7 @@ struct common_params *osnoise_top_parse_args(int argc, = char **argv) fatal("Invalid action %s", optarg); break; default: - osnoise_top_usage(params, "Invalid option"); + fatal("Invalid option"); } } =20 --=20 2.51.0 From nobody Fri Dec 19 08:52:58 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 7A69223D7CA for ; Sat, 11 Oct 2025 08:28:34 +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=1760171319; cv=none; b=QdTvdJFAJ8qNTCv1fMzMp5uNWZuws5C6v3x2HnbW73yEk6kPv8K4f3qIa4cTkENTWDo6g87oJVp78YJSQpCqfyxWUBSL/xeQVtzVJULNiHaVHBSMpAfX6IbrAdws5s6YZyTaJSLmEcIyV9O52aWaSD1A3CjDdHdTALw5OX4tq4I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760171319; c=relaxed/simple; bh=lMxJsTBvYIIRzV2ysIaeaApJyW/Xxwl8lAvSVzlHlhs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gU8TwigpvOd8WWMlFVZiLkk6UIjTnoaXvsrjmNvwtlIP9E7S3f+9FR0cBOmycqMeHJtAlUY5AiMZa/MUbRKo3KuXGc3cmYwjGtdttuG80Ax6EfTlAqvDkzA6g58MV7fLSJwGQEwG6eRLd5MMT5MNkLKLHsxw3NMhqyUTxxAk62U= 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=I592Bp9Q; 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="I592Bp9Q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760171313; 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=aOj4qrsjoSEV40FZCa/GgcbP7ZbPD06dUm2Vl71DoUE=; b=I592Bp9QcB4bXuDrx1dutBzAwOzTC9tTPH8+We2nUR6i05WSGF3QYU03qokyllxghaR5kk Qp08GWMcWqBBMZiw44zGP9mEiV3MnYgRCI0Ou6A4yzj8tkRQb1ra0Ap5SP0MOFz+0RHQ7O ME+N/9TDKCysL8OKrID0sWHuKIkdOH0= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-401-kw7vALKyP-KUq3WxGQHQpA-1; Sat, 11 Oct 2025 04:28:31 -0400 X-MC-Unique: kw7vALKyP-KUq3WxGQHQpA-1 X-Mimecast-MFC-AGG-ID: kw7vALKyP-KUq3WxGQHQpA_1760171311 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-46e4c8fa2b1so12112695e9.0 for ; Sat, 11 Oct 2025 01:28:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760171311; x=1760776111; 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=aOj4qrsjoSEV40FZCa/GgcbP7ZbPD06dUm2Vl71DoUE=; b=MqYzY9I2OLYF9/nJLPL2TnIrdrnpiNqxLq5fG7Nb3Iy/C1EG9UEfpBqPBjiBaZHE4J rq/8oHfodQre6BN6V8Ri3bK4nhlEV9GQWZt/gixoB85LT/+1OqUl1+BIP9z04y9dvPmQ gESjGemCDeG68OsAmzcfxgV4YSckxLB1zPKVGl7zSdaWTTq/4Th/pfU3MW5MTM660Wiu bA1x4Tk0aRWaJ1/hWXtLsXlinNjXWjaLMXe27a/5D0STjoC34/MO0BP4iZ8XYP0p+FCw 9zMQ/mIRZ/HOHG5N3IDzzhDXZZiWaGiuZ4tCZL6Ufgyiq8nYpWflCD5q64bDRNvQ7QQJ Hl1Q== X-Forwarded-Encrypted: i=1; AJvYcCX+ptRZqHW6CNYlxzLdqYIZEUXYBGgl0da34ILNQcrFqYNTDHUJTrPDFdOuY3LkZA+DsLPheHrX3/+9BFs=@vger.kernel.org X-Gm-Message-State: AOJu0YwhvvFa8sJBT7RXZU4Mb7yDoex+e3WHE8GYw54Pc2PZhHcaq/4e U6ri/FgDhCK1Dcaf1ikJbmS6nz+6d7+7c+61lLLi51Zo5zMZA+rcqPCnzQM8NfuIF3BYNZLKAWk 5V7agLqhQTstLlriwpSry/1xVCIGj63/2rrOAQUxOUEgsOftnkz0hV3G0PWd1WiJbHA== X-Gm-Gg: ASbGncv2tOTkYmqS/lkJ0OP5qCo1wteWTC6IhRShk0jsfoBgDvWPyAVXj5G+RHmCk4D +JG0Wmcij5yciSJZPfd1V3fy3T/cYvuwcmpyF/m2FgUKnrthYK/23v69QquARAJqstnlLcf73eJ yeUQTFsiNCqJn5J5EL2XTBzsWNzcrcqtX8XeXYxA6wCzIcLrHgYcGgC9JgKIVA9DWf084bWR5yP K10ZkaHL6mfPaNN2a48neOnAKMP1m4fHBNlpfYZDRW2XDYujxPrRY86O4/EKxwAYVMZqJWFU5Hi bN2tjmkBggGlWGSIiu/Emh2SrpEjV8sWLCvRTWdn4Q3G X-Received: by 2002:a05:600c:5306:b0:46e:3d41:5fe7 with SMTP id 5b1f17b1804b1-46fa9afbd48mr94401205e9.29.1760171310582; Sat, 11 Oct 2025 01:28:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFK5DqK5p00Q8fy/jT6hCAziOfIB4t7V7rJVh/6m2CXm+TH90wdKa0CBAPVz1Kvu+HBjsP2vw== X-Received: by 2002:a05:600c:5306:b0:46e:3d41:5fe7 with SMTP id 5b1f17b1804b1-46fa9afbd48mr94400995e9.29.1760171310146; Sat, 11 Oct 2025 01:28:30 -0700 (PDT) Received: from localhost ([2a00:a041:e2eb:5500:8728:d68a:a687:c89b]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-426ce5d0006sm8022580f8f.34.2025.10.11.01.28.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Oct 2025 01:28:29 -0700 (PDT) From: Costa Shulyupin To: Steven Rostedt , Tomas Glozar , Costa Shulyupin , Crystal Wood , John Kacur , Tiezhu Yang , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/5] tools/rtla: Replace osnoise_hist_usage("...") with fatal("...") Date: Sat, 11 Oct 2025 11:27:38 +0300 Message-ID: <20251011082738.173670-6-costa.shul@redhat.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251011082738.173670-1-costa.shul@redhat.com> References: <20251011082738.173670-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 Reviewed-by: Tomas Glozar --- Changes since v1: - fatal() prints "\n" insteasd of caller as suggested Crystal Wood --- tools/tracing/rtla/src/osnoise_hist.c | 32 +++++++++++---------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src= /osnoise_hist.c index 31a2c9cf97f5..b0b7f04c3871 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"); break; case 'c': retval =3D parse_cpu_set(optarg, ¶ms->common.monitored_cpus); if (retval) - osnoise_hist_usage("\nInvalid -c cpu list\n"); + fatal("Invalid -c cpu list"); params->common.cpus =3D optarg; break; case 'C': @@ -588,7 +582,7 @@ 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"); break; case 'e': tevent =3D trace_event_alloc(optarg); @@ -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"); 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"); 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"); 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"); 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", optarg); } else { - osnoise_hist_usage("--trigger requires a previous -e\n"); + fatal("--trigger requires a previous -e"); } break; case '5': /* filter */ @@ -679,7 +673,7 @@ static struct common_params if (retval) fatal("Error adding filter %s", optarg); } else { - osnoise_hist_usage("--filter requires a previous -e\n"); + fatal("--filter requires a previous -e"); } break; case '6': @@ -701,7 +695,7 @@ static struct common_params fatal("Invalid action %s", optarg); break; default: - osnoise_hist_usage("Invalid option"); + fatal("Invalid option"); } } =20 @@ -712,7 +706,7 @@ static struct common_params fatal("rtla needs root permission"); =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"); =20 return ¶ms->common; } --=20 2.51.0