Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
compctl-kam
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
compctl-kam
Commits
74792bf3
Commit
74792bf3
authored
13 years ago
by
Petr Baudis
Browse files
Options
Downloads
Patches
Plain Diff
cgroup_set_mem_limit(): Fix increasing the memory limit
parent
7ad86fb9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cgroup.c
+21
-9
21 additions, 9 deletions
cgroup.c
with
21 additions
and
9 deletions
cgroup.c
+
21
−
9
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
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment