Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Martin Mareš
compctl-kam
Commits
74792bf3
Commit
74792bf3
authored
Mar 16, 2012
by
Petr Baudis
Browse files
cgroup_set_mem_limit(): Fix increasing the memory limit
parent
7ad86fb9
Changes
1
Hide whitespace changes
Inline
Side-by-side
cgroup.c
View file @
74792bf3
...
...
@@ -141,7 +141,7 @@ cgroup_get_mem_limit(const char *chier, const char *cgroup)
return
nlimit
;
}
int
static
int
cgroup_set_mem_limit_do
(
const
char
*
chier
,
const
char
*
cgroup
,
size_t
nlimit
,
char
*
memsw
)
{
char
limitfile
[
PATH_MAX
];
...
...
@@ -163,21 +163,33 @@ cgroup_set_mem_limit_do(const char *chier, const char *cgroup, size_t nlimit, ch
return
1
;
}
int
cgroup_set_mem_limit
(
const
char
*
chier
,
const
char
*
cgroup
,
size_t
nlimit
)
static
int
cgroup_set_mem_limit
_twice
(
const
char
*
chier
,
const
char
*
cgroup
,
size_t
nlimit
,
char
*
memsw1
,
char
*
memsw2
)
{
/* We need to set both the "normal" and memsw limits, normal first,
* since normal <= memsw must hold. */
int
ret
=
cgroup_set_mem_limit_do
(
chier
,
cgroup
,
nlimit
,
""
);
#if SWAP_LIMIT
int
ret
=
cgroup_set_mem_limit_do
(
chier
,
cgroup
,
nlimit
,
memsw1
);
if
(
ret
>=
0
)
{
int
ret2
=
cgroup_set_mem_limit_do
(
chier
,
cgroup
,
nlimit
,
MEMSW
);
int
ret2
=
cgroup_set_mem_limit_do
(
chier
,
cgroup
,
nlimit
,
memsw2
);
ret
=
ret2
<
0
?
ret2
:
(
ret
||
ret2
);
}
#endif
return
ret
;
}
int
cgroup_set_mem_limit
(
const
char
*
chier
,
const
char
*
cgroup
,
size_t
nlimit
)
{
#if SWAP_LIMIT
/* We need to set both the "normal" and memsw limits, but in such
* order that normal <= memsw always holds. */
size_t
curlimit
=
cgroup_get_mem_limit
(
chier
,
cgroup
);
if
(
nlimit
<
curlimit
)
return
cgroup_set_mem_limit_twice
(
chier
,
cgroup
,
nlimit
,
""
,
MEMSW
);
else
return
cgroup_set_mem_limit_twice
(
chier
,
cgroup
,
nlimit
,
MEMSW
,
""
);
#else
return
cgroup_set_mem_limit_do
(
chier
,
cgroup
,
nlimit
,
""
);
#endif
}
size_t
cgroup_get_mem_usage
(
const
char
*
chier
,
const
char
*
cgroup
)
{
...
...
Write
Preview
Supports
Markdown
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