From: Andrew Morton <akpm@osdl.org>
To: Ryan Arnold <rsa@us.ibm.com>
Cc: linux-kernel@vger.kernel.org, paulus@samba.org
Subject: Re: [announce] HVCS for inclusion in 2.6 tree
Date: Thu, 22 Jul 2004 19:16:37 -0700 [thread overview]
Message-ID: <20040722191637.52ab515a.akpm@osdl.org> (raw)
In-Reply-To: <1090528007.3161.7.camel@localhost>
Ryan Arnold <rsa@us.ibm.com> wrote:
>
> hvcs_to_mainline_draft2.patch text/x-patch (80516 bytes)
>
> +int khvcsd(void *unused)
> +{
> + struct hvcs_struct *hvcsd = NULL;
> + struct list_head *element;
> + struct list_head *safe_temp;
> + int hvcs_todo_mask;
> +
> + daemonize("khvcsd");
> +
> + allow_signal(SIGTERM);
> +
> + do {
> + wait_queue_t wait = __WAITQUEUE_INITIALIZER(wait, current);
> + hvcs_todo_mask = 0;
> + hvcs_kicked = 0;
> + wmb();
> + list_for_each_safe(element, safe_temp, &hvcs_structs) {
> + hvcsd = list_entry(element, struct hvcs_struct, next);
> + hvcs_todo_mask |= hvcs_io(hvcsd);
> + }
> +
> + /* If any of the hvcs adapters want to try a write or quick read
> + * don't schedule(), yield a smidgen then execute the hvcs_io
> + * thread again for those that want the write. */
> + if (hvcs_todo_mask & (HVCS_TRY_WRITE | HVCS_QUICK_READ)) {
> + yield();
> + continue;
> + }
> +
> + add_wait_queue(&hvcs_wait_queue, &wait);
> + set_current_state(TASK_INTERRUPTIBLE);
> + if (!hvcs_kicked)
> + schedule();
> + set_current_state(TASK_RUNNING);
> + remove_wait_queue(&hvcs_wait_queue, &wait);
> +
> + } while (!signal_pending(current));
> +
> + complete_and_exit(&hvcs_exited,0);
> +}
>
I'm not a big fan of using signals for in-kernel IPC. (What happens if
root accidentally does `kill -TERM $(pidof khvcsd)', btw?) And daemonize()
is deprecated.
It should be possible to use the kthread infrastructure here - it does most
of this stuff for you. Use kthread_stop() in the killer and
kthread_should_stop() within khvcsd(). kthread_stop() is synchronous, so
you don't need to do the complete() stuff here.
It should not be necessary to re-add to the wait queue head on each pass
around the loop.
khvcsd() can have static scope.
next prev parent reply other threads:[~2004-07-22 23:17 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-14 15:42 Ryan Arnold
2004-07-18 2:00 ` Paul Mackerras
2004-07-19 15:54 ` Ryan Arnold
2004-07-22 20:26 ` Ryan Arnold
2004-07-23 1:57 ` Andrew Morton
2004-07-26 14:41 ` Ryan Arnold
2004-07-23 2:16 ` Andrew Morton [this message]
2004-07-27 20:08 ` [announce][draft3] " Ryan Arnold
2004-07-27 22:50 ` Randy.Dunlap
2004-07-28 16:39 ` Ryan Arnold
2004-07-28 20:12 ` Randy.Dunlap
2004-07-28 20:18 ` [announce][draft4] " Ryan Arnold
2004-07-29 17:41 ` Jeff Garzik
2004-08-02 14:24 ` Ryan Arnold
2004-07-28 20:36 ` [announce][draft3] " Paul Mackerras
2004-07-28 17:00 ` Ryan Arnold
2004-07-27 23:02 ` Randy.Dunlap
2004-07-23 2:21 ` [announce] " Andrew Morton
2004-07-26 12:57 ` Ryan Arnold
2004-07-23 2:29 ` Andrew Morton
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=20040722191637.52ab515a.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulus@samba.org \
--cc=rsa@us.ibm.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
all inboxes | Powered by JetHome®