linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] input/evdev: make evdev use keyed wakeups
@ 2020-04-10 23:35 Kenny Levinsen
  2020-04-19  4:27 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Kenny Levinsen @ 2020-04-10 23:35 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input, Kenny Levinsen

Some processes, such as systemd, are only polling for EPOLLERR|EPOLLHUP.
As evdev uses unkeyed wakeups, such a poll receives many spurious
wakeups from uninteresting events.

Use keyed wakeups to allow the wakeup target to more efficiently discard
these uninteresting events.

Signed-off-by: Kenny Levinsen <kl@kl.wtf>
---
 drivers/input/evdev.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index d7dd6fcf2db0..f54d3d31f61d 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -282,7 +282,8 @@ static void evdev_pass_values(struct evdev_client *client,
 	spin_unlock(&client->buffer_lock);
 
 	if (wakeup)
-		wake_up_interruptible(&evdev->wait);
+		wake_up_interruptible_poll(&evdev->wait,
+			EPOLLIN | EPOLLOUT | EPOLLRDNORM | EPOLLWRNORM);
 }
 
 /*
@@ -443,7 +444,7 @@ static void evdev_hangup(struct evdev *evdev)
 		kill_fasync(&client->fasync, SIGIO, POLL_HUP);
 	spin_unlock(&evdev->client_lock);
 
-	wake_up_interruptible(&evdev->wait);
+	wake_up_interruptible_poll(&evdev->wait, EPOLLHUP | EPOLLERR);
 }
 
 static int evdev_release(struct inode *inode, struct file *file)
@@ -958,7 +959,7 @@ static int evdev_revoke(struct evdev *evdev, struct evdev_client *client,
 	client->revoked = true;
 	evdev_ungrab(evdev, client);
 	input_flush_device(&evdev->handle, file);
-	wake_up_interruptible(&evdev->wait);
+	wake_up_interruptible_poll(&evdev->wait, EPOLLHUP | EPOLLERR);
 
 	return 0;
 }
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] input/evdev: make evdev use keyed wakeups
  2020-04-10 23:35 [PATCH] input/evdev: make evdev use keyed wakeups Kenny Levinsen
@ 2020-04-19  4:27 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2020-04-19  4:27 UTC (permalink / raw)
  To: Kenny Levinsen; +Cc: linux-input

On Sat, Apr 11, 2020 at 01:35:57AM +0200, Kenny Levinsen wrote:
> Some processes, such as systemd, are only polling for EPOLLERR|EPOLLHUP.
> As evdev uses unkeyed wakeups, such a poll receives many spurious
> wakeups from uninteresting events.
> 
> Use keyed wakeups to allow the wakeup target to more efficiently discard
> these uninteresting events.
> 
> Signed-off-by: Kenny Levinsen <kl@kl.wtf>

Applied, thank you.

> ---
>  drivers/input/evdev.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
> index d7dd6fcf2db0..f54d3d31f61d 100644
> --- a/drivers/input/evdev.c
> +++ b/drivers/input/evdev.c
> @@ -282,7 +282,8 @@ static void evdev_pass_values(struct evdev_client *client,
>  	spin_unlock(&client->buffer_lock);
>  
>  	if (wakeup)
> -		wake_up_interruptible(&evdev->wait);
> +		wake_up_interruptible_poll(&evdev->wait,
> +			EPOLLIN | EPOLLOUT | EPOLLRDNORM | EPOLLWRNORM);
>  }
>  
>  /*
> @@ -443,7 +444,7 @@ static void evdev_hangup(struct evdev *evdev)
>  		kill_fasync(&client->fasync, SIGIO, POLL_HUP);
>  	spin_unlock(&evdev->client_lock);
>  
> -	wake_up_interruptible(&evdev->wait);
> +	wake_up_interruptible_poll(&evdev->wait, EPOLLHUP | EPOLLERR);
>  }
>  
>  static int evdev_release(struct inode *inode, struct file *file)
> @@ -958,7 +959,7 @@ static int evdev_revoke(struct evdev *evdev, struct evdev_client *client,
>  	client->revoked = true;
>  	evdev_ungrab(evdev, client);
>  	input_flush_device(&evdev->handle, file);
> -	wake_up_interruptible(&evdev->wait);
> +	wake_up_interruptible_poll(&evdev->wait, EPOLLHUP | EPOLLERR);
>  
>  	return 0;
>  }
> -- 
> 2.26.0
> 

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-19  4:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-10 23:35 [PATCH] input/evdev: make evdev use keyed wakeups Kenny Levinsen
2020-04-19  4:27 ` Dmitry Torokhov

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).