From: Matt Helsley Subject: Re: [PATCH 2/2] [RFC] Enable non-blocking writes to the cgroup freezer.state file Date: Mon, 26 Oct 2009 08:57:43 -0700 Message-ID: <20091026155743.GE31446@count0.beaverton.ibm.com> References: <1256570129-13107-2-git-send-email-matthltc@us.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1256570129-13107-2-git-send-email-matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Matt Helsley Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, Nathan Lynch , Paul Menage List-Id: containers.vger.kernel.org On Mon, Oct 26, 2009 at 08:15:30AM -0700, Matt Helsley wrote: > The change to the num_cant_freeze_now count enables blocking > while the test of dont_block outside of all the locks re-enables > non-blocking operations when O_NONBLOCK is set. nit: Oops, forgot to update the portion of the description above. Should read: The change to the num_cant_freeze_now count enables blocking while the test of f_flags & O_NONBLOCK outside of all the locks ... > @@ -356,10 +354,22 @@ static int freezer_write(struct cgroup *cgroup, struct cftype *cft, > else > return -EINVAL; > > +retry: > if (!cgroup_lock_live_group(cgroup)) > return -ENODEV; > retval = freezer_change_state(cgroup, goal_state); > cgroup_unlock(); > + > + if ((f_flags & O_NONBLOCK) || (retval != -EAGAIN)) > + return retval; > + > + /* block while we haven't changed the state to the goal state */ > + set_current_state(TASK_INTERRUPTIBLE); > + schedule(); > + __set_current_state(TASK_RUNNING); > + if (!signal_pending(current)) > + goto retry; > + retval = -EINTR; > return retval; > } Cheers, -Matt Helsley