lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20090126143210.ce6a4503.akpm@linux-foundation.org>
Date:	Mon, 26 Jan 2009 14:32:10 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Frederic Weisbecker <fweisbec@...il.com>
Cc:	dmitry.torokhov@...il.com, dtor@...l.ru,
	linux-kernel@...r.kernel.org, mingo@...e.hu,
	linux-input@...r.kernel.org
Subject: Re: [PATCH] psmouse: run kpsmoused only while needed

On Thu, 15 Jan 2009 16:16:19 -0800 (PST)
Frederic Weisbecker <fweisbec@...il.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);
>  

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ