-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathswitch_features.py
More file actions
executable file
·49 lines (41 loc) · 1.16 KB
/
switch_features.py
File metadata and controls
executable file
·49 lines (41 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#! /usr/bin/python
import argparse
examples = """examples
"""
parser = argparse.ArgumentParser(
description="Toggle sched_feat",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=examples)
parser.add_argument("-i", "--index", default=-1, help="toggle based on index")
args = parser.parse_args()
def read_parse_schedfeat():
fd = open("/sys/kernel/debug/sched_features","r")
p = fd.read()
fd.close()
return p
def show_menu(l):
l = l.split(" ")
counter = 0
for i in l:
features_var = i
print (counter, features_var)
counter += 1
def toggle(index, l):
fd = open("/sys/kernel/debug/sched_features","w")
features_var = l.split(" ")[index]
features_var = features_var.split("NO_")
isno = not (features_var[-1] == features_var[0])
if isno:
fd.write(features_var[-1])
print("Turned on ", features_var[-1])
else:
fd.write("NO_"+features_var[-1])
print("Turned off ",features_var[-1])
fd.close()
# Read sched features parsed from above
p = read_parse_schedfeat()
if args.index >= 0:
toggle(int(args.index), p)
else:
show_menu(p)
toggle(int(raw_input()), p)