From nobody Sat Oct 4 20:57:10 2025 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (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 E71892F4A07; Tue, 12 Aug 2025 17:21:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755019304; cv=none; b=lEqQDNAKmaIvC6niXQ9rki2XAwsTHsnPRCOAbiA180fYAdOuz1koz0hkyr5RXhC9WhAq/pK/pG6H8s3lolKVuDRD+wHOVzU1yC00FayOLG7wgz/dceKCrxkcw2zfYdsEgWQ87tV99qezmvy5nV/SHu2oWfDJ+FndEJBqtLWy8DQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755019304; c=relaxed/simple; bh=sH8ZhJxjPjK/W5fojUbfcWKAEcP9xOolfJwD3H7oH74=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sm5YdJBTBRj1CNeMdCq9LDa8+/BKwUGc+vlHrriDlYgLJC7OqjARKErsbNtF92dolsn7ooN839+a8SIq4FgHgyVNduJfxMyWq0ZrpM1K1goZslfjgFVba7msdqcATCGGZFUuOxI21pWfN03CiRS8ZI8dCWUp+CB+4Gjq0K/3G8k= 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=XljIEBWj; arc=none smtp.client-ip=209.85.222.181 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="XljIEBWj" Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-7e806613af8so662680485a.2; Tue, 12 Aug 2025 10:21:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755019301; x=1755624101; 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=XljIEBWjq98e5JYMKguu4Kz48nZauIldiuv4RmV111srg+tYd0gafjkprconchQcQm jVoYsw0f2b230TYK0h4Dbl0hen2zhdqKTlmFt1qAnnlP52peK1460Wl9bxpodGtfhL0w iMkPUOyVlSYxfyoPmb7PKC1FCbRSaZqqD6QEUFLwDHup2kFxhGStXeNwIBQAr5qRf218 wL4aA7niCUIYjsm2U4si+NBAmuddMe2PneYqSyzBxw1G18wP8KQOAsBF7+c65OC2TYQA YEkWq9P27aS4lxDwUnjTOYdKSDJYoJtmhC/IukWdeyiJoy/Tldgd+oTISp4D9e7nsjRD yj3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755019301; x=1755624101; 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=e+e8ZwevUd8khyVzoUGOcdch4nwNLDfNbZSCqCrfJXy59WjqHB7GdCUFTeSuiW5pql /V8ih8FxHzUoy8NPdvAJ/yKX7DiHZ7ico36/X64SRx7Q1QG9I1saf401MQ4nbKgr2jeH ELYmZvlmgEXcOUP1WkY4zrZMwGhqdAr7JU54zpn9adFrNyy7H8GcIUlvQyv3YJJAwqT9 BVmBWZ3DfWZTNtXUQVEyO8+Q7HgpkRtmf+sNwcrRsc66oOcT3wZSRvhBPpFlpOTFO0yU cdpVXqHeqKayGLCNqTFu2VQBbA99/g8kMWhSyG5P3Wv0A3DgAp4vlgtuk/VkrxJ1Cfau +wlQ== X-Forwarded-Encrypted: i=1; AJvYcCV/+M1rEFgPVIN6yhUIc88/JIVI4wQAz7DXnwW/7Bt06m2q7y9P47bgffPFtJ0i3C+utJHTgF9VnKm/0o4HSY9iHT4u@vger.kernel.org, AJvYcCX2r9xHKzxW03vhfaGm3Yc3N86bKz4InFfMJX2wrEOn9c0eU85siQ5aNIlljE46XRGAdVW2U0KM2YAGOXg5@vger.kernel.org, AJvYcCXZGsB9sblN3Z96jk+kBbu29HSbDmCvr7QnFl1pmw5s6pWl4SllIvEQtkgBy9Tt6NpfF7Bzdr7Plf0=@vger.kernel.org X-Gm-Message-State: AOJu0YxHJHFyqE35xKgO9h2khEuy9Wsi/OQReayA28rXdnAWiy87SvrH GlrR0eJZSUeCrikUxxsGii3BR+6pbUZpLhyhdg9JqnyADBHC7lH2skix X-Gm-Gg: ASbGnct2Hb6NBElx/9yoHXaaGJ+jFQotRb/1YwJFdJd3PtizOQW3Kx0yM4sDLED/3at McjeMMOF9IvcuimuuBQPQyAA/cawNmK4DdRI989fxzFcH/Aot761OKmiWrSWVidGrHjYMnDO8Kd 1EgfecOITfNRElyyuduE0oz4CjqVPWRy+iVuWrEalRHOORRpGVuB2cwspDE9DYoVFxhvp1WmwQx A9yaz9hwJel+/wBnBE1w4k91aSiBYf7bMDrobTVFD2nmr3BlhBrm6DFHLtC4KRBumY5LJNYbc3H c1xAonFfGYDeaWfn43LOCT257vhjp8VKvpuNrVze7vkb4AhvL4erRwvt4FRlBQOSHRkKTXkG66h UkOD+H3UwW4KzSWqAioX734tAqjrnE4TiEzu5f79wQTm1CKXBRYfQluFF7NttYLA348sa28iLH+ /HPB4CK4mKQjVa X-Google-Smtp-Source: AGHT+IFEw8r56npI81AcDYGc37RChY9ngq0KS6ptE8f5w0v/CPHg1XJGGEBnL4aJsNDXUzKjPbxAjQ== X-Received: by 2002:a05:620a:59:b0:7e7:ccc2:67d5 with SMTP id af79cd13be357-7e86463301bmr61867885a.61.1755019300564; Tue, 12 Aug 2025 10:21:40 -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-7e82a1ccbfesm863457285a.51.2025.08.12.10.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Aug 2025 10:21:40 -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 v2 1/3] rtla: fix buffer overflow in actions_parse Date: Tue, 12 Aug 2025 13:21:07 -0400 Message-ID: <358400afe299a82806e9969570cd3009621bcd8c.1755018581.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, 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 Reviewed-by: Tomas Glozar --- 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 C3D642F7475; Tue, 12 Aug 2025 17:21:57 +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=1755019319; cv=none; b=Hs034Js0ae8jcO0r1cNmr5/OY0rZcrw0VKN3pf2+u1fp8rFg84ilzjrrRos5/9XjPoWxYrWmsFptgn9vPF9TAB1RnpKoeWvg8jyMgPTwttqQe4cnGvIEZAL/f7m2Kddyp5vXlAUye+Z6HNVP1+25hyCTdxLwxxVxYzL92L93NyI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755019319; c=relaxed/simple; bh=LwOM06oyJ3mvRmM1qS+z4Xx/tVIHy6t1yyC5hj0ET7U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LDcJMHkv6NcimwjjEP3gq1BQvGdGoY2TNx74we+EqP/y74ReuDzDG7XCvy4q7d1rm61wLvwGfX8293aJdhzbPxnyZJhQFHPupjevZSPvXDWNSU+MtshJOBMig5BB79PGcQg/NcLaHDr+SMLkEeNQMuM/CsfvNQ8/79mQPG19Hjw= 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=GTs4zlPQ; 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="GTs4zlPQ" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-7e849d7a292so286952185a.3; Tue, 12 Aug 2025 10:21:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755019317; x=1755624117; 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=VjGmbNR7gAZNxscPO3ZTs76U8Kdh+Ee956niV2hTpvE=; b=GTs4zlPQkM9GRivcfb95K2p1w+O8sql2aswtDcS25FOch5IEPU8G85bXdNcJAG8d1T +J4E2uk4TLX+fCS2KYElbwuv4dzTFvpcAG6ZlxCeSezo8TkkgSRuEkDUAGB2NPkEdPWO EoWJvYtYMKmwDR/6Bu1d+oWTl7r3l3mU7ZIrE3kNc9myXl4ZLBVfNJSNOC8y0u///fdV QAWVl0+n1jkFCnt2NV+2Fy33Ct75rO6QYXPOd+I/LCX3KzVwQHYKfMop0ESIwgJKia23 TUUYcSm9H0Ofs6+e7aFffMjhbOLHzgsdM/1+yCTXCfA8xKA04fHb32Fl3/ojaRXf+Tf2 ugRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755019317; x=1755624117; 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=VjGmbNR7gAZNxscPO3ZTs76U8Kdh+Ee956niV2hTpvE=; b=o1sIELumBo1Ag95OFlhfgoMaYTcvQugGeDUBVlvGAd0lX3UZSFhsdF3vk6DEqiT3Ot N3KPFnWmm/4rSwDi6uhnbHeVBypcbYC9Uw3V9AIYkqi5hT33ABOYV26QKH/qwKw1+lT5 BNmTZvDHdVnAEX6YQHZAoLZXA2pGCjQV6hmmUQDZFdIJaHmigFLD77za2ywKS3nSo9L7 cdz+vMxVnLwiNqU/KPO6HB1Gn0H7LQC1+HDzscB3OcSnb8E6hD8TjBc9yQ5R8IgiN1JK NRN/EWrB4vwN3ecWER9IoDijNQed+iqfsBaBTtcPLwD5+/kIBNx/89ryBsO4ixpVPnRC ddZQ== X-Forwarded-Encrypted: i=1; AJvYcCWmyJskvhBM/7IsOYCKIKRwmEQ9ypWnQ328bwqTyOaLmkFvkNl1NO4NpKlwWwrtl/o3qujL33BMJq6v6KX7@vger.kernel.org, AJvYcCXrGLYsnb5jBTjchyJ7O25Cs6KL2RbuPx8xvadPkauOV2fliHKZmgEFd6xM4BuTQFWYMHUFvVVbQfqtlmxgY2yW0hYW@vger.kernel.org, AJvYcCXvhl+Jo+JOdpNlNfj2M7itnJkz13ut6yGTPAOST10PdtFD1tr5bBfyEwgf4H2OWxCNMahUDNzbv6I=@vger.kernel.org X-Gm-Message-State: AOJu0YzJ6SsHctIrgoXdGm8su2KhqduqvmmoSQCxy0tWratIl8/894t+ Xj+vL8L9/3MF9gu6gM1U/xf1BUfby3YzW63di1E1MUN0hoDocnbnLMuG X-Gm-Gg: ASbGncvkx603cKoM/naroFCNvYTtbHOJIt9sqI1CIY9uDPiwJybvSGWB9bfG5QrasoM SY8mrOXDCwPe/lh53zqJuUmA0lNFe5cxWZnTrFHodyudoQXBzMNXnbx2BfiWknHTtgxW/c+IU8D ob5hdFiUsRv+e125W0eIcwgs2jvAg/i4UXG2noG2fNbKf8e56zxWJeMlMyakI/arfrrPszL8Cw2 J3nVPyw74Xho3dX9YqvQHJ+rwXZ+lfDFEXTug5QTQGOaqoLhjwtFN36UONtZyJi05KDJ80qZsA9 yPxmU3i1PptHq5WxMMf1Wr8oYp/pnZAFElQwX4/16IuUikSNlzONDXczvfrXuXViR7jUFkrcT1K lUSvGo2Dw12VNXexkF7kd8NrNf+L/DSoIs+Ve+tkUYCmChn8HGhtE3T5GA/SBH/WrXCCbujb7EF B0WYVGGGjOf507 X-Google-Smtp-Source: AGHT+IERbBrmkOHPHPRdywR8hNkIHSu+rbHhBXn29n3G2KrcXN48dQX6G0l4aEvSoci63NIJMimVkg== X-Received: by 2002:a05:620a:454f:b0:7e8:12c1:4d5b with SMTP id af79cd13be357-7e86529cf7bmr2953985a.6.1755019316471; Tue, 12 Aug 2025 10:21:56 -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-7e82a1ccbfesm863457285a.51.2025.08.12.10.21.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Aug 2025 10:21: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 v2 2/3] rtla: fix -C/--cgroup interface Date: Tue, 12 Aug 2025 13:21:09 -0400 Message-ID: <9394c039d5c957bd8417669148391e20fa1276ee.1755018581.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. Fixes: a957cbc02531 ("rtla: Add -C cgroup support") Signed-off-by: Ivan Pravdin --- Documentation/tools/rtla/common_options.rst | 2 +- tools/tracing/rtla/src/osnoise_hist.c | 17 +++++++++++------ tools/tracing/rtla/src/osnoise_top.c | 17 +++++++++++------ tools/tracing/rtla/src/timerlat_hist.c | 17 +++++++++++------ tools/tracing/rtla/src/timerlat_top.c | 17 +++++++++++------ 5 files changed, 45 insertions(+), 25 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..298640d92434 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,17 @@ 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..70924242bcdd 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,17 @@ 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..2a48a076d941 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,17 @@ 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..e45d9978744c 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -492,7 +492,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 +650,17 @@ 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-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 4086C2FD1AA; Tue, 12 Aug 2025 17:22:09 +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=1755019330; cv=none; b=hkQStONbnWKHlio/8G9HPAHDk7Ck1KttNSw4Y7hogncspmkAk5Dz377yeVlv62VfE6lMjWcy5G+4lCpQxdi2nioUnvwBXsPS34REHj1V0LEPf0brWXzWjqhPiMVJ4HfEoJ/NAKf4wCn2ikPIAzEW9bq0X5tq5bH0RarelAyIBq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755019330; c=relaxed/simple; bh=R2TiB1H9am4ZuJpz1fMyadvItK5KVaKH0hEND1XCnsk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uiw7PYciT0/m8J22dwbpvhbxiNE78M9wLfKkB3dgzPb9+IdMYYAXorVUscCl+H78KHmrAHUOAUvVW3f6xz21AsDMBMD9tYoBnuaAqu8atEAvczNBCQS8Y8d5YUN5sW3+dXWmq4u78GHdDOfYgGh3Ly/x3HixRCsUqRE1ovB3F4o= 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=jcX6D00F; 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="jcX6D00F" Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-7e841c71aa3so340239085a.2; Tue, 12 Aug 2025 10:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755019328; x=1755624128; 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=IEUVJaHvM44bvPB8en9gf1PVf9ZiWlysLR/X0mgOrR0=; b=jcX6D00FReRSQPLXfbM+u/aH6RqnJjwYwSYByX5JeUxZ7ejSwi0s49Ud9gnO4S36ng 7bUYEVWcBIGdeLgXrCU5L1mcXPBZDe4MnF4Y8GLu2+pJA8BU5eGFRkrVk5WCAyUOkSdF 3njBwLN0alBwC38ta9Dc3ik68t9zdeNMZTQmSBLiG/mT2hpPJgXU6/ETuLtDFbQMMSt9 +2fCdTFT8fPscK32aA7qirrCZrwm+h5oH7P6fbx8UQp9HmocjjJLKTvEX40g84jUsvPB UHwIqjrXWI+kK8+zyW6K8WKAywEQjSogT5yB4MY9RZQ25vy1CKqEwHcjVCWwhwWF39gc EO1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755019328; x=1755624128; 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=IEUVJaHvM44bvPB8en9gf1PVf9ZiWlysLR/X0mgOrR0=; b=sldwM1wXmeijlb2q2l8stfR0I+YR8cT1yXbsR8O62dt27/fkZI1N/tu+wiXDvAE1CL GzohSyp4CIuWW5yPGM/9wTplN+OknUlmwALnUvXM5Sjf6GEYld8Lbs2lbb7Ov/ydFToE 0rgXVqqPNMINjCVzOy7C3/8Y8gLZhVxN015y2YN+Fhk815bPpTGGrAh9AkuLmRb/qWX0 qa/COLaZ32zDKNndpMnGOUqfvs7kg24i8f/0R01Ji0iVXv7/Op0K5Sn5fy7HEyoXc9hS 5TvHRk9eyB+xO0sSJ1HZRLXXaz6O0UqFh/UmE0+rtdYl9QLIrDg/UBXj/BrgbZr6EUtP XQfw== X-Forwarded-Encrypted: i=1; AJvYcCUAVS4nujwZRJczxuXlvVvXLPkZzHYFE7HLjxs6bEgxax5mkLsyLp9JvcJ8sHOzNGnyW2cIWU6tY7rluy6hfbdgXKVX@vger.kernel.org, AJvYcCVHQqZ1sP18YF8pZJScrv6wNEITkxrZEJH+PPUSc78/WSMs1k6VVe9LOLh/yc4ZBeimz3QEN4SC0KQ=@vger.kernel.org, AJvYcCXsWreOUe4lG0227yCkGd4zKcYyoWwu9AR/oXPqWTijY4yPnhKbaldFNICDcO2FX8ZObBJ7kJPCvrG3Jp4o@vger.kernel.org X-Gm-Message-State: AOJu0Yy/YVnOmlvpe+hLa0iQcKtj1Q7tDl5+jLIR3ZK5m74dRCX9QKhv hl18FNiBZ7f8emPyxTxFp5CruMSphbZtZEBy7sm0FqDs3OEdrlySNp4y X-Gm-Gg: ASbGncskofbY3PuKbxCxu5Xst6h71kAonDuln7xgVVdHBkuMeXSqtMDRf98mPECHI3K 2EKRwO9oa8sk2YOvEbMbpbTyc3dJnTyH1oe0AVbZbaAU/ydlXYgb43xbBOTBMv1F+mtTSn58Yod T12bvysYI5KTITFsHHoAByAGtvUiKj9qYkBTlNxJG5PFgMjO89SUDq/1gJHIq7Vijct9gj3gC/k 3hlMx9E+9M6VOneCG2NnByLXWIOq8Iu5g9AqUBuNw+E/QjDxdXrl+Ys+uw7girKPr7u/j270NTJ h2aM9wtTjz674IsxmspKgu06ugSRdvDMNpNKVQK4pVnmRNyIRO7+UNZM/zeiM8I3SmQLsWo95Zx mPhlw0X6UnDSRejzGDrN9DzC72ud1M8z9/aOBqYvtnZ3+BfPDd4PcN4WfxN1OjQ5dIU0ZeC5Jo3 CAjthWFQFL+cxj X-Google-Smtp-Source: AGHT+IGvse4bfdU5DzZnHf9+yvgLrC++fKXcXrALaIaqHFG3dy0JHw8SIiQDSBDahRlCsazhY+Q1ZA== X-Received: by 2002:a05:620a:ac19:b0:7e6:9285:9909 with SMTP id af79cd13be357-7e864593126mr58553485a.35.1755019328058; Tue, 12 Aug 2025 10:22:08 -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-7e82a1ccbfesm863457285a.51.2025.08.12.10.22.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Aug 2025 10:22:07 -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 v2 3/3] rtla: fix -a overriding -t argument Date: Tue, 12 Aug 2025 13:21:11 -0400 Message-ID: <96f305f622de233c28d4ed9f23583b4d6ab2d1ac.1755018581.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" 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. Remove clear_terminal in timerlat top as it removes "Saving trace to " line from the terminal and is not used in other modes. 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 | 20 +++++--------------- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src= /osnoise_hist.c index 298640d92434..53655bccbbad 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': @@ -640,10 +641,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 70924242bcdd..db61a0c970e9 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': @@ -470,10 +471,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 2a48a076d941..123b7f89f80a 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': @@ -972,10 +973,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 e45d9978744c..4d7c3d74ac50 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); @@ -625,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': @@ -729,10 +718,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