From: Andrew Morton <akpm@linux-foundation.org>
To: Frederic Weisbecker <fweisbec@gmail.com>
Cc: dmitry.torokhov@gmail.com, dtor@mail.ru,
linux-kernel@vger.kernel.org, mingo@elte.hu,
linux-input@vger.kernel.org
Subject: Re: [PATCH] psmouse: run kpsmoused only while needed
Date: Mon, 26 Jan 2009 14:32:10 -0800 [thread overview]
Message-ID: <20090126143210.ce6a4503.akpm@linux-foundation.org> (raw)
In-Reply-To: <496fd1d3.0d135e0a.171b.43ea@mx.google.com>
On Thu, 15 Jan 2009 16:16:19 -0800 (PST)
Frederic Weisbecker <fweisbec@gmail.com> wrote:
> While looking at the workqueue tracer, I noticed that kpsmoused receives
> rarely (if not never) events.
>
> Currently, when a mouse has to resync, it uses the kpsmoused singlethreaded
> workqueue. But recync are rare. While reading an old discussion, it seems
> that usual workqueue events can't be used for that purpose because resync
> can take too much time and could delay the other works in queue.
>
> But if you have built psmouse driver, this workqueue will always be present
> whether you have a ps/2 port or not. And its events are rare.
>
> To avoid this pointless task, this patch makes the kpsmoused a kernel
> thread only created on the fly when a recync is needed. Once the recync is done,
> this thread will die. So you will almost never see it, and it will not be
> an inactive task anymore.
>
> This thread is created through a usual workqueue event (because we can't create
> it from interrupt).
>
Seems like a reasonable objective.
>
> ...
>
> /*
> * __psmouse_set_state() sets new psmouse state and resets all flags.
> @@ -313,7 +307,8 @@ static irqreturn_t psmouse_interrupt(struct serio *serio,
> psmouse->name, psmouse->phys, psmouse->pktcnt);
> psmouse->badbyte = psmouse->packet[0];
> __psmouse_set_state(psmouse, PSMOUSE_RESYNCING);
> - psmouse_queue_work(psmouse, &psmouse->resync_work, 0);
> + atomic_inc(&psmouse->nb_recync_pending);
The patch and the changelog consistently misspell "sync".
A code comment (in psmouse.h) which clearly spells out the role of
nb_recync_pending would be useful.
> + schedule_work(&psmouse->resync_work);
> goto out;
> }
>
>
> ...
>
> @@ -1131,7 +1155,13 @@ static void psmouse_disconnect(struct serio *serio)
>
> /* make sure we don't have a resync in progress */
> mutex_unlock(&psmouse_mutex);
> - flush_workqueue(kpsmoused_wq);
> +
> + prepare_to_wait(&psmouse->recync_pending_queue, &wait,
> + TASK_UNINTERRUPTIBLE);
> + if (atomic_read(&psmouse->nb_recync_pending))
> + schedule();
> + finish_wait(&psmouse->recync_pending_queue, &wait);
So... we're requiring that nb_recync_pending is zero at this stage?
I wonder if the code manages to do that. A little WARN_ON(), maybe?
> mutex_lock(&psmouse_mutex);
>
next prev parent reply other threads:[~2009-01-26 22:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-16 0:16 [PATCH] psmouse: run kpsmoused only while needed Frederic Weisbecker
2009-01-22 20:36 ` Frédéric Weisbecker
2009-01-26 22:32 ` Andrew Morton [this message]
2009-01-27 0:34 ` Frederic Weisbecker
2009-01-28 23:08 ` Frederic Weisbecker
2009-02-03 7:03 ` Andrew Morton
2009-02-03 9:49 ` Frederic Weisbecker
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=20090126143210.ce6a4503.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=dmitry.torokhov@gmail.com \
--cc=dtor@mail.ru \
--cc=fweisbec@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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;
as well as URLs for NNTP newsgroup(s).