From mboxrd@z Thu Jan 1 00:00:00 1970 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 6F96039F16D for ; Fri, 20 Mar 2026 15:07:11 +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=1774019233; cv=none; b=fzPD2BnKUzZELTbJQY1seLmZqqRRRRxXKzHQ/T0r5S3cnDAvPSuxnKVJDgqJuKiMpLeZvPwvaH2f9oaY7KHW/RlYfAy5QB/OCpyjHoIEU/PHUE8Sn+kR7MZwB0LQGTjIvJjsyHSropR5I0blYmyT0Vwlrmi8/aTO2FS1gVEp6ak= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774019233; c=relaxed/simple; bh=9NJhvnMb2WzoR+1Xqcml2CCcX3ljBfMGnAluGqdBIHg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:content-type; b=WleK3dzqMMyBA0dYoczUwk6Gs3d+KcCnFNebHgdt0r/4HiZyOJQPMAOQCLTOEc4/6XfOdwT7h1D1YWBVmTADxpSFSw1qgUIpIy7Px2pHu5H8siq9Suz6TiDlcnisS95u6e6vux1TYcxFRabPPLzeG7PjfgFI5r7nrial093z+7c= 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=MlI/EXIS; 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="MlI/EXIS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774019230; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yX54CfA8Z4/s2Z7zgrl9bkBwpnQ0SIfZEsoNAvqWGy8=; b=MlI/EXISIpBlSp6Kg4sOsHLWrlxgWI8MsY2iihhPb8CUExHV+Lf2XtTd7p5vqpa8xjTHSC UrlDYoeztK7Gx6jhO6iNDD4VBTlB4AX3rciUYUA4v11rnw7RX6KClM+FOA1cV4E1bKBw6M ArnmxSNi4tKNIzbXBObhEUfAmAsv3k8= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-329-Od-XMuRvMXWs3aQ2hbdRYQ-1; Fri, 20 Mar 2026 11:07:06 -0400 X-MC-Unique: Od-XMuRvMXWs3aQ2hbdRYQ-1 X-Mimecast-MFC-AGG-ID: Od-XMuRvMXWs3aQ2hbdRYQ_1774019223 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B57D219560AB; Fri, 20 Mar 2026 15:07:03 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.223]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C084E30001A1; Fri, 20 Mar 2026 15:06:59 +0000 (UTC) From: Tomas Glozar To: Steven Rostedt , Tomas Glozar Cc: John Kacur , Luis Goncalves , Crystal Wood , Costa Shulyupin , Wander Lairson Costa , Ivan Pravdin , Namhyung Kim , Ian Rogers , Arnaldo Carvalho de Melo , LKML , linux-trace-kernel , linux-perf-users Subject: [PATCH 0/3] rtla: Migrate to libsubcmd for command line option parsing Date: Fri, 20 Mar 2026 16:06:48 +0100 Message-ID: <20260320150651.51057-1-tglozar@redhat.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-MFC-PROC-ID: B2foRRX7CUWdROqvwI_8i5rzhJ7kL0GNotGuVf8ZxmM_1774019223 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true [ CC to linux-perf-users for the libsubcmd code change (second commit) ] rtla currently uses its own implementation that uses getopt_long() to parse command-line arguments. Migrate rtla to use libsubcmd for command line argument parsing, similarly to what is already done by other tools like perf, bpftool, and objtool. Among other benefits, this allows help messages to be generated automatically rather then having to by typed out manually for each tool. libsubcmd is extended with an option to parse optarg from separate argument if a new flag is turned on. Without the flag, the old behavior is preserved. That keeps the parsing working for tools that use positional arguments, and allows RTLA to keep its flexible syntax for -C and -t options and their long variants, --cgroup and --trace-output. The new implementation is moved into a separate file, cli.c, together with a tiny header counterpart, cli.h. This helps separate the parsing logic, which has little in common with the rest of RTLA, in a separate module. Macros to generate struct option array fields for libsubcmd's parse_args() are used to preserve the consolidation of argument parsing code across different RTLA tools. Kernel and user threads are, as an exception, treated as common, although they are currently implemented for timerlat only, in line with earlier consolidation changes. I expect more improvements to the code being possible in the future, like creating macros for option groups to further deduplicate the code, or reduce the amount of extra code in the _parse_args() functions. Tomas Glozar (3): rtla: Add libsubcmd dependency tools subcmd: support optarg as separate argument rtla: Parse cmdline using libsubcmd tools/lib/subcmd/parse-options.c | 53 +- tools/lib/subcmd/parse-options.h | 1 + tools/tracing/rtla/.gitignore | 1 + tools/tracing/rtla/Makefile | 53 +- tools/tracing/rtla/src/Build | 2 +- tools/tracing/rtla/src/cli.c | 1207 ++++++++++++++++++++++++ tools/tracing/rtla/src/cli.h | 7 + tools/tracing/rtla/src/common.c | 109 --- tools/tracing/rtla/src/common.h | 26 +- tools/tracing/rtla/src/osnoise_hist.c | 221 +---- tools/tracing/rtla/src/osnoise_top.c | 200 +--- tools/tracing/rtla/src/rtla.c | 89 -- tools/tracing/rtla/src/timerlat.h | 4 +- tools/tracing/rtla/src/timerlat_hist.c | 317 +------ tools/tracing/rtla/src/timerlat_top.c | 285 +----- tools/tracing/rtla/src/utils.c | 28 +- tools/tracing/rtla/src/utils.h | 9 +- tools/tracing/rtla/tests/hwnoise.t | 2 +- 18 files changed, 1331 insertions(+), 1283 deletions(-) create mode 100644 tools/tracing/rtla/src/cli.c create mode 100644 tools/tracing/rtla/src/cli.h delete mode 100644 tools/tracing/rtla/src/rtla.c -- 2.53.0