tools/rtla: Improve code readability in timerlat_load.py

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" <jkacur@redhat.com>
Cc: "lgoncalv@redhat.com" <lgoncalv@redhat.com>
Link: https://lore.kernel.org/j2B-ted7pv3TaldTyqfIHrMmjq2fVyBFgnu3TskiQJsyRzy9loPTVVJoqHnrCWu5T88MDIFc612jUglH6Sxkdg9LN-I1XuITmoL70uECmus=@protonmail.com
Signed-off-by: Furkan Onder <furkanonder@protonmail.com>
Reviewed-by: Tomas Glozar <tglozar@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
furkanonder
2024-10-21 15:09:49 +00:00
committed by Steven Rostedt (Google)
parent fcbc60d7dc
commit fc5f5aef9f

View File

@@ -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