Skip to content

Commit bd26818

Browse files
furkanonderrostedt
authored andcommitted
tools/rtla: Enhance argument parsing in timerlat_load.py
The enhancements made to timerlat_load.py are aimed at improving the clarity 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" <jkacur@redhat.com> Cc: "lgoncalv@redhat.com" <lgoncalv@redhat.com> Link: https://lore.kernel.org/QfgO7ayKD9dsLk8_ZDebkAV0OF7wla7UmasbP9CBmui_sChOeizy512t3RqCHTjvQoUBUDP8dwEOVCdHQ5KvVNEiP69CynMY94SFDERWl94=@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>
1 parent fc5f5ae commit bd26818

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

tools/tracing/rtla/sample/timerlat_load.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@
2525
import os
2626

2727
parser = argparse.ArgumentParser(description='user-space timerlat thread in Python')
28-
parser.add_argument("cpu", help='CPU to run timerlat thread')
29-
parser.add_argument("-p", "--prio", help='FIFO priority')
30-
28+
parser.add_argument("cpu", type=int, help='CPU to run timerlat thread')
29+
parser.add_argument("-p", "--prio", type=int, help='FIFO priority')
3130
args = parser.parse_args()
3231

3332
try:
34-
affinity_mask = { int(args.cpu) }
33+
affinity_mask = {args.cpu}
3534
except:
3635
print("Invalid cpu: " + args.cpu)
3736
exit(1)
@@ -44,7 +43,7 @@
4443

4544
if args.prio:
4645
try:
47-
param = os.sched_param(int(args.prio))
46+
param = os.sched_param(args.prio)
4847
os.sched_setscheduler(0, os.SCHED_FIFO, param)
4948
except:
5049
print("Error setting priority")

0 commit comments

Comments
 (0)