From: Jeff Garzik <jgarzik@mandrakesoft.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pcmcia event thread. (fwd)
Date: Mon, 13 Nov 2000 08:48:40 -0500 [thread overview]
Message-ID: <3A0FF138.A510B45@mandrakesoft.com> (raw)
In-Reply-To: <7572.974120930@redhat.com>
David Woodhouse wrote:
> I'm not sure why we changed from the existing state machine / timer setup to
> sleeping in the PCMCIA parse_events() routine,
I don't remember the exact reason, but Linus changed it for yenta...
maybe because CardBus Watcher always called the state machine from user
context...
> +static int pcmcia_event_thread(void * dummy)
> +{
> + DECLARE_WAITQUEUE(wait, current);
> +
> + current->session = 1;
> + current->pgrp = 1;
> + strcpy(current->comm, "kpcmciad");
> + current->tty = NULL;
> + spin_lock_irq(¤t->sigmask_lock);
> + sigfillset(¤t->blocked);
> + recalc_sigpending(current);
> + spin_unlock_irq(¤t->sigmask_lock);
> + exit_mm(current);
> + exit_files(current);
> + exit_sighand(current);
> + exit_fs(current);
Replace most if not all of this crap w/ daemonize()
> +
> + while(!event_thread_leaving) {
> + void *active;
> +
> + set_current_state(TASK_INTERRUPTIBLE);
> + add_wait_queue(&event_thread_wq, &wait);
> +
> + /* Don't really need locking. But the implied mb() */
> + spin_lock(&tqueue_lock);
> + active = tq_pcmcia;
> + spin_unlock(&tqueue_lock);
> +
> + if (!active)
> + schedule();
> +
> + set_current_state(TASK_RUNNING);
> + remove_wait_queue(&event_thread_wq, &wait);
> +
> + run_task_queue(&tq_pcmcia);
> + }
it looks like the loop can be simplified to
while (1) {
mb();
active = tq_pcmcia;
if (!active)
interruptible_sleep_on(&event_thread_wq);
if (signal_pending(current)
break;
run_task_queue(&tq_pcmcia);
}
> + /* Need up_and_exit() */
> + up(&event_thread_exit_sem);
Racy. Use waitpid() in the thread killer instead. You also need to
reap the process, just like in userland...
> + /* Start the thread for handling queued events for socket drivers */
> + kernel_thread (pcmcia_event_thread, NULL,
> + CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
Why are you cloning _FS, _FILES, and _SIGHAND? I don't see why the
third arg should not be zero. man clone...
--
Jeff Garzik |
Building 1024 | The chief enemy of creativity is "good" sense
MandrakeSoft | -- Picasso
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2000-11-13 13:49 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-11-13 13:08 [PATCH] pcmcia event thread. (fwd) David Woodhouse
2000-11-13 13:48 ` Jeff Garzik [this message]
2000-11-16 13:28 ` Alan Cox
2000-11-13 14:37 ` David Woodhouse
2000-11-13 15:04 ` Jeff Garzik
2000-11-13 15:14 ` David Woodhouse
2000-11-13 15:33 ` Jeff Garzik
2000-11-16 13:39 ` Alan Cox
2000-11-16 14:14 ` David Woodhouse
2000-11-16 16:28 ` Tobias Ringstrom
2000-11-18 11:24 ` Pavel Machek
2000-11-13 15:42 ` David Woodhouse
2000-11-13 18:59 ` David Hinds
2000-11-13 21:52 ` David Woodhouse
2000-11-13 21:57 ` David Hinds
2000-11-13 22:30 ` David Woodhouse
2000-11-13 22:47 ` Jeff Garzik
2000-01-01 2:54 ` Pavel Machek
2000-11-16 21:26 ` tytso
2000-11-16 21:42 ` David Hinds
2000-11-13 23:04 ` David Woodhouse
2000-11-16 16:08 ` Alan Cox
2000-11-16 16:15 ` Jeff Garzik
2000-11-16 16:20 ` Alan Cox
2000-11-17 0:51 ` Russell King
2000-11-17 10:54 ` Alan Cox
2000-11-17 16:21 ` Linus Torvalds
2000-11-17 16:29 ` Alan Cox
2000-11-17 16:35 ` Linus Torvalds
2000-11-17 16:39 ` Alan Cox
2000-11-17 16:34 ` Russell King
2000-11-17 16:17 ` Linus Torvalds
2000-11-17 16:34 ` David Woodhouse
2000-11-17 16:40 ` Jeff Garzik
2000-11-17 16:47 ` Linus Torvalds
2000-11-17 16:49 ` David Woodhouse
2000-11-17 20:01 ` David Hinds
2000-11-17 16:43 ` David Woodhouse
2000-11-17 20:30 ` 2.4's internal PCMCIA works for me (was Re: [PATCH] pcmcia event thread) Barry K. Nathan
2000-11-17 21:07 ` David Hinds
2000-11-18 9:55 ` [PATCH] pcmcia event thread. (fwd) David Ford
2000-11-18 16:03 ` Linus Torvalds
2000-11-18 22:16 ` David Hinds
2000-11-19 5:32 ` David Ford
2000-11-19 5:36 ` Linus Torvalds
2000-11-19 6:30 ` [FIXED!] " David Ford
2000-11-19 7:03 ` neighbour table? Andrew Park
2000-11-19 6:57 ` David Ford
2000-11-19 7:45 ` Eric W. Biederman
2000-11-19 10:40 ` David Ford
2000-11-16 13:40 ` [PATCH] pcmcia event thread. (fwd) Alan Cox
2000-11-15 0:01 ` Russell King
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=3A0FF138.A510B45@mandrakesoft.com \
--to=jgarzik@mandrakesoft.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
/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