From nobody Tue Dec 2 01:26:25 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 2503734F241 for ; Fri, 21 Nov 2025 17:45:49 +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=1763747151; cv=none; b=QHVJbIQgahNW3yn0Lj9B4wT6ibEacwG3zHCc6GQ7jkGvcaqvhAi7rAB02l7wjXJxak9BiHJN6iaw91fOaDKoFERYG4PwGUwGJb4dRQtq8f0eyhBj5ohvkW7onehvFI0rGKFXrwMjSfw5CHH6adPl84uy93B1nOTCpQh+voneOJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763747151; c=relaxed/simple; bh=U5DeGnZekR8rISaant6f6+HTTp8Iy1SCbciThbchxaM=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IVxXfwzzJ5gIyti3mjbXYVP/CYyAtO0AbLkOT0SUDudXdURJS/sBNnjcBWm5vBQRnVG+9TUTENx19NNa9ebw1I+NgogS2T3JWoi2IxBFA4Wj/1wRWJoRyGKD3W2qD0WCWQBHhpQoIRvVawT9CXzUiNgb5qPUfTGoF5sg13lIwEU= 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=QWOpAsEX; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=iixE4PXw; 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="QWOpAsEX"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="iixE4PXw" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763747149; 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=601u8cTJOpTNQMx+d0xy6jF7wJaJPINuIXmBn9DqsBA=; b=QWOpAsEXxfpLOqdUNeLbiZFoO44Z+Goe0ujuQz7FADWz7noMhprsoKMxdLNevRBoasjfO3 P0VCAa05ZxWIWhB5FZNgxNLgOg+Cp0AnuMt6W8PgH7hoXp9MTFzm+6o4FK/GGN4Q9mIwEo +4Z73AO3GMZ3HQMUlmeB/Ut4dUq1/Oc= 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-563-xh4LaqSaNNSfnqkGvguHbw-1; Fri, 21 Nov 2025 12:45:47 -0500 X-MC-Unique: xh4LaqSaNNSfnqkGvguHbw-1 X-Mimecast-MFC-AGG-ID: xh4LaqSaNNSfnqkGvguHbw_1763747146 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-429ca3e7245so1223906f8f.3 for ; Fri, 21 Nov 2025 09:45:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1763747146; x=1764351946; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=601u8cTJOpTNQMx+d0xy6jF7wJaJPINuIXmBn9DqsBA=; b=iixE4PXwU8ttHq0ZwE6pBuZ0X4s9s/tDs+o/xstJOiFc/UpMmvaJJBISuyiJsDJaPE 5JAp2HvgR9Y522i+Ff0FTE4QJzjY4CrAAsAvL5GuWhpyAga+ZqhCqPC9SbLo3idtOPAr fBFp5j3xB5vWy4y2/4DRPgYfG1IEplHMxzjWz3y3s/DXE1jHLcDRGIRGPonqAzte+pGs ZsL+KHuGpHGxCx8fPvUQzg9K/8HHrrz53DEtmA3vpbeFIL5tIYOKkiOINfJqn1OpaUMj wLxA2DOjD3aAQpQCpusqQsS4yTWJqaS6aAXYRBGLzwSZa8X5/Av9SVU3iJxI+696ZKhk E7cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763747146; x=1764351946; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=601u8cTJOpTNQMx+d0xy6jF7wJaJPINuIXmBn9DqsBA=; b=AR/98ONITcDujBzF2ItFkWOYEmPO6XZwrFEAwyvNGm5vSTrnPCAdvkZEUAfxlYrx4w 9WSmHyLVOj+0FTAqafsrnRFhQw3bsEYewOMYu3M5hwaVLO5EmhYuxnYUuusYs+GEUcNo ytQJvfRSRU8ne44HEWj1G0O4mRIRpo3q0yvoFigXIoENRn1DV6UmY+xp8cIbAqX53cKM jLPSr5hoppgskxXrjVygwN2/90uTJWvyRpH8oFlMLDz+kL4afItoTw6wqSNhrMQt5xTU /0VSrBJt1GwdE5ogYZh7iejcQJbA0n6ShyUHNBLRZ2APLLm+PT83Mr6RTRdxjB6YYkxF 8X8A== X-Forwarded-Encrypted: i=1; AJvYcCUDfl63lefvsYcSg8WBkPNWciUxLx2zczkW/8lbQz1iiBVGS/4FV+fDszZLyfh+WF/tf1s4Hof0WwX8WSA=@vger.kernel.org X-Gm-Message-State: AOJu0YzA0daSazwEEiE1qRYyyfqbirc2di+br7kJHoALuXx5aZh5/HYY mI88aisR/QwxuFBY61OdqnZ11w1uCxkEQR61dV/1YnYReJS+iCOz1+412OqordhlON3MvFKtJzo 6vJYlwdWiCTxtXKPDb4wPHc5BAnzUyZm2Nscc6l5Kd+TUOMH9mxXDnEpQmuhCmO/eqA== X-Gm-Gg: ASbGncsSH/AaW8cLGqTqLKplLbWsRN4owd3d61YkBRE8QE7AhQpC3LR8lGCVvKGZWYf gljEhWyvl3cXIdvffHLDGEROhYH7/Rky5U85G2cq2vY0I5W7RjBjmJop4vwNNYA3JbL6AB7+OCx QZ7SQfcYgDmKx6P+sZI2mSkKzRk8iJK9LmDDi1wE9iI+Oh2UBgcLPWMx6AbXbfITaLyQsII6/um yAekTw8Lt92tMnkjHubAOs+ajgV92XyztH3X/rY5dEI+k/Pkr/Bk5zbnXwd7ui1pIHT6hurvrns WVUPCiYxtPm+kKA2/IGRGx69eHYqsb18lbbOg3LnvxfY8i1zcVU4pzOSfCQKDWAaLRCJP7muL9A T1Q+FYwiTNZ2PVfKjZjTXi/5t X-Received: by 2002:a5d:5d02:0:b0:42b:3339:c7ff with SMTP id ffacd0b85a97d-42cc1d19a16mr3698686f8f.43.1763747146284; Fri, 21 Nov 2025 09:45:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IH8kZ/PfttCKjmF1hEvfyYQbUXFlJLAEN1wlOmdYkHKzzjvrHLPwsh+1ZWK5l8V1ImULMCiQQ== X-Received: by 2002:a5d:5d02:0:b0:42b:3339:c7ff with SMTP id ffacd0b85a97d-42cc1d19a16mr3698652f8f.43.1763747145811; Fri, 21 Nov 2025 09:45:45 -0800 (PST) Received: from costa-tp.bos2.lab ([2a00:a041:e294:5000:b694:8e49:4f51:966d]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42cb7ec454csm11529567f8f.0.2025.11.21.09.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Nov 2025 09:45:45 -0800 (PST) From: Costa Shulyupin To: Steven Rostedt , Tomas Glozar , Costa Shulyupin , Crystal Wood , Wander Lairson Costa , Ivan Pravdin , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 6/8] tools/rtla: Consolidate -e/--event option parsing Date: Fri, 21 Nov 2025 19:45:02 +0200 Message-ID: <20251121174504.519230-7-costa.shul@redhat.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251121174504.519230-1-costa.shul@redhat.com> References: <20251121174504.519230-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" Each rtla tool duplicates parsing of -e/--event. Migrate the option parsing from individual tools to the common_parse_options(). Signed-off-by: Costa Shulyupin --- tools/tracing/rtla/src/common.c | 13 ++++++++++++- tools/tracing/rtla/src/osnoise_hist.c | 14 +------------- tools/tracing/rtla/src/osnoise_top.c | 14 +------------- tools/tracing/rtla/src/timerlat_hist.c | 14 +------------- tools/tracing/rtla/src/timerlat_top.c | 13 +------------ 5 files changed, 16 insertions(+), 52 deletions(-) diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/commo= n.c index 720add9511e8..6a1675eba96e 100644 --- a/tools/tracing/rtla/src/common.c +++ b/tools/tracing/rtla/src/common.c @@ -52,6 +52,7 @@ static void set_signals(struct common_params *params) */ int common_parse_options(int argc, char **argv, struct common_params *comm= on) { + struct trace_events *tevent; int saved_state =3D optind; int c; =20 @@ -60,11 +61,12 @@ int common_parse_options(int argc, char **argv, struct = common_params *common) {"cgroup", optional_argument, 0, 'C'}, {"debug", no_argument, 0, 'D'}, {"duration", required_argument, 0, 'd'}, + {"event", required_argument, 0, 'e'}, {0, 0, 0, 0} }; =20 opterr =3D 0; - c =3D getopt_long(argc, argv, "c:C::Dd:", long_options, NULL); + c =3D getopt_long(argc, argv, "c:C::Dd:e:", long_options, NULL); =20 switch (c) { case 'c': @@ -84,6 +86,15 @@ int common_parse_options(int argc, char **argv, struct c= ommon_params *common) if (!common->duration) fatal("Invalid -d duration"); break; + case 'e': + tevent =3D trace_event_alloc(optarg); + if (!tevent) + fatal("Error alloc trace event"); + + if (common->events) + tevent->next =3D common->events; + common->events =3D tevent; + break; default: optind =3D saved_state; return 0; diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src= /osnoise_hist.c index 1b79bfefc214..c4013f50e803 100644 --- a/tools/tracing/rtla/src/osnoise_hist.c +++ b/tools/tracing/rtla/src/osnoise_hist.c @@ -469,7 +469,6 @@ static struct common_params *osnoise_hist_parse_args(int argc, char *argv[]) { struct osnoise_params *params; - struct trace_events *tevent; int retval; int c; char *trace_output =3D NULL; @@ -499,7 +498,6 @@ static struct common_params {"stop", required_argument, 0, 's'}, {"stop-total", required_argument, 0, 'S'}, {"trace", optional_argument, 0, 't'}, - {"event", required_argument, 0, 'e'}, {"threshold", required_argument, 0, 'T'}, {"no-header", no_argument, 0, '0'}, {"no-summary", no_argument, 0, '1'}, @@ -517,7 +515,7 @@ static struct common_params if (common_parse_options(argc, argv, ¶ms->common)) continue; =20 - c =3D getopt_long(argc, argv, "a:b:e:E:hH:p:P:r:s:S:t::T:01234:5:6:7:", + c =3D getopt_long(argc, argv, "a:b:E:hH:p:P:r:s:S:t::T:01234:5:6:7:", long_options, NULL); =20 /* detect the end of the options. */ @@ -543,16 +541,6 @@ static struct common_params params->common.hist.bucket_size >=3D 1000000) fatal("Bucket size needs to be > 0 and <=3D 1000000"); break; - case 'e': - tevent =3D trace_event_alloc(optarg); - if (!tevent) - fatal("Error alloc trace event"); - - if (params->common.events) - tevent->next =3D params->common.events; - - params->common.events =3D tevent; - break; case 'E': params->common.hist.entries =3D get_llong_from_str(optarg); if (params->common.hist.entries < 10 || diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/= osnoise_top.c index 619c5bcf8f35..846d25ee4885 100644 --- a/tools/tracing/rtla/src/osnoise_top.c +++ b/tools/tracing/rtla/src/osnoise_top.c @@ -322,7 +322,6 @@ static void osnoise_top_usage(struct osnoise_params *pa= rams) struct common_params *osnoise_top_parse_args(int argc, char **argv) { struct osnoise_params *params; - struct trace_events *tevent; int retval; int c; char *trace_output =3D NULL; @@ -346,7 +345,6 @@ struct common_params *osnoise_top_parse_args(int argc, = char **argv) while (1) { static struct option long_options[] =3D { {"auto", required_argument, 0, 'a'}, - {"event", required_argument, 0, 'e'}, {"house-keeping", required_argument, 0, 'H'}, {"help", no_argument, 0, 'h'}, {"period", required_argument, 0, 'p'}, @@ -369,7 +367,7 @@ struct common_params *osnoise_top_parse_args(int argc, = char **argv) if (common_parse_options(argc, argv, ¶ms->common)) continue; =20 - c =3D getopt_long(argc, argv, "a:e:hH:p:P:qr:s:S:t::T:0:1:2:3:", + c =3D getopt_long(argc, argv, "a:hH:p:P:qr:s:S:t::T:0:1:2:3:", long_options, NULL); =20 /* Detect the end of the options. */ @@ -388,16 +386,6 @@ struct common_params *osnoise_top_parse_args(int argc,= char **argv) if (!trace_output) trace_output =3D "osnoise_trace.txt"; =20 - break; - case 'e': - tevent =3D trace_event_alloc(optarg); - if (!tevent) - fatal("Error alloc trace event"); - - if (params->common.events) - tevent->next =3D params->common.events; - params->common.events =3D tevent; - break; case 'h': case '?': diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/sr= c/timerlat_hist.c index 0a7e5dcce121..4744f84a452e 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -766,7 +766,6 @@ static struct common_params *timerlat_hist_parse_args(int argc, char *argv[]) { struct timerlat_params *params; - struct trace_events *tevent; int auto_thresh; int retval; int c; @@ -810,7 +809,6 @@ static struct common_params {"user-threads", no_argument, 0, 'u'}, {"kernel-threads", no_argument, 0, 'k'}, {"user-load", no_argument, 0, 'U'}, - {"event", required_argument, 0, 'e'}, {"no-irq", no_argument, 0, '0'}, {"no-thread", no_argument, 0, '1'}, {"no-header", no_argument, 0, '2'}, @@ -833,7 +831,7 @@ static struct common_params if (common_parse_options(argc, argv, ¶ms->common)) continue; =20 - c =3D getopt_long(argc, argv, "a:b:e:E:hH:i:knp:P:s:t::T:uU0123456:7:8:9= \1\2:\3:", + c =3D getopt_long(argc, argv, "a:b:E:hH:i:knp:P:s:t::T:uU0123456:7:8:9\1= \2:\3:", long_options, NULL); =20 /* detect the end of the options. */ @@ -862,16 +860,6 @@ static struct common_params params->common.hist.bucket_size >=3D 1000000) fatal("Bucket size needs to be > 0 and <=3D 1000000"); break; - case 'e': - tevent =3D trace_event_alloc(optarg); - if (!tevent) - fatal("Error alloc trace event"); - - if (params->common.events) - tevent->next =3D params->common.events; - - params->common.events =3D tevent; - break; case 'E': params->common.hist.entries =3D get_llong_from_str(optarg); if (params->common.hist.entries < 10 || diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index 4340fbf3f879..b77e5b6550a1 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -538,7 +538,6 @@ static struct common_params *timerlat_top_parse_args(int argc, char **argv) { struct timerlat_params *params; - struct trace_events *tevent; long long auto_thresh; int retval; int c; @@ -566,7 +565,6 @@ static struct common_params while (1) { static struct option long_options[] =3D { {"auto", required_argument, 0, 'a'}, - {"event", required_argument, 0, 'e'}, {"help", no_argument, 0, 'h'}, {"house-keeping", required_argument, 0, 'H'}, {"irq", required_argument, 0, 'i'}, @@ -597,7 +595,7 @@ static struct common_params if (common_parse_options(argc, argv, ¶ms->common)) continue; =20 - c =3D getopt_long(argc, argv, "a:e:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:", + c =3D getopt_long(argc, argv, "a:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:", long_options, NULL); =20 /* detect the end of the options. */ @@ -634,15 +632,6 @@ static struct common_params /* set aa_only to avoid parsing the trace */ params->common.aa_only =3D 1; break; - case 'e': - tevent =3D trace_event_alloc(optarg); - if (!tevent) - fatal("Error alloc trace event"); - - if (params->common.events) - tevent->next =3D params->common.events; - params->common.events =3D tevent; - break; case 'h': case '?': timerlat_top_usage(); --=20 2.51.1