<p><br>
On Mar 2, 2012 11:06 AM, "Lennert Buytenhek" <<a href="mailto:buytenh@wantstofly.org">buytenh@wantstofly.org</a>> wrote:<br>
><br>
> On Fri, Mar 02, 2012 at 01:50:16AM -0800, Jon Nettleton wrote:<br>
><br>
> > > One problem you can get into with this scheme is a kind of priority<br>
> > > inversion.  If the low priority process does:<br>
> > ><br>
> > >        fd = open("/foo/bar", O_RDWR);<br>
> > >        flock(fd, LOCK_EX);<br>
> > ><br>
> > > and the high priority process then also does:<br>
> > ><br>
> > >        fd = open("/foo/bar", O_RDWR);<br>
> > >        flock(fd, LOCK_EX);<br>
> > ><br>
> > > and the low priority process then does:<br>
> > ><br>
> > >        sleep(1);<br>
> > >        flock(fd, LOCK_UN);<br>
> > ><br>
> > > and the system then goes into suspend, you'll not wake up again<br>
> > > after that second expires, and you might not wake up again soon<br>
> > > at all.  The low priority process doesn't even have to sleep<br>
> > > explicitly, if it takes a page fault you get basically the same<br>
> > > thing.<br>
> ><br>
> > I believe the cgroup method will catch this though.  I would have<br>
> > to double check, but I think that the cgroup becomes partially<br>
> > frozen returning EBUSY until all the processes can properly be<br>
> > frozen.  At that time I believe it is up to userspace to thaw, or<br>
> > refreeze the group, unless the blocking process ends in which case<br>
> > the entire cgroup is set to the frozen state.<br>
><br>
> You can still suffer from priority inversion if you freeze a cgroup<br>
> with a low priority process in it that holds a resource that another<br>
> high priority process needs.<br>
><br>
> You indeed can't suffer from priority inversion between processes in<br>
> the same cgroup if you are going to freeze all of them, but then you<br>
> don't care about CPU wakeups for the high priority process either.<br>
><br>
> I guess that what I don't see yet is how you would use cgroups to<br>
> implement the goals of John's scheme.</p>
<p>The cgroup would be the method to organize the processes that you don't want running all  the time, but only when a higher priority processes has already woken the cpu and is doing significant work.  If we put all these "background" processes in a special cgroup, we can freeze their activity before suspend, or any other arbitrary time at that point.  Then it would be up to a process scheduler, or a userspace daemon to decided when we would want to thaw this group because our system will already be up and doing work.  We can also put a lower priority on that cgroup as to not steal cpu cycles from the process that caused the cpu/system to wakeup to do work.</p>

<p>Am I misunderstanding the concept proposed?</p>
<p>-Jon</p>