[PATCH v1 0/8] tools/rtla: Consolidate common command line options

From: Costa Shulyupin

Date: Fri Nov 21 2025 - 12:45:22 EST


Argument parsing functions are the longest functions of the project:

lizard --warnings_only --sort nloc -L100 | head -n 4
./src/timerlat_hist.c:766: warning: timerlat_hist_parse_args has 247 NLOC, 76 CCN, 1579 token, 1 PARAM, 287 length, 0 ND
./src/timerlat_top.c:538: warning: timerlat_top_parse_args has 217 NLOC, 64 CCN, 1338 token, 2 PARAM, 262 length, 0 ND
./src/osnoise_hist.c:469: warning: osnoise_hist_parse_args has 195 NLOC, 56 CCN, 1225 token, 1 PARAM, 216 length, 0 ND
./src/osnoise_top.c:322: warning: osnoise_top_parse_args has 169 NLOC, 46 CCN, 1019 token, 2 PARAM, 191 length, 0 ND

Moreover, they contain a lot of duplicate code and growing.

Refactor these functions to reduce code duplication.

Benefits:
- Single implementation for common options
- Easier maintenance and consistent behavior

Costa Shulyupin (8):
tools/rtla: Add common_parse_options()
tools/rtla: Consolidate -c/--cpus option parsing
tools/rtla: Consolidate -C/--cgroup option parsing
tools/rtla: Consolidate -D/--debug option parsing
tools/rtla: Consolidate -d/--duration option parsing
tools/rtla: Consolidate -e/--event option parsing
tools/rtla: Consolidate -P/--priority option parsing
tools/rtla: Consolidate -H/--house-keeping option parsing

tools/tracing/rtla/src/common.c | 78 ++++++++++++++++++++++++++
tools/tracing/rtla/src/common.h | 1 +
tools/tracing/rtla/src/osnoise_hist.c | 53 ++---------------
tools/tracing/rtla/src/osnoise_top.c | 53 ++---------------
tools/tracing/rtla/src/timerlat_hist.c | 53 ++---------------
tools/tracing/rtla/src/timerlat_top.c | 52 ++---------------
6 files changed, 95 insertions(+), 195 deletions(-)

--
2.51.1