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 5C3B82F3C12 for ; Tue, 9 Dec 2025 10:01:08 +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=1765274470; cv=none; b=NYk+n8VQWjdZYwGFmvny1XYefeD1aqqfYe9n3ftOohI3iwGvP0U05z+d6mbQJYhspoKfZuzmqDb7nZ/vGptv1qR/klJQhZpbLoISY9iwkvnIhHgNqqmN8acN89JdL/qCXeqmPS+zxnKa9BW5qbsPqb+lhxQfU2+M6QxNjSOvRmk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765274470; c=relaxed/simple; bh=EYL8jMHEMsZ6U+ISXHnaT8gl0oIxzRcdqDA/qKxcflA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mr7Q0GfLtHyJPvOz3iHOzEkITClzx6cOHq/iB5pqyI9hyrHTQ8CgBHgWagzT4EQjww6a8Hfjs7EVAqHp///2rcG6mnatl1GNn+IvSxV3+rPFg7cLjvHPqm4wQ8oA41muHEGgQKHrqZM1RenEAwlfpZwjDQgenj02YUN2P/qBXLc= 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=M5gA4O+y; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=KqOqfDzr; 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="M5gA4O+y"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="KqOqfDzr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765274467; 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=ulHpppgPkD0WivPOraMTYrfg6Edxoov5Pk58h71j2Rg=; b=M5gA4O+yYrECB51NMqZr5rkisO7w0uffItHBT/ddkoPSNUp5rN3lHhk8s9xBwVNbHtYMdX fCPw55WYbQuxgFlw8gLzkeSfQKlTqoHwrXQFyDRou8SWeZktoQpDtAQqup0djoUNxhkKJ0 GED0jPv19swWTOUo9no8W82h7HeUAMc= 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-589-qFlEL-wlM4a5p64KfIAVOA-1; Tue, 09 Dec 2025 05:01:05 -0500 X-MC-Unique: qFlEL-wlM4a5p64KfIAVOA-1 X-Mimecast-MFC-AGG-ID: qFlEL-wlM4a5p64KfIAVOA_1765274465 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-47775585257so35020955e9.1 for ; Tue, 09 Dec 2025 02:01:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1765274464; x=1765879264; 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=ulHpppgPkD0WivPOraMTYrfg6Edxoov5Pk58h71j2Rg=; b=KqOqfDzr8TdePTIgjGLPBc9lV7SHP5XH4nNzgLZ+CjGsSAdRYs1NWWxr+Ki9eh3xXs 56uDvCjbRmgtm/nIMHKCQSgalIBb7jkHZaxuiHHla5FcdLgZDP5h2n6GIuRS7AfUA4C/ BP6hoi//rPDW296e/y2cQ+JtXgIKibzJP3/7Iaz64iHNcNYYDw8i2GauqiTsJf/EJpqD 2zwkqcRDcZwXAY9RLcLF7GjxbTT75t4e0W0nzRItaYYxhERVagfGsWImHoiWM5s+pblZ OxYw8NMLGp3Uo/+y9vgs9T8nWLozD7TzVnSEBrdhMeZ5sTqnqfb1LB7UDR9bML/X7kZn Qi8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765274464; x=1765879264; 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=ulHpppgPkD0WivPOraMTYrfg6Edxoov5Pk58h71j2Rg=; b=a5Qm5q6FhTyAMTL9o3xvklEgGLFoDDBZmr0inZNGGELkO+zxnfOBcZKUU6zJO6Ay8U NcgHf6vny/kq+WZCLuVP1liqY87G5lsXd7Kpqu80WXftcKA+Y7w+J7bxYuyk8TlpkJPN CeU5amrXwNBchvUAxGczrtmXGvb/EnVz20lOKDCwNOVHgQnt9maSS7FCzwE69yU6Hgy0 4VVPblKACrJZzmbxEe1XCIGEk5WNsueHvO2QLOYN4Cfm5wfHmGvP/GzZV0zmASZgEQ1H yJCdA9LrsmM/rM0rsku3sI7KhVf/pyIrLJwLqAaEAV8eZ5C07hqdslCCxbj3gAmdYO6B izjw== X-Forwarded-Encrypted: i=1; AJvYcCUbjsh19HnLv/U4UwaKzMQfrp5sQcPI1Ufl76Otpioo/Dhp96KPqVzwD0mvVD5XLFj1e/n/TZusLhgDGNI=@vger.kernel.org X-Gm-Message-State: AOJu0YxJ33nLvL1yL1qczJ4qc+8nYNt19RCxN58cfpAZRzkZlDeVe753 N7rCxJbBrLa+stwGCpHk8bRmjmrYt0EuSz+ElAeJ8Mn46n9bzhlr5TApNBGuDqo2GzxRrnAbdJc p6A1odCE2RKAeB/a1WWk3RhKEeRn4o6u0eEQbGfJOGleuu05l1mJMAVs5ySn+2tp4MA== X-Gm-Gg: ASbGnctI1MEaXisuuGKb+XWrzVkhkkqB8xuFi04D4NFDouO44fDJFQNfiaiPhlHRKL2 xZNGq6jGyxn+NeNg+D6hxspK/56a8NPsh1HsbMVWPgrjZmcXqHtwKyjT8Gr+4dI7jw7sjJl3g/4 JM4LkdsYOV3AbQyWGBfcZWbhDvrwJhvwQEQWjuu43PAB1eZn7ujIeBDRwWO76IxBztVDSmqm9s4 UMjDnB7catC7N2wFeJKASGkLcP2ZLyosXpY5kt3ySdDK4QRhCfYJcTbvmyEDlJucINPWxrcuyus FyNJ0xMiG3fDov63oqsWRSdXncapq3V3uuH22jQzXMnGAMgikUzrPljBQ2DdQxli2Nnk7xqUguv CRaizU3GRZb9Jyyb8h5XMq8TrY40= X-Received: by 2002:a05:600c:1382:b0:477:aed0:f401 with SMTP id 5b1f17b1804b1-47939e276e1mr80239985e9.23.1765274464481; Tue, 09 Dec 2025 02:01:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKl2EQBEkqNCg6U4G3dj7IGLT7huIGgrqSFVgLdWD41QjtWYM84wV0MpjtV78sUTQJbkNY0w== X-Received: by 2002:a05:600c:1382:b0:477:aed0:f401 with SMTP id 5b1f17b1804b1-47939e276e1mr80239655e9.23.1765274463941; Tue, 09 Dec 2025 02:01:03 -0800 (PST) Received: from costa-tp.redhat.com ([2a00:a041:e294:5000:b694:8e49:4f51:966d]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47a7d612e49sm33620855e9.3.2025.12.09.02.01.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 02:01:03 -0800 (PST) From: Costa Shulyupin To: Steven Rostedt , Tomas Glozar , Costa Shulyupin , Crystal Wood , Wander Lairson Costa , John Kacur , Ivan Pravdin , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/8] tools/rtla: Consolidate -c/--cpus option parsing Date: Tue, 9 Dec 2025 12:00:41 +0200 Message-ID: <20251209100047.2692515-2-costa.shul@redhat.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251209100047.2692515-1-costa.shul@redhat.com> References: <20251209100047.2692515-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: 8bit 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/common.c index a78f9883521e..e5aa8c30cd7d 100644 --- a/tools/tracing/rtla/src/common.c +++ b/tools/tracing/rtla/src/common.c @@ -56,14 +56,20 @@ int common_parse_options(int argc, char **argv, struct common_params *common) int c; static struct option long_options[] = { + {"cpus", required_argument, 0, 'c'}, {0, 0, 0, 0} }; opterr = 0; - c = getopt_long(argc, argv, "", long_options, NULL); + c = getopt_long(argc, argv, "c:", long_options, NULL); opterr = 1; switch (c) { + case 'c': + if (parse_cpu_set(optarg, &common->monitored_cpus)) + fatal("Invalid -c cpu list"); + common->cpus = optarg; + break; default: optind = 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; - c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5:6:7:", + c = 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); /* detect the end of the options. */ @@ -547,12 +546,6 @@ static struct common_params params->common.hist.bucket_size >= 1000000) fatal("Bucket size needs to be > 0 and <= 1000000"); break; - case 'c': - retval = parse_cpu_set(optarg, ¶ms->common.monitored_cpus); - if (retval) - fatal("Invalid -c cpu list"); - params->common.cpus = optarg; - break; case 'C': params->common.cgroup = 1; params->common.cgroup_name = 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[] = { {"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; - c = getopt_long(argc, argv, "a:c:C::d:De:hH:p:P:qr:s:S:t::T:0:1:2:3:", + c = getopt_long(argc, argv, "a:C::d:De:hH:p:P:qr:s:S:t::T:0:1:2:3:", long_options, NULL); /* 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 = "osnoise_trace.txt"; - break; - case 'c': - retval = parse_cpu_set(optarg, ¶ms->common.monitored_cpus); - if (retval) - fatal("Invalid -c cpu list"); - params->common.cpus = optarg; break; case 'C': params->common.cgroup = 1; diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/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[] = { {"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; - c = getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:", + c = 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); /* detect the end of the options. */ @@ -859,12 +858,6 @@ static struct common_params if (!trace_output) trace_output = "timerlat_trace.txt"; - break; - case 'c': - retval = parse_cpu_set(optarg, ¶ms->common.monitored_cpus); - if (retval) - fatal("Invalid -c cpu list"); - params->common.cpus = optarg; break; case 'C': params->common.cgroup = 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[] = { {"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; - c = getopt_long(argc, argv, "a:c:C::d:De:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:", + c = getopt_long(argc, argv, "a:C::d:De:hH:i:knp:P:qs:t::T:uU0:1:2:345:6:7:", long_options, NULL); /* 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 = 1; break; - case 'c': - retval = parse_cpu_set(optarg, ¶ms->common.monitored_cpus); - if (retval) - fatal("Invalid -c cpu list"); - params->common.cpus = optarg; - break; case 'C': params->common.cgroup = 1; params->common.cgroup_name = optarg; -- 2.52.0