Skip to content
This repository

Fixes/issue28 #38

Merged
merged 2 commits into from over 1 year ago

2 participants

Petr Gajdůšek Daniel Poelzleithner
Petr Gajdůšek
Collaborator

Hi,
please review patch (2 actually) fixing issue28.

gajdusek added some commits
Petr Gajdůšek gajdusek scheduler: Do not reinitialize parent cgroups everytime a child group…
… is created.

Whenever scheduler find a process matching rule and correspondent cgroup
does not yet exist, scheduler blindly tries to create all parental
cgroups, ignoring they may already be there.

adjust_new() functions are repeatedly called upon already existing
cgroups and adjust() function is repeatedly added to them.
4a43252
Petr Gajdůšek gajdusek core.lua: fix for cgroups removed outside ulatencyd (issue #28)
fixes issue #28: CGroup properties not set.

Reason:
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.
 + CGroup.new(): always create requested cgroup. If it is already
   contained in _CGroup_Cache, replace it with new one. Code should check
   its existence before calling CGroup.new() 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.
bfbb838
Petr Gajdůšek
Collaborator

Oops. it was not my indent to create new issue for this pull request, but I was not able to figure out, how attach this to issue 28. Did I missed something?

Daniel Poelzleithner poelzi merged commit bfbb838 into from
Daniel Poelzleithner poelzi closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Jul 04, 2012
Petr Gajdůšek gajdusek scheduler: Do not reinitialize parent cgroups everytime a child group…
… is created.

Whenever scheduler find a process matching rule and correspondent cgroup
does not yet exist, scheduler blindly tries to create all parental
cgroups, ignoring they may already be there.

adjust_new() functions are repeatedly called upon already existing
cgroups and adjust() function is repeatedly added to them.
4a43252
Petr Gajdůšek gajdusek core.lua: fix for cgroups removed outside ulatencyd (issue #28)
fixes issue #28: CGroup properties not set.

Reason:
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.
 + CGroup.new(): always create requested cgroup. If it is already
   contained in _CGroup_Cache, replace it with new one. Code should check
   its existence before calling CGroup.new() 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.
bfbb838
This page is out of date. Refresh to see the latest.

Showing 2 changed files with 14 additions and 5 deletions. Show diff stats Hide diff stats

  1. +6 0 rules/scheduler.lua
  2. +8 5 src/core.lua
6 rules/scheduler.lua
@@ -104,6 +104,12 @@ local function create_group(proc, prefix, mapping, subsys)
104 104 else
105 105 path = name
106 106 end
  107 +
  108 + local rv = CGroup.get_group(subsys .."/".. path)
  109 + if rv then
  110 + return rv
  111 + end
  112 +
107 113 rv = CGroup.new(path, mapping.param, subsys)
108 114 if mapping.adjust then
109 115 rv.adjust[#rv.adjust+1] = mapping.adjust
13 src/core.lua
@@ -409,12 +409,9 @@ end
409 409
410 410 ulatency.add_timeout(cgroups_cleanup, 120000)
411 411
  412 +--! @brief create and initialize new cgroup in _CGroup_Cache, already existing cgroup is replaced
412 413 function CGroup.new(name, init, tree)
413 414 tree = tree or "cpu"
414   - rv = _CGroup_Cache[tree..'/'..name]
415   - if rv then
416   - return rv
417   - end
418 415 if CGROUP_DEFAULT[tree] then
419 416 cinit = table.copy(CGROUP_DEFAULT[tree])
420 417 else
@@ -431,8 +428,14 @@ function CGroup.get_groups()
431 428 return _CGroup_Cache
432 429 end
433 430
  431 +--! @brief return cgroup or false/nil if it does not exists or is not present in ulatency internal _CGroup_Cache
434 432 function CGroup.get_group(name)
435   - return _CGroup_Cache[name]
  433 + local cgr = _CGroup_Cache[name]
  434 + if cgr then
  435 + local stat=posix.stat(cgr:path())
  436 + return (stat and stat.type == 'directory') and cgr or nil
  437 + end
  438 + return nil
436 439 end
437 440
438 441

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.