Re: software suspend doesn't work with 2.6.22-rc3

From: Rafael J. Wysocki
Date: Thu May 31 2007 - 03:08:28 EST


On Thursday, 31 May 2007 09:04, Rafael J. Wysocki wrote:
> On Thursday, 31 May 2007 08:54, Rafael J. Wysocki wrote:
> > On Tuesday, 29 May 2007 02:39, Herbert Xu wrote:
> > > On Mon, May 28, 2007 at 08:21:29PM +0200, Rafael J. Wysocki wrote:
> > > >
> > > > Well, it looks like we have to fix this one separately.
> > > >
> > > > Can you please tell me what to do to make cryptd run?
> > >
> > > If you build it as a module then just loading it should be sufficient.
> > > If you have it built-in then it should always be there.
> > >
> > > Let me know when you guys have a final patch.
> >
> > The problem is more serious than I thought:
> >
> > kthread_create() in crypto/cryptd.c line 302 doesn't return, so cryptd is stuck
> > in TASK_UNINTERRUPTIBLE all the time and it doesn't even execute one
> > instruction from cryptd_thread() [this happens on x86_64].
>
> Sorry, I was wrong.
>
> kthread_create() returns, but cryptd_thread() is not executed and the cryptd
> process is stuck in TASK_UNINTERRUPTIBLE.

It can be fixed by replacing the kthread_create() with kthread_run(). Patch
follows.

Greetings,
Rafael

---
From: Rafael J. Wysocki <rjw@xxxxxxx>

Make cryptd actually run and mark it as nonfreezable.

Signed-off-by: Rafael J. Wysocki <rjw@xxxxxxx>
---
crypto/cryptd.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

Index: linux-2.6.22-rc3/crypto/cryptd.c
===================================================================
--- linux-2.6.22-rc3.orig/crypto/cryptd.c 2007-05-26 22:08:07.000000000 +0200
+++ linux-2.6.22-rc3/crypto/cryptd.c 2007-05-31 09:13:38.000000000 +0200
@@ -298,7 +298,7 @@ static inline int cryptd_create_thread(s
mutex_init(&state->mutex);
crypto_init_queue(&state->queue, CRYPTD_MAX_QLEN);

- state->task = kthread_create(fn, state, name);
+ state->task = kthread_run(fn, state, name);
if (IS_ERR(state->task))
return PTR_ERR(state->task);

@@ -316,6 +316,8 @@ static int cryptd_thread(void *data)
struct cryptd_state *state = data;
int stop;

+ current->flags |= PF_NOFREEZE;
+
do {
struct crypto_async_request *req, *backlog;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/