diff mbox series

[1/3] tools/rtla: Improve code readability in timerlat_load.py

Message ID j2B-ted7pv3TaldTyqfIHrMmjq2fVyBFgnu3TskiQJsyRzy9loPTVVJoqHnrCWu5T88MDIFc612jUglH6Sxkdg9LN-I1XuITmoL70uECmus=@protonmail.com (mailing list archive)
State Queued
Commit fda90b990eaf109c7b376b232bd553dde8bc07e1
Headers show
Series [1/3] tools/rtla: Improve code readability in timerlat_load.py | expand

Commit Message

furkanonder Oct. 21, 2024, 3:09 p.m. UTC
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.

Signed-off-by: Furkan Onder <furkanonder@protonmail.com>
---
 tools/tracing/rtla/sample/timerlat_load.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

--
2.46.2

Comments

Tomas Glozar Oct. 22, 2024, 8:28 a.m. UTC | #1
po 21. 10. 2024 v 17:10 odesílatel furkanonder
<furkanonder@protonmail.com> napsal:
>
> 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.
>
> Signed-off-by: Furkan Onder <furkanonder@protonmail.com>
> ---
>  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/rtla/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)
>
>  try:
> -    os.sched_setaffinity(0, affinity_mask);
> +    os.sched_setaffinity(0, affinity_mask)
>  except:
>      print("Error setting affinity")
>      exit(1)
>
> -if (args.prio):
> +if args.prio:
>      try:
>          param = os.sched_param(int(args.prio))
>          os.sched_setscheduler(0, os.SCHED_FIFO, param)
> @@ -51,21 +51,21 @@ if (args.prio):
>          exit(1)
>
>  try:
> -    timerlat_path = "/sys/kernel/tracing/osnoise/per_cpu/cpu" + args.cpu + "/timerlat_fd"
> +    timerlat_path = f"/sys/kernel/tracing/osnoise/per_cpu/cpu{args.cpu}/timerlat_fd"
>      timerlat_fd = open(timerlat_path, 'r')
>  except:
>      print("Error opening timerlat fd, did you run timerlat -U?")
>      exit(1)
>
>  try:
> -    data_fd = open("/dev/full", 'r');
> +    data_fd = open("/dev/full", 'r')
>  except:
>      print("Error opening data fd")
>
>  while True:
>      try:
>          timerlat_fd.read(1)
> -        data_fd.read(20*1024*1024)
> +        data_fd.read(20 * 1024 * 1024)
>      except:
>          print("Leaving")
>          break
> --
> 2.46.2
>

Reviewed-by: Tomas Glozar <tglozar@redhat.com>
Steven Rostedt Nov. 18, 2024, 7:34 p.m. UTC | #2
On Mon, 21 Oct 2024 15:09:49 +0000
furkanonder <furkanonder@protonmail.com> wrote:

> 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.
> 
> Signed-off-by: Furkan Onder <furkanonder@protonmail.com>

BTW, should tools/tracing/rtla/sample/timerlat_load.py be executable?

 chmod +x tools/tracing/rtla/sample/timerlat_load.py

?

If so, I can write a patch to update that.

-- Steve
diff mbox series

Patch

diff --git a/tools/tracing/rtla/sample/timerlat_load.py b/tools/tracing/rtla/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)

 try:
-    os.sched_setaffinity(0, affinity_mask);
+    os.sched_setaffinity(0, affinity_mask)
 except:
     print("Error setting affinity")
     exit(1)

-if (args.prio):
+if args.prio:
     try:
         param = os.sched_param(int(args.prio))
         os.sched_setscheduler(0, os.SCHED_FIFO, param)
@@ -51,21 +51,21 @@  if (args.prio):
         exit(1)

 try:
-    timerlat_path = "/sys/kernel/tracing/osnoise/per_cpu/cpu" + args.cpu + "/timerlat_fd"
+    timerlat_path = f"/sys/kernel/tracing/osnoise/per_cpu/cpu{args.cpu}/timerlat_fd"
     timerlat_fd = open(timerlat_path, 'r')
 except:
     print("Error opening timerlat fd, did you run timerlat -U?")
     exit(1)

 try:
-    data_fd = open("/dev/full", 'r');
+    data_fd = open("/dev/full", 'r')
 except:
     print("Error opening data fd")

 while True:
     try:
         timerlat_fd.read(1)
-        data_fd.read(20*1024*1024)
+        data_fd.read(20 * 1024 * 1024)
     except:
         print("Leaving")
         break