From nobody Tue Dec 2 01:25:49 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 0D60D1DE4F6 for ; Fri, 21 Nov 2025 17:45:38 +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=1763747140; cv=none; b=dkt2rLV3sPhi/7y22w+ySRXD+M2cCLw30bH0NuoM86aOunSB3Tr2uyfFE8U7vx2nUQHLRrD1ZfHJJAR0XaFT0jxL06Y9bmm+rlls7/a0aq8d0eBWJQOT/nOxhbABO9sTfp3cSpGgJuE8xnHaPDrKD3yIoCUBZ5VrK9Baz6DzupA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763747140; c=relaxed/simple; bh=pT/n7TwuIIVbjLsRSlAm3v1I6gvrDAWaKDW6YsvrdCs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ju34gcTbzX1Qw/kT9p+S2/mkZ8KZRgLmWUgSfDCHik8vZVkHof5zAx52eys1icWgEQ03ewE38mqew6cPpiPDuyFzGy6P0ky7Gbjczci4sWNa/Yz6YL+FS8fFBysLBW3IlKEz4eTzlHSTlqKCIIJ//mwzDFo9HLjGe4GndoUuyDQ= 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=Jaqkv/pa; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=tv5vXTIa; 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="Jaqkv/pa"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="tv5vXTIa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763747137; 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=YpyZDwI31rENzFfB5C1Wg2Rz+FfMtSQE+luFnR7RLDs=; b=Jaqkv/paoOmOK1UK2dPEs2a/hRPpZRDNWpJIJYA2eH0XvLTLoTc5odM+q1xW0OwUEPmEko PGj6tA4VTqK/AHkwNYBObfycb1i5x4zGlJvdhLuwh3SWFDIp2owNaXUL4WXe8VQd4ScPh5 fYFKb3IMSTVeLhdSdfNCzVcJ/YaWZps= 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-44-c6Xk6DcbNjmkDHnQHx3lpg-1; Fri, 21 Nov 2025 12:45:35 -0500 X-MC-Unique: c6Xk6DcbNjmkDHnQHx3lpg-1 X-Mimecast-MFC-AGG-ID: c6Xk6DcbNjmkDHnQHx3lpg_1763747134 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-42b3155274eso1140073f8f.0 for ; Fri, 21 Nov 2025 09:45:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1763747134; x=1764351934; 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=YpyZDwI31rENzFfB5C1Wg2Rz+FfMtSQE+luFnR7RLDs=; b=tv5vXTIapMELPVuRPc1w/MgePpF/c7Y8ve/ztcsQrDf7cYmc6nyH+Vm4TP5RsF+VUd w4KYtqaoI/wV0DjQDIC7tMXeE0f5mV7wff0LERmF0Jdtk/r1bBGl0VUQAOciJ7BbwCwO EHwCJmD6oURuB7IvGOt6MWAiANRRAJCyhcvl/xoHyz2gRspbpl0pkJX+WwRRj0PsYt9Q DZK4akG7KNh/ACCtxeZENmvx/lBN/SK6XWICzsb7cgohfu1XCwCGriYE5pn2m9eMS7B4 CJRwuxP5RDm5Sjbzcyn9iJl7Y6KsG/xMiO+ASsNQQmTHkmycV8fILAuJpsafi0SyeXX1 p9iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763747134; x=1764351934; 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=YpyZDwI31rENzFfB5C1Wg2Rz+FfMtSQE+luFnR7RLDs=; b=eh6xk9emtlbeZfvhO0ZeRJyMV+5Upj3HpY20LoQkbCV/TUywXq8cX8DIJw9OmrwtXe ITVQ3ZkVVxqmAK5Rfh0cWKI/Ix0pU2tNs3I9MvlinaAB4eq8uhhJyE5K7eegCvo8m4ZV BFGLcfT+2uRzVWXCQC6oj3hFvMUZ4J1dAWh4PFEvgBZColfxPycFuu2gyQaqhycVdPSM mdRXR17FuYApGvYmUhMlHotqI5NxEWeIXhuIWJfaFGmg++odwo30Lw6cwVUz3qrlRIUL 5zqn8weEhttjX8LDJZr6N1U4fdOVQahq+CBja6IzbeZ8dlbmr0jObHFHoP0rEnOTAB0Z EJsA== X-Forwarded-Encrypted: i=1; AJvYcCUHGN8PhVREcMZ4qCNMUeml5R8nu3crsi7/oW2DwamHW2RMIwcLH0rrxguHFO9idvly+sCh+yM++H+BLZg=@vger.kernel.org X-Gm-Message-State: AOJu0YwzM1IbG67wE+Rd8CPpI4f63lT9QHAnP7W2BtR5m0cx90PGN+Vx 8Kxp9hhFMp3VZr7H7hGn+5rbg+3/+I2BSHrcdI49Hkh+S3XP/5Vh1JvvgIB6T+wYfhqHOlRXZR1 5qx0mJ1na0cRwYI1ENc0utZvph7bupWT9wbHa0vIBZ7Ev4GqA2naESq2IEGaoNquH6Q== X-Gm-Gg: ASbGncviqVZnhTZUeoSHK7TmBo3Zr3En37vGb9WY9JM/YWVEc59w6UPINesaEe6yoB+ vDbnxpbvizl3qA7iO6RoBOp04qkSwWu6ZeCQunOpYecdHSdFwDWSRUtWcgueEmvHYAi90dSWbFx ENDjdSqAxvoM8xTZEIddBjghoZnru6ahGIbSoz5lxaPqlDyEqzT3ttV9wAbzNtChsRQmhVmHEAr 8fAdN4RLq8yweJXQcdgsUZtTeliT+GvnoT/7yeCk11qEutGFjoudBvIFoEmcNXEcfEzFDwECWBE +199XjeFgxmuaYJiRFrUE1lw/ByuR3ZBgUizdby0CxggdrWu9dMQm2AmPc9nf7ckHnN8Vh7TFjA adsihJYr6sWvIiM8dNfp/2v7v X-Received: by 2002:a05:6000:240b:b0:429:c4bb:fbc4 with SMTP id ffacd0b85a97d-42cc1cc293dmr3253806f8f.25.1763747133666; Fri, 21 Nov 2025 09:45:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIpzBXzy0HPFysMAQjEIJp3Hx8LAxcp7Ta/3C1XrC0QGlsWwYqzq+LzSYTGLDxPDmbXken+A== X-Received: by 2002:a05:6000:240b:b0:429:c4bb:fbc4 with SMTP id ffacd0b85a97d-42cc1cc293dmr3253778f8f.25.1763747133191; Fri, 21 Nov 2025 09:45:33 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Nov 2025 09:45:32 -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 2/8] tools/rtla: Consolidate -c/--cpus option parsing Date: Fri, 21 Nov 2025 19:44:58 +0200 Message-ID: <20251121174504.519230-3-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 -c/--cpus. Migrate the option parsing from individual tools to the common_parse_options(). Signed-off-by: Costa Shulyupin --- tools/tracing/rtla/src/common.c | 8 +++++++- tools/tracing/rtla/src/osnoise_hist.c | 9 +-------- tools/tracing/rtla/src/osnoise_top.c | 9 +-------- tools/tracing/rtla/src/timerlat_hist.c | 9 +-------- tools/tracing/rtla/src/timerlat_top.c | 9 +-------- 5 files changed, 11 insertions(+), 33 deletions(-) diff --git a/tools/tracing/rtla/src/common.c b/tools/tracing/rtla/src/commo= n.c index 5eaf6d9e11bf..e12192fcb3ab 100644 --- a/tools/tracing/rtla/src/common.c +++ b/tools/tracing/rtla/src/common.c @@ -56,13 +56,19 @@ int common_parse_options(int argc, char **argv, struct = common_params *common) int c; =20 static struct option long_options[] =3D { + {"cpus", required_argument, 0, 'c'}, {0, 0, 0, 0} }; =20 opterr =3D 0; - c =3D getopt_long(argc, argv, "", long_options, NULL); + c =3D getopt_long(argc, argv, "c:", long_options, NULL); =20 switch (c) { + case 'c': + if (parse_cpu_set(optarg, &common->monitored_cpus)) + fatal("Invalid -c cpu list"); + common->cpus =3D optarg; + 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 35f4a068af95..9e721362989a 100644 --- a/tools/tracing/rtla/src/osnoise_hist.c +++ b/tools/tracing/rtla/src/osnoise_hist.c @@ -491,7 +491,6 @@ static struct common_params {"auto", required_argument, 0, 'a'}, {"bucket-size", required_argument, 0, 'b'}, {"entries", required_argument, 0, 'E'}, - {"cpus", required_argument, 0, 'c'}, {"cgroup", optional_argument, 0, 'C'}, {"debug", no_argument, 0, 'D'}, {"duration", required_argument, 0, 'd'}, @@ -521,7 +520,7 @@ static struct common_params if (common_parse_options(argc, argv, ¶ms->common)) continue; =20 - 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:", + c =3D getopt_long(argc, argv, "a:C::b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5:6= :7:", long_options, NULL); =20 /* detect the end of the options. */ @@ -547,12 +546,6 @@ static struct common_params params->common.hist.bucket_size >=3D 1000000) 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) - fatal("Invalid -c cpu list"); - params->common.cpus =3D optarg; - break; case 'C': params->common.cgroup =3D 1; params->common.cgroup_name =3D parse_optional_arg(argc, argv); diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/= osnoise_top.c index 550731c7addd..73736cefd992 100644 --- a/tools/tracing/rtla/src/osnoise_top.c +++ b/tools/tracing/rtla/src/osnoise_top.c @@ -346,7 +346,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'}, - {"cpus", required_argument, 0, 'c'}, {"cgroup", optional_argument, 0, 'C'}, {"debug", no_argument, 0, 'D'}, {"duration", required_argument, 0, 'd'}, @@ -373,7 +372,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:c:C::d:De:hH:p:P:qr:s:S:t::T:0:1:2:3:", + c =3D getopt_long(argc, argv, "a:C::d:De:hH:p:P:qr:s:S:t::T:0:1:2:3:", long_options, NULL); =20 /* Detect the end of the options. */ @@ -392,12 +391,6 @@ struct common_params *osnoise_top_parse_args(int argc,= char **argv) if (!trace_output) trace_output =3D "osnoise_trace.txt"; =20 - break; - case 'c': - retval =3D parse_cpu_set(optarg, ¶ms->common.monitored_cpus); - if (retval) - fatal("Invalid -c cpu list"); - params->common.cpus =3D optarg; break; case 'C': params->common.cgroup =3D 1; diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/sr= c/timerlat_hist.c index ffcfcabb9964..4ae77145adea 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -796,7 +796,6 @@ static struct common_params while (1) { static struct option long_options[] =3D { {"auto", required_argument, 0, 'a'}, - {"cpus", required_argument, 0, 'c'}, {"cgroup", optional_argument, 0, 'C'}, {"bucket-size", required_argument, 0, 'b'}, {"debug", no_argument, 0, 'D'}, @@ -837,7 +836,7 @@ static struct common_params if (common_parse_options(argc, argv, ¶ms->common)) continue; =20 - 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:", + c =3D getopt_long(argc, argv, "a:C::b:d:e:E:DhH:i:knp:P:s:t::T:uU0123456= :7:8:9\1\2:\3:", long_options, NULL); =20 /* detect the end of the options. */ @@ -859,12 +858,6 @@ static struct common_params if (!trace_output) trace_output =3D "timerlat_trace.txt"; =20 - break; - case 'c': - retval =3D parse_cpu_set(optarg, ¶ms->common.monitored_cpus); - if (retval) - fatal("Invalid -c cpu list"); - params->common.cpus =3D optarg; break; case 'C': params->common.cgroup =3D 1; diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index d18d48671ccd..9774c26b27ff 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -566,7 +566,6 @@ static struct common_params while (1) { static struct option long_options[] =3D { {"auto", required_argument, 0, 'a'}, - {"cpus", required_argument, 0, 'c'}, {"cgroup", optional_argument, 0, 'C'}, {"debug", no_argument, 0, 'D'}, {"duration", required_argument, 0, 'd'}, @@ -601,7 +600,7 @@ static struct common_params if (common_parse_options(argc, argv, ¶ms->common)) continue; =20 - 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:", + c =3D getopt_long(argc, argv, "a:C::d:De:hH:i:knp:P:qs:t::T:uU0:1:2:345:= 6:7:", long_options, NULL); =20 /* detect the end of the options. */ @@ -638,12 +637,6 @@ static struct common_params /* set aa_only to avoid parsing the trace */ params->common.aa_only =3D 1; break; - case 'c': - retval =3D parse_cpu_set(optarg, ¶ms->common.monitored_cpus); - if (retval) - fatal("Invalid -c cpu list"); - params->common.cpus =3D optarg; - break; case 'C': params->common.cgroup =3D 1; params->common.cgroup_name =3D optarg; --=20 2.51.1