public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Gautham R Shenoy <ego@in.ibm.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Ingo Molnar <mingo@elte.hu>, Oleg Nesterov <oleg@tv-sign.ru>,
	Pavel Machek <pavel@ucw.cz>,
	Pekka Enberg <penberg@cs.helsinki.fi>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -mm] Allow selective freezing of the system for different events
Date: Tue, 1 May 2007 00:49:34 +0530	[thread overview]
Message-ID: <20070430191934.GA4142@in.ibm.com> (raw)
In-Reply-To: <200704291951.05425.rjw@sisk.pl>

On Sun, Apr 29, 2007 at 07:51:04PM +0200, Rafael J. Wysocki wrote:
> Hi,
> 
> Sorry for the delay.

No problems! Even I was out for the weekend.

> >  /*
> >   * Tell the freezer to exempt this task from freezing
> > + * for events in freeze_event_mask.
> >   */
> > -static inline void freezer_exempt(struct task_struct *p)
> 
> I, personally, would introduce
> 
> static inline void freezer_exempt_event(struct task_struct *p,
> 				  unsigned long freeze_event_mask)
> {
> 	atomic_set_mask(freeze_event_mask, &p->freezer_flags);
> }
> 
> and then
> 
> static inline void freezer_exempt(struct task_struct *p)
> {
> 	freezer_exempt_event(p, FE_ALL);
> }
> 
> The patch would be shorter. ;-)
> 

Agreed. Will do that.

> [In that case I'd probably rename freezer_should_exempt() to
> freezer_should_exempt_event(), for symmetry.]
> 

Ok. 

> > +
> > +static inline int thawable(struct task_struct *p)
> > +{
> > +	if (!freezeable(p))
> > +		return 0;
> > +
> > +	/* Thaw p iff it is frozen for current_freezer_event alone */
> > +	 if (process_frozen_event_mask(p) & ~current_freezer_event)
> > +	 	return 0;
> > +
> > +	return 1;
> 
> I would do
> 
> 	return !(process_frozen_event_mask(p) & ~current_freezer_event);

I was wondering if the statement
	 if (process_frozen_event_mask(p) & ~current_freezer_event)
	 	return 0;

would be readable in the first place! 
Yeah, we can do what you have suggested.

> > -int freeze_processes(void)
> > +int freeze_processes(unsigned long freeze_event)
> >  {
> > -	unsigned int nr_unfrozen;
> > +	unsigned int nr_unfrozen = 0;
> > +
> > +	mutex_lock(&freezer_mutex);
> > +	if (system_frozen_event_mask & freeze_event)
> > +		goto out;
> > +
> > +	current_freezer_event = freeze_event;
> >  
> >  	printk("Stopping tasks ... ");
> >  	nr_unfrozen = try_to_freeze_tasks(FREEZER_USER_SPACE);
> >  	if (nr_unfrozen)
> > -		return nr_unfrozen;
> > +		goto out;
> >  
> >  	sys_sync();
> >  	nr_unfrozen = try_to_freeze_tasks(FREEZER_KERNEL_THREADS);
> >  	if (nr_unfrozen)
> > -		return nr_unfrozen;
> > +		goto out;
> >  
> > +	system_frozen_event_mask |= current_freezer_event;
> >  	printk("done.\n");
> >  	BUG_ON(in_atomic());
> 
> The BUG_ON() is still valid if tasks are already frozen for this event.

Right! So we would need one more label. How about the following?

	mutex_lock(&freezer_mutex);
	/* check if already frozen for the event */
	if (system_frozen_event_mask & freeze_event)
		goto out_frozen;
		.
		.
		.

out_frozen: 
	BUG_ON(in_atomic());
out:
	current_freezer_event = 0;
	mutex_unlock(&freezer_mutex);
	return nr_unfrozen;
}

> 

> > -void thaw_processes(void)
> > +void thaw_processes(unsigned long thaw_event)
> >  {
> > +	mutex_lock(&freezer_mutex);
> > +	if (!(system_frozen_event_mask & thaw_event)) {
> > +		WARN_ON(1);
> 
> Hmm, I wouldn't use the WARN_ON() here.  There's nothing wrong in calling
> this twice in a row as long as we do the sanity checking.  There's even one
> case in which that may be convenient, actually.

Well, yes. But I put the warn on from the perspective of someone trying
to thaw_processes for the event for which they have not frozen. I hadn't
thought about a double thaw. Will rethink.

Thanks for the Review.
Regards
gautham.
-- 
Gautham R Shenoy
Linux Technology Center
IBM India.
"Freedom comes with a price tag of responsibility, which is still a bargain,
because Freedom is priceless!"

      reply	other threads:[~2007-04-30 19:20 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-27 15:37 [PATCH -mm 0/2] Separate freezer from PM code Rafael J. Wysocki
2007-04-27 15:38 ` [PATCH -mm 1/2] " Rafael J. Wysocki
2007-04-27 16:15   ` Sam Ravnborg
2007-04-27 16:25   ` Jeremy Fitzhardinge
2007-04-27 20:20     ` Rafael J. Wysocki
2007-04-27 20:20       ` Jeremy Fitzhardinge
2007-04-27 21:29         ` Rafael J. Wysocki
2007-04-29  8:43           ` Sam Ravnborg
2007-04-27 15:40 ` [PATCH -mm 2/2] Introduce freezer flags Rafael J. Wysocki
2007-04-27 16:19   ` Sam Ravnborg
2007-04-27 16:33     ` Gautham R Shenoy
2007-04-27 21:40   ` Gautham R Shenoy
2007-04-27 21:49     ` Rafael J. Wysocki
2007-04-27 21:49       ` Gautham R Shenoy
2007-04-27 22:09       ` Rafael J. Wysocki
2007-04-27 22:07         ` Pavel Machek
2007-04-27 22:56           ` Rafael J. Wysocki
2007-04-28  7:07             ` Pavel Machek
2007-04-28  1:34   ` [PATCH -mm] Allow selective freezing of the system for different events Gautham R Shenoy
2007-04-28  6:22     ` Andrew Morton
2007-04-28  7:45       ` Gautham R Shenoy
2007-04-29 17:51     ` Rafael J. Wysocki
2007-04-30 19:19       ` Gautham R Shenoy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070430191934.GA4142@in.ibm.com \
    --to=ego@in.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=oleg@tv-sign.ru \
    --cc=pavel@ucw.cz \
    --cc=penberg@cs.helsinki.fi \
    --cc=rjw@sisk.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox