From nobody Tue Dec 2 01:26:26 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 809841DE4F6 for ; Fri, 21 Nov 2025 17:45:32 +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=1763747134; cv=none; b=qME+kvhTTFye5MnEhGcpLMX4TD2ay+LL8Gk3go7ymz4nXTmXvSLdJZQA939cMaE33lAe0GEpybdw14yVYQoIk59dFf4g0ujSdieamudY9CLj0Y53J+4nH+l5xjf7SjRlpzpFnRB8jmO9lEhi2XubMMf+zRWv6RONh+wOx62u2FQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763747134; c=relaxed/simple; bh=hEnSqrU6gyHDpfaTTvuhCk0gZVj3SdwGrgEDkeASOzo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t9TW/XQLQ0Qui8uyuHHjPEBr8q0DMtXoxvG8NOj7xbnAxmxKpGl27OZh1bSv20TmDT46N94bij3xVnKkw3o8+NeEDKuygoW/IR0sOZIqopSflpDjlg/wWDSjjhxSkA/fVS08T9rK1k6aaKJDJ8tsvGFFIzfKAgZsmMpY9GnsJQM= 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=XOrx029Y; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Zm7Zc148; 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="XOrx029Y"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Zm7Zc148" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763747131; 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=a8U8k61ooI8uwApq9Nne2HkmVcuivM1F21YTKzt65jc=; b=XOrx029YQpULBALwJFD7a+kMiLybUpejWo9fEV5Clgc4yC/bmQrzUfS67dYBQw6pUE1O63 IjybPpmL0YS6IF/rFLryHl7bQKuUn7QXmajq/eBtJeApHR6fe5gPrQo5y7Hi1nDDwmGsWq 6GXM9l9xCaEJtk/EdonYIY1ZAq2RGd8= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-450-ASL0C9V8M3GfYjZyNrdW2A-1; Fri, 21 Nov 2025 12:45:30 -0500 X-MC-Unique: ASL0C9V8M3GfYjZyNrdW2A-1 X-Mimecast-MFC-AGG-ID: ASL0C9V8M3GfYjZyNrdW2A_1763747129 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4779981523fso29224505e9.2 for ; Fri, 21 Nov 2025 09:45:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1763747129; x=1764351929; 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=a8U8k61ooI8uwApq9Nne2HkmVcuivM1F21YTKzt65jc=; b=Zm7Zc148otkHb35R1pL3XST0rdKb0QTkVW5Yh3MWARoj6+R5QqSXFK5v9XeIsk71p+ +WlWX5e5obbxJ3zC7SzjEvx32ohe0oxzYeA65XzYq/AnW76KEQkdCGCpKN0YheQX9zdi D8zUGV7XYQLYUA5dkfHJHGFbnF2WeWE0c3TUpiIXrqnrdVmcpmivXLp2EStF4KVezwbI e5OWjWCrhoA4HES46Sd00uNqgV1/LkQi8xjsutYCIeRW4NQYYABqJQeEASyRQfFd/ikt hDQOxbyTaU8ENyDSdyPy8zT3KKTOCkZnqAUTqWoEzsT3Z/LdPtYsoDXawNp9DSs0Q/Iw tZYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763747129; x=1764351929; 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=a8U8k61ooI8uwApq9Nne2HkmVcuivM1F21YTKzt65jc=; b=lQZhi1BQPcWfv4EDu7BWGaUhrvcUKp4vDP+BzJiaKy1q86pChk4xquRzA6/CA8QSJY B0LjlBvlXbg8CobGV+fr+2Df4BiR8bmPYWoC9Wnr9U47+S5Gzeg+tnd6jyyl/dOZKPN0 8SwGt3386qXuFHTswDmqhyf9o3NTcOZAQgnhYe5eClBEL84bwBNs3/nJKUO5/5Hc9nVe ZR5ZuUbX5zkLL5XOzWEQTO00zQk24wnGe+rN9gA35SrTA2eJtxqcqXycNXQmqK7RjEyx T+TKNqVlfBmFMyjqZ3bcsJMpoyshJoUlQCYUQjJrIrjKUHhlwNFVCiJJnCVim85d9S/W iHog== X-Forwarded-Encrypted: i=1; AJvYcCU/wpD0YZEodXGxRiIY9DXCub0AZiVFYB2hbb2LqWuHcTRp4jtbdu2WMfzHW/NmCKkmiAvBbMuBRIztDQg=@vger.kernel.org X-Gm-Message-State: AOJu0Yy0rJAt2gB4OW0s6RqrOM5lcroftX28B/dOcFwkQpZZ8PE1NNzz ZA6CnZ29NyZmKI/HU83/+9wPMvM96a6nEBZSXjTPwaPUkFoURvJ+2LGRzwfeVtS25O07t74DmXg MW5jFVDpzHual0WhOAQFg7Se45uN26it4jXp+yp5ZnEoIAxcfypwBphK9aRKiR7q7Tw== X-Gm-Gg: ASbGncsxTY2x20FPiTTawT+Lj2QH/vgFrgaOjD3Rg+MMVLXbs3q1+rvxrAhVKPTEjuf 8fP+pyqOJTPjSneCjTenP7qbby8b0oQspwfjc6ty8naSxytuKWFe/xdmn4MoelzRwDXT6mWi2io ZuVMC/LaKKCUR9XTHtWcSXwsb+ZncNJNKjoEkK5oWp/MrE+giLmnXrBU5c2s95jeXhAhxB/4aPf V7X70caf5QR2m+0QRYPjdJB5vJMniJAQmi+KAdDGX9HgJsE23/wv44htryj1HbAw9WkRlIJOwGp RgPAU0Von5qnQSzlkV/BkxDq5pKIqMoTdwTLBfqhQVD3QZ3/eOyO1XbJTnXZpAQKsDIpTNDZfpm duv2YkdE53b+e6X4K30FoLV26 X-Received: by 2002:a05:600c:1f85:b0:477:7b30:a6fe with SMTP id 5b1f17b1804b1-477c1116013mr27453345e9.18.1763747128615; Fri, 21 Nov 2025 09:45:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+H0undz5MZzoSg1LxF9NOXlTyyk9c7w50TvXj8Zav3XyrYG5bpmJO1uYPj5tlwMHTJM4AzA== X-Received: by 2002:a05:600c:1f85:b0:477:7b30:a6fe with SMTP id 5b1f17b1804b1-477c1116013mr27453165e9.18.1763747128228; Fri, 21 Nov 2025 09:45:28 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Nov 2025 09:45:27 -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 1/8] tools/rtla: Add common_parse_options() Date: Fri, 21 Nov 2025 19:44:57 +0200 Message-ID: <20251121174504.519230-2-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 many common options. This creates maintenance overhead and risks inconsistencies when updating these options. Add common_parse_options() to centralize parsing of options used across all tools. Common options to be migrated in future patches. Signed-off-by: Costa Shulyupin --- tools/tracing/rtla/src/common.c | 34 ++++++++++++++++++++++++++ tools/tracing/rtla/src/common.h | 1 + tools/tracing/rtla/src/osnoise_hist.c | 3 +++ tools/tracing/rtla/src/osnoise_top.c | 3 +++ tools/tracing/rtla/src/timerlat_hist.c | 3 +++ tools/tracing/rtla/src/timerlat_top.c | 3 +++ 6 files changed, 47 insertions(+) diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/commo= n.c index b197037fc58b..5eaf6d9e11bf 100644 --- a/tools/tracing/rtla/src/common.c +++ b/tools/tracing/rtla/src/common.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "common.h" =20 struct trace_instance *trace_inst; @@ -37,6 +38,39 @@ static void set_signals(struct common_params *params) } } =20 +/* + * common_parse_options - parse common command line options + * + * @argc: argument count + * @argv: argument vector + * @common: common parameters structure + * + * Parse command line options that are common to all rtla tools. + * + * Returns: non zero if a common option was parsed, or 0 + * if the option should be handled by tool-specific parsing. + */ +int common_parse_options(int argc, char **argv, struct common_params *comm= on) +{ + int saved_state =3D optind; + int c; + + static struct option long_options[] =3D { + {0, 0, 0, 0} + }; + + opterr =3D 0; + c =3D getopt_long(argc, argv, "", long_options, NULL); + + switch (c) { + default: + optind =3D saved_state; + return 0; + } + + return c; +} + /* * common_apply_config - apply common configs to the initialized tool */ diff --git a/tools/tracing/rtla/src/common.h b/tools/tracing/rtla/src/commo= n.h index 9ec2b7632c37..1066d777a823 100644 --- a/tools/tracing/rtla/src/common.h +++ b/tools/tracing/rtla/src/common.h @@ -153,6 +153,7 @@ struct osnoise_tool *osnoise_init_tool(char *tool_name); struct osnoise_tool *osnoise_init_trace_tool(const char *tracer); bool osnoise_trace_is_off(struct osnoise_tool *tool, struct osnoise_tool *= record); =20 +int common_parse_options(int argc, char **argv, struct common_params *comm= on); int common_apply_config(struct osnoise_tool *tool, struct common_params *p= arams); int top_main_loop(struct osnoise_tool *tool); int hist_main_loop(struct osnoise_tool *tool); diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src= /osnoise_hist.c index ff8c231e47c4..35f4a068af95 100644 --- a/tools/tracing/rtla/src/osnoise_hist.c +++ b/tools/tracing/rtla/src/osnoise_hist.c @@ -518,6 +518,9 @@ static struct common_params {0, 0, 0, 0} }; =20 + if (common_parse_options(argc, argv, ¶ms->common)) + continue; + c =3D getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5= :6:7:", long_options, NULL); =20 diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/= osnoise_top.c index 04c699bdd736..550731c7addd 100644 --- a/tools/tracing/rtla/src/osnoise_top.c +++ b/tools/tracing/rtla/src/osnoise_top.c @@ -370,6 +370,9 @@ struct common_params *osnoise_top_parse_args(int argc, = char **argv) {0, 0, 0, 0} }; =20 + if (common_parse_options(argc, argv, ¶ms->common)) + continue; + c =3D getopt_long(argc, argv, "a:c:C::d:De:hH:p:P:qr:s:S:t::T:0:1:2:3:", long_options, NULL); =20 diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/sr= c/timerlat_hist.c index 1fb471a787b7..ffcfcabb9964 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -834,6 +834,9 @@ static struct common_params {0, 0, 0, 0} }; =20 + if (common_parse_options(argc, argv, ¶ms->common)) + continue; + c =3D getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:knp:P:s:t::T:uU01234= 56:7:8:9\1\2:\3:", long_options, NULL); =20 diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index 29c2c1f717ed..d18d48671ccd 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -598,6 +598,9 @@ static struct common_params {0, 0, 0, 0} }; =20 + if (common_parse_options(argc, argv, ¶ms->common)) + continue; + c =3D getopt_long(argc, argv, "a:c:C::d:De:hH:i:knp:P:qs:t::T:uU0:1:2:34= 5:6:7:", long_options, NULL); =20 --=20 2.51.1