public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Matthew Garrett <mjg59@srcf.ucam.org>,
	Miklos Szeredi <miklos@szeredi.hu>, Pavel Machek <pavel@ucw.cz>,
	pm list <linux-pm@lists.linux-foundation.org>
Subject: Re: [RFC][PATCH -mm 2/6] Freezer: Do not send signals to kernel threads
Date: Tue, 10 Jul 2007 19:00:50 +0400	[thread overview]
Message-ID: <20070710150050.GA158@tv-sign.ru> (raw)
In-Reply-To: <200707092232.01603.rjw@sisk.pl>

On 07/09, Rafael J. Wysocki wrote:
>
> Commit b74d0deb968e1f85942f17080eace015ce3c332c has changed
> recalc_sigpending_tsk() so that it doesn't clear TIF_SIGPENDING.  For this
> reason, the freezer should not send fake signals to kernel threads any more,
> since otherwise some of them may run with TIF_SIGPENDING set forever if the
> freezing of kernel threads fails.

I personally think it is very good to get rid of signals to kthread, regardless
of changed behaviour of recalc_sigpending_tsk().

> +static int freeze_user_process(struct task_struct *p)
> +{
> +	int ret = 1;
> +
> +	task_lock(p);
> +	if (has_mm(p)) {
> +		if (freezing(p)) {
> +			if (!signal_pending(p))
> +				fake_signal_wake_up(p, 0);
> +			else
> +				wake_up_state(p, TASK_INTERRUPTIBLE);

Why do we need the "else" branch? It is already a bug if the task sleeps
in TASK_INTERRUPTIBLE state but has signal_pending().

The same for freeze_task(). Actually, they look very similar. Imho, it would
be better to have a single function with a "user_space_only" parameter.

> @@ -99,7 +99,6 @@ static inline int has_pending_signals(si
>  static int recalc_sigpending_tsk(struct task_struct *t)
>  {
>  	if (t->signal->group_stop_count > 0 ||
> -	    (freezing(t)) ||
>  	    PENDING(&t->pending, &t->blocked) ||
>  	    PENDING(&t->signal->shared_pending, &t->blocked)) {
>  		set_tsk_thread_flag(t, TIF_SIGPENDING);

This is important (and imho good) change, but changelog says nothing about it.

I guess this should works because freeze_user_process/freeze_task repeatedly
"re-send" the signal in a loop when TIF_SIGPENDING is cleared, yes?

> +#define wait_event_freezable(wq, condition)				\
> +({									\
> +	int __ret;							\
> +	do {								\
> +		__ret = wait_event_interruptible(wq, 			\
> +				(condition) || freezing(current));	\
> +	} while (try_to_freeze());					\
> +	__ret;								\
> +})

I don't think this is right.

wait_event_freezable() should return success _only_ if "condition" == true.
What if TIF_FREEZE was cleared between freezing() and try_to_freeze() ?

> --- linux-2.6.22-rc6-mm1.orig/drivers/input/gameport/gameport.c
> +++ linux-2.6.22-rc6-mm1/drivers/input/gameport/gameport.c
> @@ -448,9 +448,8 @@ static int gameport_thread(void *nothing
>  	set_freezable();
>  	do {
>  		gameport_handle_event();
> -		wait_event_interruptible(gameport_wait,
> +		wait_event_freezable(gameport_wait,
>  			kthread_should_stop() || !list_empty(&gameport_event_list));
> -		try_to_freeze();
>  	} while (!kthread_should_stop());

Isn't it better to break this patch into 2 separate ones? The first adds
wait_event_freezable() and "fixes" gameport_thread() and friends in advance,
the second deals with TIF_SIGPENDING. (please ignore if this is not convenient).

Oleg.

  parent reply	other threads:[~2007-07-10 15:00 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-09 20:29 [RFC][PATCH -mm 0/6] Freezer update Rafael J. Wysocki
2007-07-09 20:31 ` [RFC][PATCH -mm 1/6] Freezer: Do not sync filesystems Rafael J. Wysocki
2007-07-09 23:12   ` Pavel Machek
2007-07-10  0:31     ` Matthew Garrett
2007-07-09 20:32 ` [RFC][PATCH -mm 2/6] Freezer: Do not send signals to kernel threads Rafael J. Wysocki
2007-07-09 23:42   ` Pavel Machek
2007-07-10  5:57     ` Rafael J. Wysocki
2007-07-10 15:00   ` Oleg Nesterov [this message]
2007-07-10 21:08     ` Rafael J. Wysocki
2007-07-10 21:22       ` Oleg Nesterov
2007-07-09 20:33 ` [RFC][PATCH -mm 3/6] Freezer: Be more verbose Rafael J. Wysocki
2007-07-09 23:46   ` Pavel Machek
2007-07-10  6:01     ` Rafael J. Wysocki
2007-07-10 15:05       ` Pavel Machek
2007-07-09 20:34 ` [RFC][PATCH -mm 4/6] Freezer: Prevent new tasks from inheriting TIF_FREEZE set Rafael J. Wysocki
2007-07-09 23:21   ` Pavel Machek
2007-07-10  6:03     ` Rafael J. Wysocki
2007-07-10 15:05       ` Pavel Machek
2007-07-09 20:38 ` [RFC][PATCH -mm 5/6] Freezer: Use freezing timeout more efficiently Rafael J. Wysocki
2007-07-09 23:34   ` Pavel Machek
2007-07-10  6:09     ` Rafael J. Wysocki
2007-07-10 10:04       ` Rafael J. Wysocki
2007-07-10 17:17         ` Oleg Nesterov
2007-07-10 20:30           ` Rafael J. Wysocki
2007-07-10 20:55             ` Oleg Nesterov
2007-07-10 21:15               ` Rafael J. Wysocki
2007-07-10 18:50         ` Oleg Nesterov
2007-07-10 19:54           ` Rafael J. Wysocki
2007-07-10 20:35             ` Oleg Nesterov
2007-07-10 20:57               ` Rafael J. Wysocki
2007-07-10 21:13         ` bogosort (was Re: Re: [RFC][PATCH -mm 5/6] Freezer: Use freezing timeout more efficiently) Pavel Machek
2007-07-10 21:38           ` Oleg Nesterov
2007-07-10 21:39           ` Rafael J. Wysocki
2007-07-10 21:39             ` Pavel Machek
2007-07-10 22:07               ` Rafael J. Wysocki
2007-07-10 22:21                 ` Pavel Machek
2007-07-23  8:04                 ` Pavel Machek
2007-07-23 19:16                   ` Rafael J. Wysocki
2007-07-09 20:41 ` [RFC][PATCH -mm 6/6] Freezer: Document relationship with memory shrinking Rafael J. Wysocki
2007-07-09 23:23   ` Pavel Machek

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=20070710150050.GA158@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=miklos@szeredi.hu \
    --cc=mjg59@srcf.ucam.org \
    --cc=pavel@ucw.cz \
    --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