From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: "Franck Bui-Huu" <vagabon.xyz@gmail.com>
Cc: linux-pm@lists.linux-foundation.org, lkml <linux-kernel@vger.kernel.org>
Subject: Re: apm emulation driver broken ?
Date: Fri, 16 Nov 2007 22:20:55 +0100 [thread overview]
Message-ID: <200711162220.56494.rjw@sisk.pl> (raw)
In-Reply-To: <cda58cb80711160929i4dbac6b7xb9d1bcc9223ddd7b@mail.gmail.com>
On Friday, 16 of November 2007, Franck Bui-Huu wrote:
> On Nov 16, 2007 5:20 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> >
> > The freezer doesn't regard the current task as freezable.
> >
>
>
> Hmm, I don't get your point.
>
> If I understood this driver correctly, several processes can be
> waiting for a suspend event by reading /dev/apm_bios, apmd (the _user_
> space daemon) can be one of them.
>
> Then another process asks to suspend the system by calling 'apm -s',
> which results in a apm_ioctl() call. This process will basically
> execute:
>
> err = queue_suspend_event(APM_USER_SUSPEND, as);
> flags = current->flags;
> wait_event_interruptible(apm_suspend_waitqueue,
> as->suspend_state == SUSPEND_DONE);
>
> It's basically waiting for the waiters to ack the event. But it won't
> be the process that is going to suspend the system, right ?
>
> So now all waiting processes are waken up and need to acknolwedge the
> event for the system to actually suspend. So they need to call
> apm_ioctl(). They'll basically do:
>
> flags = current->flags;
> wait_event(apm_suspend_waitqueue,
> as->suspend_state == SUSPEND_DONE);
>
> Except for the last acknowledging process which will do instead:
>
> apm_suspend();
>
> It's a call to pm_suspend().
>
> So you can see that the process which initiates the suspend, the one
> that calls 'apm -s', is not the current process but is going to be
> waken up by the fake signal sent by freeze_task().
>
> One of the consequence I can see is at this time 'as->result' won't be
> setup, so the return value of apm_ioctl() may be wrong.
Ah, that. Yes, I see your point.
However, using PF_NOFREEZE to prevent this from happening doesn't seem to be
a good idea.
I'd probably use wait_event_freezable() (defined in include/linux/freezer.h)
for that.
> As I said, I'm not familiar with this code, so please correct me if
> I'm wrong.
No, you're not wrong and I have overlooked the problem.
> BTW, how does try_to_freeze_tasks() deal with user land thread waiting
> in the UNINTERRUPTIBLE state ?
It tries to send them fake signals and waits for them to freeze. If they don't
freeze within the timeout, it fails and clears their TIF_FREEZE bits.
Greetings,
Rafael
next prev parent reply other threads:[~2007-11-16 21:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-16 15:06 apm emulation driver broken ? Franck Bui-Huu
2007-11-16 16:20 ` Rafael J. Wysocki
2007-11-16 17:29 ` Franck Bui-Huu
2007-11-16 21:20 ` Rafael J. Wysocki [this message]
2007-11-17 8:53 ` Franck Bui-Huu
2007-11-17 9:59 ` Rafael J. Wysocki
2007-11-17 11:09 ` Rafael J. Wysocki
2007-11-17 11:57 ` Franck Bui-Huu
2007-11-17 12:46 ` Rafael J. Wysocki
2007-11-18 19:57 ` Franck Bui-Huu
2007-11-18 22:22 ` Rafael J. Wysocki
2007-11-19 13:05 ` Franck Bui-Huu
2007-11-21 1:32 ` Rafael J. Wysocki
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=200711162220.56494.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=vagabon.xyz@gmail.com \
/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