Browse files

core.lua: fix for cgroups removed outside ulatencyd (issue #28)

fixes issue #28: CGroup properties not set.

Whenever scheduler finds matching rule for scheduled process, it calls
CGroup.get_group(name) to check if cgroup does exist. This used to check
only if cgroup is contained in the internal _CGroup_Cache - not if it really
does exist in cgroup filesystem.

So if the cgroup was removed outside ulatencyd and therefore was not
removed from _CGroup_Cache, cgroup will not be recreated and will loose
all settings (default parameters, rule parameters, parameters adjusted
by adjust_new).

 + CGroup.get_group(): test if cgroup is really present in filesystem,
   otherwise return false or nil.
 + always create requested cgroup. If it is already
   contained in _CGroup_Cache, replace it with new one. Code should check
   its existence before calling anyway.

Real fix would involve changing ulatencyd_cleanup.lua in a way it tells
ulatencyd to remove that cgroup. Ulatencyd should also update its internal
structures and do clean up, i.e. handle remaining memory charges.
  • Loading branch information...
1 parent 4a43252 commit bfbb838f6b8f6e515a378fcd79bd9e64872ee513 @gajdusek committed Jun 29, 2012
Showing with 8 additions and 5 deletions.
  1. +8 −5 src/core.lua
@@ -409,12 +409,9 @@ end
ulatency.add_timeout(cgroups_cleanup, 120000)
+--! @brief create and initialize new cgroup in _CGroup_Cache, already existing cgroup is replaced
function, init, tree)
tree = tree or "cpu"
- rv = _CGroup_Cache[tree..'/']
- if rv then
- return rv
- end
if CGROUP_DEFAULT[tree] then
cinit = table.copy(CGROUP_DEFAULT[tree])
@@ -431,8 +428,14 @@ function CGroup.get_groups()
return _CGroup_Cache
+--! @brief return cgroup or false/nil if it does not exists or is not present in ulatency internal _CGroup_Cache
function CGroup.get_group(name)
- return _CGroup_Cache[name]
+ local cgr = _CGroup_Cache[name]
+ if cgr then
+ local stat=posix.stat(cgr:path())
+ return (stat and stat.type == 'directory') and cgr or nil
+ end
+ return nil

0 comments on commit bfbb838

Please sign in to comment.