mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christophe Saout <christophe@saout.de>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: LKML <linux-kernel@vger.kernel.org>, pavel@suse.cz
Subject: Re: kthread, signals and PF_FREEZE (suspend)
Date: Mon, 16 Feb 2004 14:36:15 +0100	[thread overview]
Message-ID: <1076938575.7350.29.camel@leto.cs.pocnet.net> (raw)
In-Reply-To: <20040216034251.0912E2C0F8@lists.samba.org>

Am Mo, den 16.02.2004 schrieb Rusty Russell um 04:38:

> > That means that signal_pending() will return true for that process which
> > will make kthread stop the thread.
> 
> Yes, the way they are currently coded.  I had assumed that spurious
> signals do not occur.

Yes, the freeze signalling is somewhat hackish. It sets the PF_FREEZE
flag and calls signal_wake_up on the process.

> Pavel, what is the answer here?  Should the refrigerator code be in
> the kthread infrastructure?  Why does the workqueue code set
> PF_IOTHREAD?

If PF_IOTHREAD is set the suspend code won't try to freeze the process
(kthread works here with the suspend code).

But you could change

while (!signal_pending(current))
        ret = threadfn(data);

to

for (;;) {
	if (current->flags & PF_FREEZE)
		refrigerator(PF_IOTHREAD);
	if (signal_pending())
		break;
        ret = threadfn(data);
}

or something like that.

The threadfn will return when it sees a signal. If it was a "PF_FREEZE
signal" the refrigerator will suspend the code and flush the signal. The
threadfn will be reentered afterwards (it should be prepared for this to
happen if it doesn't handle PF_FREEZE itself).

If it was real signal the thread will exit.

BTW: You might want to export the kthread functions:

EXPORT_SYMBOL(kthread_create);
EXPORT_SYMBOL(kthread_bind);
EXPORT_SYMBOL(kthread_stop);

Should I send a patch to Andrew?



  parent reply	other threads:[~2004-02-16 13:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-16  0:18 Christophe Saout
2004-02-16  3:38 ` Rusty Russell
2004-02-16  9:55   ` Pavel Machek
2004-02-16 13:36   ` Christophe Saout [this message]
2004-02-16 16:53   ` Jamie Lokier
2004-02-16 17:12     ` Christophe Saout
2004-02-17  4:44     ` Rusty Russell

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=1076938575.7350.29.camel@leto.cs.pocnet.net \
    --to=christophe@saout.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@suse.cz \
    --cc=rusty@rustcorp.com.au \
    /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

all inboxes | Powered by JetHome®