From nobody Sun Nov 24 02:54:45 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 467811E5015 for ; Mon, 18 Nov 2024 20:14:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731960867; cv=none; b=NfkLob5t0D4182E71IqOj/35F0pq54BZPdyNbvkOl0zk276DPukFaQoueEwMKt2cYHLbrrN02b2f1IGEFNdaTU8IkiNDIwzJRsKydDevDJEfgMNwclrQWIl0+6zzCXbfku/BdOSJkclmrLfxWciaZW80zfnn5JrWqOCWTSyhg9w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731960867; c=relaxed/simple; bh=MVdApGcyUkptaqX7YZykKxm5OO/+NabO5+9iyVWfb5o=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=J36MZy1D6uQYx6pxDOJgbdv4NYK03YLfcV/15FbdZN5qKc+v06I/7Plzxd8KoESIgC4mZCOU3DmyQY5gPptLpbOG6MVJs+LdTy9MnkxUO09f4CDK55Zpbs+NsYrT612/yUpLRw+1EWUNdcxqGFJquC7pw/0TG17HvUmp81jj4KU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0F39C4CECC; Mon, 18 Nov 2024 20:14:26 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1tD89D-0000000D8x8-0RhF; Mon, 18 Nov 2024 15:14:59 -0500 Message-ID: <20241118201458.954141338@goodmis.org> User-Agent: quilt/0.68 Date: Mon, 18 Nov 2024 15:14:32 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Tomas Glozar , John Kacur Subject: [for-next][PATCH 1/4] rtla/timerlat: Do not set params->user_workload with -U References: <20241118201431.871648641@goodmis.org> 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" From: Tomas Glozar Since commit fb9e90a67ee9 ("rtla/timerlat: Make user-space threads the default"), rtla-timerlat has been defaulting to params->user_workload if neither that or params->kernel_workload is set. This has unintentionally made -U, which sets only params->user_hist/top but not params->user_workload, to behave like -u unless -k is set, preventing the user from running a custom workload. Example: $ rtla timerlat hist -U -c 0 & [1] 7413 $ python sample/timerlat_load.py 0 Error opening timerlat fd, did you run timerlat -U? $ ps | grep timerlatu 7415 pts/4 00:00:00 timerlatu/0 Fix the issue by checking for params->user_top/hist instead of params->user_workload when setting default thread mode. Link: https://lore.kernel.org/20241021123140.14652-1-tglozar@redhat.com Fixes: fb9e90a67ee9 ("rtla/timerlat: Make user-space threads the default") Signed-off-by: Tomas Glozar Signed-off-by: Steven Rostedt (Google) --- tools/tracing/rtla/src/timerlat_hist.c | 2 +- tools/tracing/rtla/src/timerlat_top.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/sr= c/timerlat_hist.c index 01dd337da13a..8b66387e5f35 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -1073,7 +1073,7 @@ timerlat_hist_apply_config(struct osnoise_tool *tool,= struct timerlat_hist_param * If the user did not specify a type of thread, try user-threads first. * Fall back to kernel threads otherwise. */ - if (!params->kernel_workload && !params->user_workload) { + if (!params->kernel_workload && !params->user_hist) { retval =3D tracefs_file_exists(NULL, "osnoise/per_cpu/cpu0/timerlat_fd"); if (retval) { debug_msg("User-space interface detected, setting user-threads\n"); diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index fca0da3caa87..f7422948205d 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -839,7 +839,7 @@ timerlat_top_apply_config(struct osnoise_tool *top, str= uct timerlat_top_params * * If the user did not specify a type of thread, try user-threads first. * Fall back to kernel threads otherwise. */ - if (!params->kernel_workload && !params->user_workload) { + if (!params->kernel_workload && !params->user_top) { retval =3D tracefs_file_exists(NULL, "osnoise/per_cpu/cpu0/timerlat_fd"); if (retval) { debug_msg("User-space interface detected, setting user-threads\n"); --=20 2.45.2 From nobody Sun Nov 24 02:54:45 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7A9391E5734 for ; Mon, 18 Nov 2024 20:14:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731960867; cv=none; b=WkNNWFPJKi5Qz7SzMDXJFJe5E1ldYAuXQ+UQyLp+3VNhafSwaUUeFsU8pA8blrYamsi4oIuSZRTlLBTTnk0yDgV+izgw7N9cKxWYUg0OciwJeTExVvSLQwC1hFSvg8zLm0PMD+Mn8AuCJg6uTOJ3mUX62XN0wZ5k09XI+mXzhLA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731960867; c=relaxed/simple; bh=9vh/n3TLJf6SPuh2A+56vcj5XMn/yl800FwblNP07pY=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=EJJIVknqomD9LbihD8FsjIaMCpSDacriY7/HM5s9sDfiQfa01eYVLdfbIGFCPZd4cLN10701WxDePfYKBJSW0SwPNlN2bQkWgZPxEMOhwyiv4zIlUSaemp3g3IJZfn0xp8HUR3WknktlNlpcBo5nkVu9oaUyIoE1bc/3Gr2cI1I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 381AAC4CED6; Mon, 18 Nov 2024 20:14:27 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1tD89D-0000000D8xe-19mI; Mon, 18 Nov 2024 15:14:59 -0500 Message-ID: <20241118201459.127808078@goodmis.org> User-Agent: quilt/0.68 Date: Mon, 18 Nov 2024 15:14:33 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Tomas Glozar , John Kacur , "lgoncalv@redhat.com" , Furkan Onder Subject: [for-next][PATCH 2/4] tools/rtla: Improve code readability in timerlat_load.py References: <20241118201431.871648641@goodmis.org> 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" From: furkanonder The enhancements made to timerlat_load.py are intended to improve the script's robustness and readability. Summary of the changes: - Unnecessary semicolons at the end of lines have been removed. - Parentheses surrounding the if statement checking args.prio have been eliminated. - String concatenation for constructing timerlat_path has been replaced with an f-string. - Spacing in a multiplication expression has been adjusted for improved clarity. Cc: "jkacur@redhat.com" Cc: "lgoncalv@redhat.com" Link: https://lore.kernel.org/j2B-ted7pv3TaldTyqfIHrMmjq2fVyBFgnu3TskiQJsyR= zy9loPTVVJoqHnrCWu5T88MDIFc612jUglH6Sxkdg9LN-I1XuITmoL70uECmus=3D@protonmai= l.com Signed-off-by: Furkan Onder Reviewed-by: Tomas Glozar Signed-off-by: Steven Rostedt (Google) --- tools/tracing/rtla/sample/timerlat_load.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/tracing/rtla/sample/timerlat_load.py b/tools/tracing/rtl= a/sample/timerlat_load.py index 8cc5eb2d2e69..785e9a83539a 100644 --- a/tools/tracing/rtla/sample/timerlat_load.py +++ b/tools/tracing/rtla/sample/timerlat_load.py @@ -37,12 +37,12 @@ except: exit(1) =20 try: - os.sched_setaffinity(0, affinity_mask); + os.sched_setaffinity(0, affinity_mask) except: print("Error setting affinity") exit(1) =20 -if (args.prio): +if args.prio: try: param =3D os.sched_param(int(args.prio)) os.sched_setscheduler(0, os.SCHED_FIFO, param) @@ -51,21 +51,21 @@ if (args.prio): exit(1) =20 try: - timerlat_path =3D "/sys/kernel/tracing/osnoise/per_cpu/cpu" + args.cpu= + "/timerlat_fd" + timerlat_path =3D f"/sys/kernel/tracing/osnoise/per_cpu/cpu{args.cpu}/= timerlat_fd" timerlat_fd =3D open(timerlat_path, 'r') except: print("Error opening timerlat fd, did you run timerlat -U?") exit(1) =20 try: - data_fd =3D open("/dev/full", 'r'); + data_fd =3D open("/dev/full", 'r') except: print("Error opening data fd") =20 while True: try: timerlat_fd.read(1) - data_fd.read(20*1024*1024) + data_fd.read(20 * 1024 * 1024) except: print("Leaving") break --=20 2.45.2 From nobody Sun Nov 24 02:54:45 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7A8C41E5732 for ; Mon, 18 Nov 2024 20:14:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731960867; cv=none; b=MQab1JeGRTEfWeZTr9LWn27MHQ/foHmV65a91rhvwWDXy21QptWFs5vsbhdbiNJ5RNfMpXoPBwnhnW+eDFmxbPaflUdFttKKWinZg1n1epDy7aHZ3/pNzm+rSH6Vpw1lUA89pldViib2wptt6U9QX59dow30/i7uS+v1Y4txiaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731960867; c=relaxed/simple; bh=EFXGenEvq+97XtCagTbKXm70xIu/0FQ5mQXGq+OYBUs=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=auV7VRcw94HIDs509Ghl3yX0NdvwwEhz6MP8t1wWRv1miJUi/HPWkT3eB3kMaX/akJQx4orf8iT85dTtUtG+6/8l3zfA8qD5gFcpTAXe4IkelzUyc9bCg+2SU6oHcz+3mDpezjkDooIDb0Tn9Nz6JuvTBikHOijL9SBVt/yhA2w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47874C4CED8; Mon, 18 Nov 2024 20:14:27 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1tD89D-0000000D8y9-1rag; Mon, 18 Nov 2024 15:14:59 -0500 Message-ID: <20241118201459.296411856@goodmis.org> User-Agent: quilt/0.68 Date: Mon, 18 Nov 2024 15:14:34 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Tomas Glozar , John Kacur , "lgoncalv@redhat.com" , Furkan Onder Subject: [for-next][PATCH 3/4] tools/rtla: Enhance argument parsing in timerlat_load.py References: <20241118201431.871648641@goodmis.org> 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" From: furkanonder The enhancements made to timerlat_load.py are aimed at improving the clarit= y of argument parsing. Summary of Changes: - The cpu argument is now specified as an integer type in the argument parser to enforce input validation, and the construction of affinity_mask has been simplified to directly use the integer value of args.cpu. - The prio argument is similarly updated to be of integer type for consistency and validation, eliminating the need for the conversion of args.prio to an integer, as this is now handled by the argument parser. Cc: "jkacur@redhat.com" Cc: "lgoncalv@redhat.com" Link: https://lore.kernel.org/QfgO7ayKD9dsLk8_ZDebkAV0OF7wla7UmasbP9CBmui_s= ChOeizy512t3RqCHTjvQoUBUDP8dwEOVCdHQ5KvVNEiP69CynMY94SFDERWl94=3D@protonmai= l.com Signed-off-by: Furkan Onder Reviewed-by: Tomas Glozar Signed-off-by: Steven Rostedt (Google) --- tools/tracing/rtla/sample/timerlat_load.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/tracing/rtla/sample/timerlat_load.py b/tools/tracing/rtl= a/sample/timerlat_load.py index 785e9a83539a..d7341ed5127a 100644 --- a/tools/tracing/rtla/sample/timerlat_load.py +++ b/tools/tracing/rtla/sample/timerlat_load.py @@ -25,13 +25,12 @@ import sys import os =20 parser =3D argparse.ArgumentParser(description=3D'user-space timerlat thre= ad in Python') -parser.add_argument("cpu", help=3D'CPU to run timerlat thread') -parser.add_argument("-p", "--prio", help=3D'FIFO priority') - +parser.add_argument("cpu", type=3Dint, help=3D'CPU to run timerlat thread') +parser.add_argument("-p", "--prio", type=3Dint, help=3D'FIFO priority') args =3D parser.parse_args() =20 try: - affinity_mask =3D { int(args.cpu) } + affinity_mask =3D {args.cpu} except: print("Invalid cpu: " + args.cpu) exit(1) @@ -44,7 +43,7 @@ except: =20 if args.prio: try: - param =3D os.sched_param(int(args.prio)) + param =3D os.sched_param(args.prio) os.sched_setscheduler(0, os.SCHED_FIFO, param) except: print("Error setting priority") --=20 2.45.2 From nobody Sun Nov 24 02:54:45 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C35A91E6DD4 for ; Mon, 18 Nov 2024 20:14:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731960867; cv=none; b=aY6boxqiJx+IxSL5uL2gVqvHZ4cIfs9hp8Re75EcEdhE1cb9sherSbzOjfMEmWWi6dEJfRDqcNIUIxS0156UqnmOSgAsapL3LQk4dE5XocxU/fNE3RFjZY36R33iAl6+2xKwjfgyG9/wKJR3ObA02g2LzZ6RbZqwowKZeUzadpk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731960867; c=relaxed/simple; bh=1bsicQsClz2mA5LGmCCz633UWz8AMxCoyQFRdHoj6LQ=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=qMpWwcpcWoWmiB0f306g0aj3BZgGkKZsCG88FmGJG1s1WA6fZg2SdLclvELfD2YYZ9JABucX0ohaMRaV7PEnYJiARXA+O+MUjShqHUjgxg/xPLYGgioJ8ELCN0pvyjM+5S/TT6a90/2Kig8doGtyOWwreIE7Z/9dcgT4BdRjKjk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71469C4CECC; Mon, 18 Nov 2024 20:14:27 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1tD89D-0000000D8ye-2a8H; Mon, 18 Nov 2024 15:14:59 -0500 Message-ID: <20241118201459.464858475@goodmis.org> User-Agent: quilt/0.68 Date: Mon, 18 Nov 2024 15:14:35 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Tomas Glozar , John Kacur , "lgoncalv@redhat.com" , Furkan Onder Subject: [for-next][PATCH 4/4] tools/rtla: Improve exception handling in timerlat_load.py References: <20241118201431.871648641@goodmis.org> 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" From: furkanonder The enhancements made to timerlat_load.py are intended to improve the scrip= t's exception handling. Summary of the changes: - Specific exceptions are now caught for CPU affinity and priority settings, with clearer error messages provided. - The timerlat file descriptor opening now includes handling for PermissionError and OSError, with informative messages. - In the infinite loop, generic exceptions have been replaced with specific types like KeyboardInterrupt and IOError, improving feedback. Before: $ sudo python timerlat_load.py 122 Error setting affinity After: $ sudo python timerlat_load.py 122 Error setting affinity: [Errno 22] Invalid argument Before: $ sudo python timerlat_load.py 1 -p 950 Error setting priority After: $ sudo python timerlat_load.py 1 -p 950 Error setting priority: [Errno 22] Invalid argument Before: $ python timerlat_load.py 1 Error opening timerlat fd, did you run timerlat -U? After: $ python timerlat_load.py 1 Permission denied. Please check your access rights. Cc: "lgoncalv@redhat.com" Cc: "jkacur@redhat.com" Link: https://lore.kernel.org/Q_k1s4hBtUy2px8ou0QKenjEK2_T_LoV8IxAE79aBakBo= gb-7uHp2fpET3oWtI1t3dy8uKjWeRzQOdKNzIzOOpyM4OjutJOriZ9TrGY6b-g=3D@protonmai= l.com Signed-off-by: Furkan Onder Reviewed-by: Tomas Glozar Signed-off-by: Steven Rostedt (Google) --- tools/tracing/rtla/sample/timerlat_load.py | 37 ++++++++++++---------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/tools/tracing/rtla/sample/timerlat_load.py b/tools/tracing/rtl= a/sample/timerlat_load.py index d7341ed5127a..a819c3588073 100644 --- a/tools/tracing/rtla/sample/timerlat_load.py +++ b/tools/tracing/rtla/sample/timerlat_load.py @@ -31,43 +31,48 @@ args =3D parser.parse_args() =20 try: affinity_mask =3D {args.cpu} -except: - print("Invalid cpu: " + args.cpu) - exit(1) - -try: os.sched_setaffinity(0, affinity_mask) -except: - print("Error setting affinity") - exit(1) +except Exception as e: + print(f"Error setting affinity: {e}") + sys.exit(1) =20 if args.prio: try: param =3D os.sched_param(args.prio) os.sched_setscheduler(0, os.SCHED_FIFO, param) - except: - print("Error setting priority") - exit(1) + except Exception as e: + print(f"Error setting priority: {e}") + sys.exit(1) =20 try: timerlat_path =3D f"/sys/kernel/tracing/osnoise/per_cpu/cpu{args.cpu}/= timerlat_fd" timerlat_fd =3D open(timerlat_path, 'r') -except: +except PermissionError: + print("Permission denied. Please check your access rights.") + sys.exit(1) +except OSError: print("Error opening timerlat fd, did you run timerlat -U?") - exit(1) + sys.exit(1) =20 try: data_fd =3D open("/dev/full", 'r') -except: - print("Error opening data fd") +except Exception as e: + print(f"Error opening data fd: {e}") + sys.exit(1) =20 while True: try: timerlat_fd.read(1) data_fd.read(20 * 1024 * 1024) - except: + except KeyboardInterrupt: print("Leaving") break + except IOError as e: + print(f"I/O error occurred: {e}") + break + except Exception as e: + print(f"Unexpected error: {e}") + break =20 timerlat_fd.close() data_fd.close() --=20 2.45.2