Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ophélie Gagnard
slapos.core
Commits
f5bb4ee0
Commit
f5bb4ee0
authored
Jun 09, 2017
by
Tomáš Peterka
Committed by
Rafael Monnerat
Jun 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[format] Switch exclusive CPU to 'realtime' performant mode
parent
02b9607e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
3 deletions
+20
-3
slapos/format.py
slapos/format.py
+20
-3
No files found.
slapos/format.py
View file @
f5bb4ee0
...
@@ -263,7 +263,7 @@ class CGroupManager(Manager):
...
@@ -263,7 +263,7 @@ class CGroupManager(Manager):
short_name
=
'cgroup'
short_name
=
'cgroup'
cpu_exclusive_file
=
".slapos-cpu-exclusive"
cpu_exclusive_file
=
".slapos-cpu-exclusive"
cpuset_path
=
"/sys/fs/cgroup/cpuset/"
cpuset_path
=
"/sys/fs/cgroup/cpuset/"
task_write_mode
=
"
a
t"
task_write_mode
=
"
w
t"
def
__init__
(
self
,
computer
):
def
__init__
(
self
,
computer
):
"""Extract necessary information from the ``computer``.
"""Extract necessary information from the ``computer``.
...
@@ -403,10 +403,27 @@ class CGroupManager(Manager):
...
@@ -403,10 +403,27 @@ class CGroupManager(Manager):
return
self
.
_move_task
(
pid
,
exclusive_cpu
)[
1
]
return
self
.
_move_task
(
pid
,
exclusive_cpu
)[
1
]
return
-
1
return
-
1
def
_move_task
(
self
,
pid
,
cpu_id
):
def
_move_task
(
self
,
pid
,
cpu_id
,
cpu_mode
=
"performance"
):
"""Move ``pid`` to ``cpu_id``."""
"""Move ``pid`` to ``cpu_id``.
cpu_mode can be "performance" or "powersave"
"""
known_cpu_mode_list
=
(
"performance"
,
"powersave"
)
with
open
(
os
.
path
.
join
(
self
.
cpuset_path
,
"cpu"
+
str
(
cpu_id
),
"tasks"
),
self
.
task_write_mode
)
as
fo
:
with
open
(
os
.
path
.
join
(
self
.
cpuset_path
,
"cpu"
+
str
(
cpu_id
),
"tasks"
),
self
.
task_write_mode
)
as
fo
:
fo
.
write
(
str
(
pid
)
+
"
\
n
"
)
fo
.
write
(
str
(
pid
)
+
"
\
n
"
)
# set the core to `cpu_mode`
scaling_governor_file
=
"/sys/devices/system/cpu/cpu{:d}/cpufreq/scaling_governor"
.
format
(
cpu_id
)
if
os
.
path
.
exists
(
scaling_governor_file
):
if
cpu_mode
not
in
known_cpu_mode_list
:
logger
.
warning
(
"Cannot set CPU to mode
\
"
{}
\
"
! Known modes {!s}"
.
format
(
cpu_mode
,
known_cpu_mode_list
))
else
:
try
:
with
open
(
scaling_governor_file
,
self
.
task_write_mode
)
as
fo
:
fo
.
write
(
cpu_mode
+
"
\
n
"
)
# default is "powersave"
except
IOError
as
e
:
# handle permission error
logger
.
error
(
"Failed to write
\
"
{}
\
"
to {}"
.
format
(
cpu_mode
,
scaling_governor_file
))
return
pid
,
cpu_id
return
pid
,
cpu_id
def
_prepare_folder
(
self
,
folder
):
def
_prepare_folder
(
self
,
folder
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment