From nobody Sat Oct 4 20:57:10 2025 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 380092F90CE; Tue, 12 Aug 2025 16:27:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755016077; cv=none; b=fA20xB866AeFjsOi0eViHX1/FV2nLCa+8bnoER0efbX0Vbs2JvFbT1ggzbzrUpvHhMG081q0bnVhfHFLmERY5idi9EHpESO+GFoCWwpWPnLCIN3GmrZLMsALuqF0gehPsCsALKd2puVFjgEScQiehB9VNsN8UmTamS1SA7lQimA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755016077; c=relaxed/simple; bh=sH8ZhJxjPjK/W5fojUbfcWKAEcP9xOolfJwD3H7oH74=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tAU3Ey39dEFbKSXNPCM1QIjPf9qdClvjPcIZRD0qql0mM19b2BTREYigMDg0fjKfnpzcGWTB+y4owIMUlIHy6ki4OrNlte7pmNEuQoghvWoZddD1RtgMyYyi1OoidS/6OYj86tuT9FlOkj8jLtJ4J4VBwD10eaRNUOT+e7o20vI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XneTJzWN; arc=none smtp.client-ip=209.85.222.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XneTJzWN" Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-7e2c1dc6567so369003385a.1; Tue, 12 Aug 2025 09:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755016075; x=1755620875; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SM8pT9HqxyMa3H416EZmlZYSb6JbMTeAfDZVPtYuWGY=; b=XneTJzWNo8HXowd+RaQWjEar51JsfU1BU4oJT7PG/FIJvipqcAyMXUX1Oa6Q0qOlb/ 0MtbF3V4NwaFKK1TmC8m5K6f6e5/SIN2I7KcZmevfkqsqDS6VwUK6Gk+HkV/CKqekxyt eUBEhofS8VGaYYq5W/oOz2MAHTPM53JvSX5HLEVjKT+TgVuQUjGqhVU7bPaxNa+M8hd1 sxrvd7wtkhZYKFHawJss59ZXmEVEi2gKQlIKJpaEhxJ+ycxGPdaqcqJoCfCeU61nUC/l 7PyUNuE15jrtHQUPxRNNqvEh0XLTqvmD2WUmBO+5Lhay32/hZrIHJhj3oYce/kPpAYvM hbAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755016075; x=1755620875; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SM8pT9HqxyMa3H416EZmlZYSb6JbMTeAfDZVPtYuWGY=; b=WQPNBlHdfmMvUlVjWJWxUAkNBS/IX6C6A258QWrdR0PTexJ5zFKj9DpkvvlwPOn6EK CrkQZJQgFIhp6QnhKiBhG2Eu332nG753B07Hw9k9vIGGshUHhJKo0Mb6UqwwS4qG9LES YhoRGZz9wzXScgd4XD8LAH42fXvGPCHkM59+uGcDuXce4GBaPDC8sl74+RkEYKStVNts 3hU1FzEcLbwDA3UHZIz94GWz2d8Ax+SGbXhHI3NKRpnpqzl9VlJXyYH56vjWTR60iyeB rYh64CzecZbhLaqF3SlPvvERYM6zXZaqa978G7tZf1u6J5owWG4qOR0vJyGnFt8zZabu 1EyA== X-Forwarded-Encrypted: i=1; AJvYcCUuVLGIkkmTi4sexIdoEQf0zfbxmtiv3L9CRbAUOmtv9PTXagYFY/UZSdEP6VLfXbgLhZiZRPwhbjsE6O+708eGcC/h@vger.kernel.org, AJvYcCWTmjInpAwjKdE7XEFkjcIGb6+qLg1Zku3b2OchchcjAZtj45n5FwwvqJUBh2mAHu/LckkC+YZshmjVwbtS@vger.kernel.org, AJvYcCX+uT6G2mpXxgBHxQEA3BX+P4BRyG76pKktD39EQCnNJAm0rcaRiFf0PWUHXo49TuidMmPh8B7RIWA=@vger.kernel.org X-Gm-Message-State: AOJu0Yw6SWrwxBwxVucaUx9BhwEolaBbgIhr0gph4nis3ynqKOOoAWM/ dnREFtPseUwsPR3GSu9WRyR/1BmP8VQSwUBx5KV8DKjAuAfqRNAT7UJztTEXZlHm X-Gm-Gg: ASbGnctDBFeQCc8p00atEsUZEV1CoIOZFBEITnt3RC2HThpuZ1pHkZUUG1ipmE8wfFs 0SLjHPiRebDu2nhs03aAtzr+n/ueHEAE5TJ/h+BOKfA6ELIN8HEDblyB5q4UXNppFQv6yv0xWht 1YmcGctQMdNU3P//uxhN0MOc8PMbBLRab73V8ifvwvvjD3JW42win+O2SVt0FxODjPSv+cFYHRc 1KgWtMCqtpeA0z/PlYLWiBknMfBnpJXnfjtMJGJ6Tdey3GOYDZzH7kHd6hrRXAUw5mIg4QCs6s7 ytBMlZUcveAOb4rMLZuxNRSfL7BCxjtbkQrOARD3YkbDse+U6nlGZt9hhiNWe4Zh4e6TN3Y27WZ kVrNGkQBCu2tGXfJJMxiFvazeW/qPZWHZDgSq4BZW8EamH+ecSbIEt192hwJZLRZijpvr/F9Bzy ys7Euftffj4wcZ X-Google-Smtp-Source: AGHT+IEXWLCDOoIUg8sO/RUBFwfq47KnsYs2PT1+RjuQgmzwjpMo4+nK8+M7EzM4TrdX+OU0o6rqLQ== X-Received: by 2002:a05:620a:a811:b0:7e6:30dd:529 with SMTP id af79cd13be357-7e86446841bmr54878485a.10.1755016074924; Tue, 12 Aug 2025 09:27:54 -0700 (PDT) Received: from ipravd-Nitro-AN515-55.mynetworksettings.com ([2600:4040:530f:f000:a841:61f7:aa1f:bc8]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7e8079cfcc9sm1269013885a.29.2025.08.12.09.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Aug 2025 09:27:54 -0700 (PDT) From: Ivan Pravdin To: rostedt@goodmis.org, corbet@lwn.net, tglozar@redhat.com, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ivan Pravdin Subject: [PATCH 1/3] rtla: fix buffer overflow in actions_parse Date: Tue, 12 Aug 2025 12:27:30 -0400 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: 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" Currently, tests 3 and 13-22 in tests/timerlat.t fail with error: *** buffer overflow detected ***: terminated timeout: the monitored command dumped core The result of running `sudo make check` is tests/timerlat.t (Wstat: 0 Tests: 22 Failed: 11) Failed tests: 3, 13-22 Files=3D3, Tests=3D34, 140 wallclock secs ( 0.07 usr 0.01 sys + 27.63 = cusr 27.96 csys =3D 55.67 CPU) Result: FAIL Fix buffer overflow in actions_parse to avoid this error. After this change, the tests results are tests/hwnoise.t ... ok tests/osnoise.t ... ok tests/timerlat.t .. ok All tests successful. Files=3D3, Tests=3D34, 186 wallclock secs ( 0.06 usr 0.01 sys + 41.10 = cusr 44.38 csys =3D 85.55 CPU) Result: PASS Fixes: 6ea082b171e0 ("rtla/timerlat: Add action on threshold feature") Signed-off-by: Ivan Pravdin --- tools/tracing/rtla/src/actions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tracing/rtla/src/actions.c b/tools/tracing/rtla/src/acti= ons.c index aaf0808125d7..eab51c0c0ce2 100644 --- a/tools/tracing/rtla/src/actions.c +++ b/tools/tracing/rtla/src/actions.c @@ -131,7 +131,7 @@ actions_parse(struct actions *self, const char *trigger) { enum action_type type =3D ACTION_NONE; char *token; - char trigger_c[strlen(trigger)]; + char trigger_c[strlen(trigger) + 1]; =20 /* For ACTION_SIGNAL */ int signal =3D 0, pid =3D 0; --=20 2.48.1 From nobody Sat Oct 4 20:57:10 2025 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97AA42F659B; Tue, 12 Aug 2025 16:27:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755016080; cv=none; b=fb6BAbE7TBU96ZN338cWFgdZ3IEnSBNfq6/af39gUl4he/bKcT7vVAYcS/9bB0+75blpd9sIJ7Of5ww47s0XdHwiU1Go9Wmz6b3tI1rDyGAVdUoCFuzsgohO1Msg39sps8zjxDXH1c4cYZIpjVDOwnX7NuRHpXZ5F5W9bBKiCYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755016080; c=relaxed/simple; bh=b2J8dR+dS8w9QpFRYh+CDJAJYdMXE6W78LAGhBr5/m4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VZZTxv5r4jbN6hsvTA+wnL/x+WGCfbS8adsa5SFpOuS2RLNZksbztcv2WgVdr2mTpgG2qz6dnf83rbDiXg0PtvgIELeGBrBWQUB99HzRrBfitqiInseFj3lExpvHiNecyzvo2Nb+UAsgsbsIhxAhB3ugL/fF/rAqZWzpuU0ZtAk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JUJhmvOk; arc=none smtp.client-ip=209.85.222.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JUJhmvOk" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-7e8248b3f1cso691282085a.0; Tue, 12 Aug 2025 09:27:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755016077; x=1755620877; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pVvse4gwG4SHMNUE37lqj8akcoNPT2eJxOWdm0u/E6c=; b=JUJhmvOk3nDLdN90mzRXhCEO8Y0cfTgfDUnmotP29Z44z+htlsOGPYvtc6dt5p2719 obviawsuKDpug33/7reFyIMHrDd0AtLXF8P9Fg4bjKa/37ELeAbDoC416MD1w+zmbgnZ JTxEZV1WcbQpoS9/52NljP2vWe5Q9XbOYlSHdOxE+KD4F2rHIcfsRzk6kyIKzIrmF+/w trLUawgHrPRKflStoXgQ/KVelKC+/+wj55tgkWp7gPZqanx49MiJnC5p3A3HENvCPuLM KxYJdH5PJb4j2FEU461/KE7TmEtHYZ7KTw29t3++8RYS8OsO1eMMn9kr5lD4KHt2HhtG 7BTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755016077; x=1755620877; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pVvse4gwG4SHMNUE37lqj8akcoNPT2eJxOWdm0u/E6c=; b=G3uCKn3S9eTauTK7lqtdRgozhxLLIP5AOzBNVxM14abqW6HER0mNS/nJ2f7JwVI1Yy QLx00W7BmPqvlheG2alYEDs8JSaE1EafbxaJQ/vWT013lnflYCT3pH5S5grlaBrzi6YM mwEPZqqvM0QU2n2OYEJh4GI3Ai4tBY+PIw8V1rB0Vo/fSpHA+JwjxWszxPzhGRiKWcAJ J6cLN/yP8UMQxVcpleOHDztfs6QCI6zn1WuNM5t1mJl/zNucy/GRa8hY8cHHufvS4158 4ZwmQr/VJtZc26MVoKsKF6hhsY9xf72U/5uSQZ47kfbVBTowfOO+CBMt/NgfbEYwIE92 ZjCg== X-Forwarded-Encrypted: i=1; AJvYcCUJ/SW0v6Jl8+AtRoiOYtGZvS8wQ4vAJQcre7jZPWkIIBeYDYuZYHfQZfK/gbllo7Faoijy/VJit38=@vger.kernel.org, AJvYcCW6UtJbQNGYks+PSfRkoK1wOEHlgsPc7FIapxiMqmR0/wApBKItuq6N6q5iOmfUki7QBD4sJRDnKo4vctNtJF4drG2N@vger.kernel.org, AJvYcCWhIC3d1usneu6sEjM2A1F//Oswo6NjL+9gKk9svFamQcTxshQuJZa7nJAQI+OyE8u9oWtVamwPRRaIoTnb@vger.kernel.org X-Gm-Message-State: AOJu0YzzY56tYnVbIUelbQ+GsPaokVbwVryFi1Q+0Okf3dS/pYrzjMH+ fK1OnMkCAzcRhyIDqxzf7ndlMBSie7fstyOAIa3p0/To44/oeGCGYsOI X-Gm-Gg: ASbGnct3yLJ1cBYVq3NclYiWtcZ04kgYa1pkQmi79OwOulRiQN2qGVoPZxSc2rU7id5 FKGgsEUusMJCIdzHTPCrvhKc3Yk8xJ1W2dz18LSxy7nhZzzZmXVP0cCbKFPg3ktmK46e2z8+bD2 XKK1SnEzQZs2O+bvE44yjyG0CnzMRUOPA8B9FrtWWAfU7rdzAXNr7Y5SFpG+Mu+vVFLqHAUS1pN wOBADBsu6OEcIWw/hGvrdVFAsbKtCJjMtrVUu7A/7wt5th4zdZcOazIskXvu+nvFelfll3ckLh5 HqDxPQWglOWQdtwOr0Xij/n4Sw14KMZk2DF2QHWY91Pl2ZQKByKlN1c2hmQXmahI1zBTpO/98Ex HSRDUd+Bx5ACN2dCEQOY9SS7Ycyk9kQmyX2t1+w9Ngd3pd28vzXdV7IfsCkG3gONI8V2Klriszc gTrYc37FdeM5l4 X-Google-Smtp-Source: AGHT+IEZOFBaQmq8M/TLVSdvSJqstKbfFiDBnB5aLkMnf/DUtBrvnsght8jgx8jzMv/NteEco9LH8g== X-Received: by 2002:a05:620a:611e:b0:7c5:3d60:7f91 with SMTP id af79cd13be357-7e8645175famr38152685a.15.1755016077189; Tue, 12 Aug 2025 09:27:57 -0700 (PDT) Received: from ipravd-Nitro-AN515-55.mynetworksettings.com ([2600:4040:530f:f000:a841:61f7:aa1f:bc8]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7e8079cfcc9sm1269013885a.29.2025.08.12.09.27.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Aug 2025 09:27:56 -0700 (PDT) From: Ivan Pravdin To: rostedt@goodmis.org, corbet@lwn.net, tglozar@redhat.com, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ivan Pravdin Subject: [PATCH 2/3] rtla: fix -C/--cgroup interface Date: Tue, 12 Aug 2025 12:27:31 -0400 Message-ID: <4c350277bffecdf736ebc69f76de265e693fda14.1755014784.git.ipravdin.official@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: 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" Currently, user can only specify cgroup to the tracer's thread the following ways: `-C[cgroup]` `-C[=3Dcgroup]` `--cgroup[=3Dcgroup]` If user tries to specify cgroup as `-C [cgroup]` or `--cgroup [cgroup]`, the parser silently fails and rtla's cgroup is used for the tracer threads. To make interface more user-friendly, allow user to specify cgroup in the aforementioned way, i.e. `-C [cgroup]` and `--cgroup [cgroup]` Change documentation to reflect this user interface change. Signed-off-by: Ivan Pravdin --- Documentation/tools/rtla/common_options.rst | 2 +- tools/tracing/rtla/src/osnoise_hist.c | 16 +++++++----- tools/tracing/rtla/src/osnoise_top.c | 16 +++++++----- tools/tracing/rtla/src/timerlat_hist.c | 16 +++++++----- tools/tracing/rtla/src/timerlat_top.c | 28 ++++++++------------- 5 files changed, 41 insertions(+), 37 deletions(-) diff --git a/Documentation/tools/rtla/common_options.rst b/Documentation/to= ols/rtla/common_options.rst index 2dc1575210aa..3f292a12b7af 100644 --- a/Documentation/tools/rtla/common_options.rst +++ b/Documentation/tools/rtla/common_options.rst @@ -42,7 +42,7 @@ - *f:prio* - use SCHED_FIFO with *prio*; - *d:runtime[us|ms|s]:period[us|ms|s]* - use SCHED_DEADLINE with *= runtime* and *period* in nanoseconds. =20 -**-C**, **--cgroup**\[*=3Dcgroup*] +**-C**, **--cgroup** \[*cgroup*] =20 Set a *cgroup* to the tracer's threads. If the **-C** option is pa= ssed without arguments, the tracer's thread will inherit **rtla**'s *cgroup= *. Otherwise, the threads will be placed on the *cgroup* passed to the opti= on. =20 diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src= /osnoise_hist.c index 8d579bcee709..92c379fbe030 100644 --- a/tools/tracing/rtla/src/osnoise_hist.c +++ b/tools/tracing/rtla/src/osnoise_hist.c @@ -435,7 +435,7 @@ static void osnoise_hist_usage(char *usage) " -T/--threshold us: the minimum delta to be considered a noise", " -c/--cpus cpu-list: list of cpus to run osnoise threads", " -H/--house-keeping cpus: run rtla control threads only on the given = cpus", - " -C/--cgroup[=3Dcgroup_name]: set cgroup, if no cgroup_name is passed= , the rtla's cgroup will be inherited", + " -C/--cgroup [cgroup_name]: set cgroup, if no cgroup_name is passed, = the rtla's cgroup will be inherited", " -d/--duration time[s|m|h|d]: duration of the session", " -D/--debug: print debug info", " -t/--trace[file]: save the stopped trace to [file|osnoise_trace.txt]= ", @@ -559,12 +559,16 @@ static struct osnoise_params break; case 'C': params->cgroup =3D 1; - if (!optarg) { - /* will inherit this cgroup */ + if (optarg) { + if (optarg[0] =3D=3D '=3D') + /* skip the =3D */ + params->cgroup_name =3D &optarg[1]; + else + params->cgroup_name =3D optarg; + } else if (optind < argc && argv[optind][0] !=3D '-') { + params->cgroup_name =3D argv[optind]; + } else { params->cgroup_name =3D NULL; - } else if (*optarg =3D=3D '=3D') { - /* skip the =3D */ - params->cgroup_name =3D ++optarg; } break; case 'D': diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/= osnoise_top.c index 2c12780c8aa9..d149c3c4ac11 100644 --- a/tools/tracing/rtla/src/osnoise_top.c +++ b/tools/tracing/rtla/src/osnoise_top.c @@ -269,7 +269,7 @@ static void osnoise_top_usage(struct osnoise_params *pa= rams, char *usage) " -T/--threshold us: the minimum delta to be considered a noise", " -c/--cpus cpu-list: list of cpus to run osnoise threads", " -H/--house-keeping cpus: run rtla control threads only on the given = cpus", - " -C/--cgroup[=3Dcgroup_name]: set cgroup, if no cgroup_name is passed= , the rtla's cgroup will be inherited", + " -C/--cgroup [cgroup_name]: set cgroup, if no cgroup_name is passed, = the rtla's cgroup will be inherited", " -d/--duration time[s|m|h|d]: duration of the session", " -D/--debug: print debug info", " -t/--trace[file]: save the stopped trace to [file|osnoise_trace.txt]= ", @@ -394,12 +394,16 @@ struct osnoise_params *osnoise_top_parse_args(int arg= c, char **argv) break; case 'C': params->cgroup =3D 1; - if (!optarg) { - /* will inherit this cgroup */ + if (optarg) { + if (optarg[0] =3D=3D '=3D') + /* skip the =3D */ + params->cgroup_name =3D &optarg[1]; + else + params->cgroup_name =3D optarg; + } else if (optind < argc && argv[optind][0] !=3D '-') { + params->cgroup_name =3D argv[optind]; + } else { params->cgroup_name =3D NULL; - } else if (*optarg =3D=3D '=3D') { - /* skip the =3D */ - params->cgroup_name =3D ++optarg; } break; case 'D': diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/sr= c/timerlat_hist.c index 9baea1b251ed..c397f6260054 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -726,7 +726,7 @@ static void timerlat_hist_usage(char *usage) " -s/--stack us: save the stack trace at the IRQ if a thread latency i= s higher than the argument in us", " -c/--cpus cpus: run the tracer only on the given cpus", " -H/--house-keeping cpus: run rtla control threads only on the given = cpus", - " -C/--cgroup[=3Dcgroup_name]: set cgroup, if no cgroup_name is passed= , the rtla's cgroup will be inherited", + " -C/--cgroup [cgroup_name]: set cgroup, if no cgroup_name is passed, = the rtla's cgroup will be inherited", " -d/--duration time[m|h|d]: duration of the session in seconds", " --dump-tasks: prints the task running on all CPUs if stop conditi= ons are met (depends on !--no-aa)", " -D/--debug: print debug info", @@ -885,12 +885,16 @@ static struct timerlat_params break; case 'C': params->cgroup =3D 1; - if (!optarg) { - /* will inherit this cgroup */ + if (optarg) { + if (optarg[0] =3D=3D '=3D') + /* skip the =3D */ + params->cgroup_name =3D &optarg[1]; + else + params->cgroup_name =3D optarg; + } else if (optind < argc && argv[optind][0] !=3D '-') { + params->cgroup_name =3D argv[optind]; + } else { params->cgroup_name =3D NULL; - } else if (*optarg =3D=3D '=3D') { - /* skip the =3D */ - params->cgroup_name =3D ++optarg; } break; case 'b': diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index c80b81c0b4da..73949d52cf41 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -423,15 +423,6 @@ timerlat_top_print_sum(struct osnoise_tool *top, struc= t timerlat_top_cpu *summar } } =20 -/* - * clear_terminal - clears the output terminal - */ -static void clear_terminal(struct trace_seq *seq) -{ - if (!config_debug) - trace_seq_printf(seq, "\033c"); -} - /* * timerlat_print_stats - print data for all cpus */ @@ -449,9 +440,6 @@ timerlat_print_stats(struct timerlat_params *params, st= ruct osnoise_tool *top) if (nr_cpus =3D=3D -1) nr_cpus =3D sysconf(_SC_NPROCESSORS_CONF); =20 - if (!params->quiet) - clear_terminal(trace->seq); - timerlat_top_reset_sum(&summary); =20 timerlat_top_header(params, top); @@ -492,7 +480,7 @@ static void timerlat_top_usage(char *usage) " -s/--stack us: save the stack trace at the IRQ if a thread latency i= s higher than the argument in us", " -c/--cpus cpus: run the tracer only on the given cpus", " -H/--house-keeping cpus: run rtla control threads only on the given = cpus", - " -C/--cgroup[=3Dcgroup_name]: set cgroup, if no cgroup_name is passed= , the rtla's cgroup will be inherited", + " -C/--cgroup [cgroup_name]: set cgroup, if no cgroup_name is passed, = the rtla's cgroup will be inherited", " -d/--duration time[s|m|h|d]: duration of the session", " -D/--debug: print debug info", " --dump-tasks: prints the task running on all CPUs if stop conditi= ons are met (depends on !--no-aa)", @@ -650,12 +638,16 @@ static struct timerlat_params break; case 'C': params->cgroup =3D 1; - if (!optarg) { - /* will inherit this cgroup */ + if (optarg) { + if (optarg[0] =3D=3D '=3D') + /* skip the =3D */ + params->cgroup_name =3D &optarg[1]; + else + params->cgroup_name =3D optarg; + } else if (optind < argc && argv[optind][0] !=3D '-') { + params->cgroup_name =3D argv[optind]; + } else { params->cgroup_name =3D NULL; - } else if (*optarg =3D=3D '=3D') { - /* skip the =3D */ - params->cgroup_name =3D ++optarg; } break; case 'D': --=20 2.48.1 From nobody Sat Oct 4 20:57:10 2025 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 888C02F90FA; Tue, 12 Aug 2025 16:28:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755016082; cv=none; b=mWlr0iox09OMSfP+iCqsWIjitjBF1YS92eyon05BwlzmwrOOJyMk9SQJxiOWohkeDdUPvX5YgVkQzSYNqZCphWRpHTe3uKssF6y6CqVuQrwvnYQ6hz2pl3RYkaLKyXfLUwYzXoO+YBLVp+zqZcS78i0BzKePfrfz0+/ez/9v4tQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755016082; c=relaxed/simple; bh=aaRlaMnKQF/KXaTUudMGeFyfuROIytQq19mkqMGgYyw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mcowtjQGFJUojsuu5E2DCUBjWvq8VJBFTFKGB7SwiZJTFw4WyDIcfTOfa2vR8iCOTpRyYwp6nEamR4KIXoXm6lyuNjOf1wiwEmO8b8Y1/5/g4IYiSPQjCfSQgeJUD553ngtGp6AeA7/2LsnMusobDDC0AUXK1vbw3FACzHTpNyc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Xe6qedDz; arc=none smtp.client-ip=209.85.222.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Xe6qedDz" Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-7e6696eb47bso559695585a.3; Tue, 12 Aug 2025 09:28:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755016079; x=1755620879; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9rLm2lrFLTZGd2gYNfqFFy1afCQreKJUHVchLm6m9Xo=; b=Xe6qedDzA5kelivDAznTzxujAjQ8SWeZeRJScwIiJxi87j73sSIjw7ZtZuj+Kyvvw6 aLkUMmTtOUogU0UF9mUO1PQbFTDcVxotXas2sXrjM6yFVr8keRVGLBczsI4dcNujItp8 bx3LoW3k2JNY0oKyKC8rDCqvBQE7Rahhon1hM8R9v5AXeIAKRNNtI7T0SbAolEvg4TjA yU/dWGxzFzodLde+QzZUKs9TYm8A1EmWJXAXiQx9PcR2TjABQgYb6ouEMudPXHfuPQth CWFPbUnKUdFVHQ961AtF47FA7HwCGoM72GdjluRWrkTEC3KBP23DTl5yFLHS1BoZFXfu 1KVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755016079; x=1755620879; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9rLm2lrFLTZGd2gYNfqFFy1afCQreKJUHVchLm6m9Xo=; b=uhS9FETTWW2gMwX4MbS3/d4GvMiEVdxGBQMMMXysdBGwyi1UIAnZp6NpOAvInTyGJH Yek2o7Wc8siUrx1RWS2nOqkUXM+xuZ/0rBTKzHLO9MgDk4WxVmp3NQSGdfyHykvKbYJ0 aHKVwnYR0h52+BtLM7gG/LSq692YXpBDEUo1XmnvwGsiqLZd58k4MJBlMEgH/RR7Uk57 WwPkgTlaxuMvbWb2TMiob8dBxanpXCxIvI58LT23EGQ3d1ydKbxgqXFUOMN2HZOaTwbN 2k5G2QcnoK/Tmm9p0q+PEjqXQRyTQEWsNv3K1HeQb/5TEQVXefUtUuoW0NVHbR+RmYXH 5s7g== X-Forwarded-Encrypted: i=1; AJvYcCUMUKpeWzRf6sl0CZbeDJBXhOGosbxbbRa6QqD6EISnTna5Y1VANIT++Wr0uKpWGCcnj4JWVICZSL46R6+U@vger.kernel.org, AJvYcCV95o9KkCu+sLoFyzSz2nrcSM0aU1A0xvHqKnI73rXo9oN03zWI9hgBp3jYheL68q1ppYxyGuXsyEWa7NCoRcBGd5Au@vger.kernel.org, AJvYcCWwEkxoCTjSx+KGmNR36LyJc6d2OXOKbc9hl7K4ul9jiSPAkkPTeVcSJvaiuOw7f0fl6BFiBOhWHRk=@vger.kernel.org X-Gm-Message-State: AOJu0YwM+zpqZymVaWPnEUc7VsuCq8VtBPoKNFsDD6MsmROB5SwcOdAA q28jBactKeV8egDD4xHqmA3O5VH89+77qsJbj6SbvKe68uyDBp16YCHm X-Gm-Gg: ASbGncvNv5qBaAGHqNKl+J978sSniYV2ELQ7OiTi2cbz6MG0kzIBIoQ4ynR2LRGY9PO j+P7+Kidb4ld22Ff83Dn8Q5br+ItWVxCSIdy8C/YS5hMSVEtTKdM7T7tnqKyN4jUFStpl5vyVfY mIGG23/HV93fIUANSCx3xoDxyRq5ByAanokIxBUmfJlW2Ke5j+RtK3E4AeUSrfwbzPu3od9B889 s8mQNPXqkItsPdzA/xGynXgHLB554UBHY3gtBF3gI5qP6uBP+Wk3sjmaH31AS75tHbceFYXkKdT zm9x+wYrxAH8+7QMO0ZuhVe2/94sPDjLcMMVPs5CB/nJwEjlC9OEkohw+EK62vqc9rPxOOuttK4 Tn9Q7UPvx7fnmxUjw1O7Evxm+oy3t3hg6oWKzbxdfhW4tGgwj/5bxbKa7WimHP01DN9B2C3iBNv ec3U266YVn4cF7 X-Google-Smtp-Source: AGHT+IFo1JdEFRG0OuDkT3+aosw6jrG0ZodoETEdSk81Gszj9XVoky2dkekqX9SgLI9SwZWqYjX4fQ== X-Received: by 2002:a05:620a:aa19:b0:7c5:49b7:237c with SMTP id af79cd13be357-7e86451bef0mr37941385a.27.1755016079135; Tue, 12 Aug 2025 09:27:59 -0700 (PDT) Received: from ipravd-Nitro-AN515-55.mynetworksettings.com ([2600:4040:530f:f000:a841:61f7:aa1f:bc8]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7e8079cfcc9sm1269013885a.29.2025.08.12.09.27.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Aug 2025 09:27:58 -0700 (PDT) From: Ivan Pravdin To: rostedt@goodmis.org, corbet@lwn.net, tglozar@redhat.com, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ivan Pravdin Subject: [PATCH 3/3] rtla: fix -a overriding -t argument Date: Tue, 12 Aug 2025 12:27:32 -0400 Message-ID: X-Mailer: git-send-email 2.48.1 In-Reply-To: References: 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" When running rtla as `rtla -t custom_file.txt -a 100` -a options override trace output filename specified by -t option. Running the command above will create _trace.txt file instead of custom_file.txt. Fix this by making sure that -a option does not override trace output filename even if it's passed after trace output filename is specified. Fixes: 173a3b014827 ("rtla/timerlat: Add the automatic trace option") Signed-off-by: Ivan Pravdin --- tools/tracing/rtla/src/osnoise_hist.c | 8 +++++--- tools/tracing/rtla/src/osnoise_top.c | 8 +++++--- tools/tracing/rtla/src/timerlat_hist.c | 8 +++++--- tools/tracing/rtla/src/timerlat_top.c | 8 +++++--- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src= /osnoise_hist.c index 92c379fbe030..babcd97cec66 100644 --- a/tools/tracing/rtla/src/osnoise_hist.c +++ b/tools/tracing/rtla/src/osnoise_hist.c @@ -543,7 +543,8 @@ static struct osnoise_params params->threshold =3D 1; =20 /* set trace */ - params->trace_output =3D "osnoise_trace.txt"; + if (!params->trace_output) + params->trace_output =3D "osnoise_trace.txt"; =20 break; case 'b': @@ -639,10 +640,11 @@ static struct osnoise_params params->trace_output =3D &optarg[1]; else params->trace_output =3D &optarg[0]; - } else if (optind < argc && argv[optind][0] !=3D '0') + } else if (optind < argc && argv[optind][0] !=3D '0') { params->trace_output =3D argv[optind]; - else + } else { params->trace_output =3D "osnoise_trace.txt"; + } break; case '0': /* no header */ params->no_header =3D 1; diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/= osnoise_top.c index d149c3c4ac11..6c1e83f7a828 100644 --- a/tools/tracing/rtla/src/osnoise_top.c +++ b/tools/tracing/rtla/src/osnoise_top.c @@ -383,7 +383,8 @@ struct osnoise_params *osnoise_top_parse_args(int argc,= char **argv) params->threshold =3D 1; =20 /* set trace */ - params->trace_output =3D "osnoise_trace.txt"; + if (!params->trace_output) + params->trace_output =3D "osnoise_trace.txt"; =20 break; case 'c': @@ -469,10 +470,11 @@ struct osnoise_params *osnoise_top_parse_args(int arg= c, char **argv) params->trace_output =3D &optarg[1]; else params->trace_output =3D &optarg[0]; - } else if (optind < argc && argv[optind][0] !=3D '-') + } else if (optind < argc && argv[optind][0] !=3D '-') { params->trace_output =3D argv[optind]; - else + } else { params->trace_output =3D "osnoise_trace.txt"; + } break; case 'T': params->threshold =3D get_llong_from_str(optarg); diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/sr= c/timerlat_hist.c index c397f6260054..d4f2a5f02998 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -874,7 +874,8 @@ static struct timerlat_params params->print_stack =3D auto_thresh; =20 /* set trace */ - trace_output =3D "timerlat_trace.txt"; + if (!trace_output) + trace_output =3D "timerlat_trace.txt"; =20 break; case 'c': @@ -971,10 +972,11 @@ static struct timerlat_params trace_output =3D &optarg[1]; else trace_output =3D &optarg[0]; - } else if (optind < argc && argv[optind][0] !=3D '-') + } else if (optind < argc && argv[optind][0] !=3D '-') { trace_output =3D argv[optind]; - else + } else { trace_output =3D "timerlat_trace.txt"; + } break; case 'u': params->user_workload =3D 1; diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index 73949d52cf41..4f40e7ebde88 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -613,7 +613,8 @@ static struct timerlat_params params->print_stack =3D auto_thresh; =20 /* set trace */ - trace_output =3D "timerlat_trace.txt"; + if (!trace_output) + trace_output =3D "timerlat_trace.txt"; =20 break; case '5': @@ -716,10 +717,11 @@ static struct timerlat_params trace_output =3D &optarg[1]; else trace_output =3D &optarg[0]; - } else if (optind < argc && argv[optind][0] !=3D '-') + } else if (optind < argc && argv[optind][0] !=3D '-') { trace_output =3D argv[optind]; - else + } else { trace_output =3D "timerlat_trace.txt"; + } break; case 'u': params->user_workload =3D true; --=20 2.48.1