Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
59ac3b88
Unverified
Commit
59ac3b88
authored
Feb 17, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgfsng: cg_legacy_filter_and_set_cpus()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
333987b9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
23 deletions
+23
-23
cgfsng.c
src/lxc/cgroups/cgfsng.c
+23
-23
No files found.
src/lxc/cgroups/cgfsng.c
View file @
59ac3b88
...
@@ -510,18 +510,17 @@ static ssize_t get_max_cpus(char *cpulist)
...
@@ -510,18 +510,17 @@ static ssize_t get_max_cpus(char *cpulist)
#define __ISOL_CPUS "/sys/devices/system/cpu/isolated"
#define __ISOL_CPUS "/sys/devices/system/cpu/isolated"
static
bool
cg_legacy_filter_and_set_cpus
(
char
*
path
,
bool
am_initialized
)
static
bool
cg_legacy_filter_and_set_cpus
(
char
*
path
,
bool
am_initialized
)
{
{
char
*
lastslash
,
*
fpath
,
oldv
;
int
ret
;
int
ret
;
ssize_t
i
;
ssize_t
i
;
char
*
lastslash
,
*
fpath
,
oldv
;
ssize_t
max
poss
=
0
,
maxisol
=
0
;
ssize_t
max
isol
=
0
,
maxposs
=
0
;
char
*
cpulist
=
NULL
,
*
posscpus
=
NULL
,
*
isol
cpus
=
NULL
;
char
*
cpulist
=
NULL
,
*
isolcpus
=
NULL
,
*
poss
cpus
=
NULL
;
uint32_t
*
possmask
=
NULL
,
*
isol
mask
=
NULL
;
uint32_t
*
isolmask
=
NULL
,
*
poss
mask
=
NULL
;
bool
bret
=
false
,
flipped_bit
=
false
;
bool
bret
=
false
,
flipped_bit
=
false
;
lastslash
=
strrchr
(
path
,
'/'
);
lastslash
=
strrchr
(
path
,
'/'
);
if
(
!
lastslash
)
{
/* bug... this shouldn't be possible */
if
(
!
lastslash
)
{
ERROR
(
"
Invalid path: %s.
"
,
path
);
ERROR
(
"
Failed to detect
\"
/
\"
in
\"
%s
\"
"
,
path
);
return
bret
;
return
bret
;
}
}
oldv
=
*
lastslash
;
oldv
=
*
lastslash
;
...
@@ -529,7 +528,7 @@ static bool cg_legacy_filter_and_set_cpus(char *path, bool am_initialized)
...
@@ -529,7 +528,7 @@ static bool cg_legacy_filter_and_set_cpus(char *path, bool am_initialized)
fpath
=
must_make_path
(
path
,
"cpuset.cpus"
,
NULL
);
fpath
=
must_make_path
(
path
,
"cpuset.cpus"
,
NULL
);
posscpus
=
read_file
(
fpath
);
posscpus
=
read_file
(
fpath
);
if
(
!
posscpus
)
{
if
(
!
posscpus
)
{
SYSERROR
(
"
Could not read file: %s.
\n
"
,
fpath
);
SYSERROR
(
"
Failed to read file
\"
%s
\"
"
,
fpath
);
goto
on_error
;
goto
on_error
;
}
}
...
@@ -540,14 +539,14 @@ static bool cg_legacy_filter_and_set_cpus(char *path, bool am_initialized)
...
@@ -540,14 +539,14 @@ static bool cg_legacy_filter_and_set_cpus(char *path, bool am_initialized)
if
(
!
file_exists
(
__ISOL_CPUS
))
{
if
(
!
file_exists
(
__ISOL_CPUS
))
{
/* This system doesn't expose isolated cpus. */
/* This system doesn't expose isolated cpus. */
DEBUG
(
"
Path: "
__ISOL_CPUS
" to read isolated cpus from does not exist.
\n
"
);
DEBUG
(
"
The path
\"
"
__ISOL_CPUS
"
\"
to read isolated cpus from does not exist
"
);
cpulist
=
posscpus
;
cpulist
=
posscpus
;
/* No isolated cpus but we weren't already initialized by
/* No isolated cpus but we weren't already initialized by
* someone. We should simply copy the parents cpuset.cpus
* someone. We should simply copy the parents cpuset.cpus
* values.
* values.
*/
*/
if
(
!
am_initialized
)
{
if
(
!
am_initialized
)
{
DEBUG
(
"Copying cpu
set of parent cgroup.
"
);
DEBUG
(
"Copying cpu
settings of parent cgroup
"
);
goto
copy_parent
;
goto
copy_parent
;
}
}
/* No isolated cpus but we were already initialized by someone.
/* No isolated cpus but we were already initialized by someone.
...
@@ -558,18 +557,18 @@ static bool cg_legacy_filter_and_set_cpus(char *path, bool am_initialized)
...
@@ -558,18 +557,18 @@ static bool cg_legacy_filter_and_set_cpus(char *path, bool am_initialized)
isolcpus
=
read_file
(
__ISOL_CPUS
);
isolcpus
=
read_file
(
__ISOL_CPUS
);
if
(
!
isolcpus
)
{
if
(
!
isolcpus
)
{
SYSERROR
(
"
Could not read file "
__ISOL_CPUS
);
SYSERROR
(
"
Failed to read file
\"
"
__ISOL_CPUS
"
\"
"
);
goto
on_error
;
goto
on_error
;
}
}
if
(
!
isdigit
(
isolcpus
[
0
]))
{
if
(
!
isdigit
(
isolcpus
[
0
]))
{
DEBUG
(
"No isolated cpus detected.
"
);
TRACE
(
"No isolated cpus detected
"
);
cpulist
=
posscpus
;
cpulist
=
posscpus
;
/* No isolated cpus but we weren't already initialized by
/* No isolated cpus but we weren't already initialized by
* someone. We should simply copy the parents cpuset.cpus
* someone. We should simply copy the parents cpuset.cpus
* values.
* values.
*/
*/
if
(
!
am_initialized
)
{
if
(
!
am_initialized
)
{
DEBUG
(
"Copying cpu
set of parent cgroup.
"
);
DEBUG
(
"Copying cpu
settings of parent cgroup
"
);
goto
copy_parent
;
goto
copy_parent
;
}
}
/* No isolated cpus but we were already initialized by someone.
/* No isolated cpus but we were already initialized by someone.
...
@@ -589,32 +588,33 @@ static bool cg_legacy_filter_and_set_cpus(char *path, bool am_initialized)
...
@@ -589,32 +588,33 @@ static bool cg_legacy_filter_and_set_cpus(char *path, bool am_initialized)
possmask
=
lxc_cpumask
(
posscpus
,
maxposs
);
possmask
=
lxc_cpumask
(
posscpus
,
maxposs
);
if
(
!
possmask
)
{
if
(
!
possmask
)
{
ERROR
(
"
Could not create cpumask for all possible cpus.
\n
"
);
ERROR
(
"
Failed to create cpumask for possible cpus
"
);
goto
on_error
;
goto
on_error
;
}
}
isolmask
=
lxc_cpumask
(
isolcpus
,
maxposs
);
isolmask
=
lxc_cpumask
(
isolcpus
,
maxposs
);
if
(
!
isolmask
)
{
if
(
!
isolmask
)
{
ERROR
(
"
Could not create cpumask for all isolated cpus.
\n
"
);
ERROR
(
"
Failed to create cpumask for isolated cpus
"
);
goto
on_error
;
goto
on_error
;
}
}
for
(
i
=
0
;
i
<=
maxposs
;
i
++
)
{
for
(
i
=
0
;
i
<=
maxposs
;
i
++
)
{
if
(
is_set
(
i
,
isolmask
)
&&
is_set
(
i
,
possmask
))
{
if
(
!
is_set
(
i
,
isolmask
)
||
!
is_set
(
i
,
possmask
))
flipped_bit
=
true
;
continue
;
clear_bit
(
i
,
possmask
);
}
flipped_bit
=
true
;
clear_bit
(
i
,
possmask
);
}
}
if
(
!
flipped_bit
)
{
if
(
!
flipped_bit
)
{
DEBUG
(
"No isolated cpus present in cpuset
.
"
);
DEBUG
(
"No isolated cpus present in cpuset"
);
goto
on_success
;
goto
on_success
;
}
}
DEBUG
(
"Removed isolated cpus from cpuset
.
"
);
DEBUG
(
"Removed isolated cpus from cpuset"
);
cpulist
=
lxc_cpumask_to_cpulist
(
possmask
,
maxposs
);
cpulist
=
lxc_cpumask_to_cpulist
(
possmask
,
maxposs
);
if
(
!
cpulist
)
{
if
(
!
cpulist
)
{
ERROR
(
"
Could not create cpu list.
\n
"
);
ERROR
(
"
Failed to create cpu list
"
);
goto
on_error
;
goto
on_error
;
}
}
...
@@ -624,7 +624,7 @@ copy_parent:
...
@@ -624,7 +624,7 @@ copy_parent:
fpath
=
must_make_path
(
path
,
"cpuset.cpus"
,
NULL
);
fpath
=
must_make_path
(
path
,
"cpuset.cpus"
,
NULL
);
ret
=
lxc_write_to_file
(
fpath
,
cpulist
,
strlen
(
cpulist
),
false
);
ret
=
lxc_write_to_file
(
fpath
,
cpulist
,
strlen
(
cpulist
),
false
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
SYSERROR
(
"
Could not write cpu list to: %s.
\n
"
,
fpath
);
SYSERROR
(
"
Failed to write cpu list to
\"
%s
\"
"
,
fpath
);
goto
on_error
;
goto
on_error
;
}
}
...
...
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