* [PATCH] [v3]Input: evdev - drop partial events after emptying the buffer
@ 2016-01-04 21:30 Aniroop Mathur
2016-01-04 21:49 ` kbuild test robot
2016-01-04 22:00 ` kbuild test robot
0 siblings, 2 replies; 4+ messages in thread
From: Aniroop Mathur @ 2016-01-04 21:30 UTC (permalink / raw)
To: dmitry.torokhov, benjamin.tissoires, peter.hutterer
Cc: dh.herrmann, rydberg, aniroop.mathur, linux-input, linux-kernel,
Aniroop Mathur
This patch introduces concept to drop partial events in evdev handler
itself after emptying the buffer which are dropped by all evdev
clients in userspace after SYN_DROPPED occurs and this in turn reduces
evdev client reading requests plus saves memory space filled by partial
events in evdev handler buffer.
Also, this patch prevents dropping of full packet by evdev client after
SYN_DROPPED occurs in case last stored event was SYN_REPORT.
(like after clock change request)
Signed-off-by: Aniroop Mathur <a.mathur@samsung.com>
---
drivers/input/evdev.c | 53 ++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 40 insertions(+), 13 deletions(-)
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index e9ae3d5..2d670e4 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -58,6 +58,7 @@ struct evdev_client {
struct list_head node;
unsigned int clk_type;
bool revoked;
+ bool drop_pevent; /* specifies if partial events need to be dropped */
unsigned long *evmasks[EV_CNT];
unsigned int bufsize;
struct input_event buffer[];
@@ -156,7 +157,12 @@ static void __evdev_flush_queue(struct evdev_client *client, unsigned int type)
static void __evdev_queue_syn_dropped(struct evdev_client *client)
{
struct input_event ev;
+ struct input_event *prev_ev;
ktime_t time;
+ unsigned int mask = client->bufsize - 1;
+
+ /* Store previous event */
+ prev_ev = &client->buffer[(client->head - 1) & mask];
time = client->clk_type == EV_CLK_REAL ?
ktime_get_real() :
@@ -170,13 +176,33 @@ static void __evdev_queue_syn_dropped(struct evdev_client *client)
ev.value = 0;
client->buffer[client->head++] = ev;
- client->head &= client->bufsize - 1;
+ client->head &= mask;
if (unlikely(client->head == client->tail)) {
/* drop queue but keep our SYN_DROPPED event */
- client->tail = (client->head - 1) & (client->bufsize - 1);
+ client->tail = (client->head - 1) & mask;
client->packet_head = client->tail;
}
+
+ /*
+ * If last packet is NOT fully stored, set drop_pevent to true to
+ * ignore partial events and if last packet is fully stored, queue
+ * SYN_REPORT so that clients would not ignore next full packet.
+ */
+ if (prev_ev->type != EV_SYN && prev_ev->code != SYN_REPORT) {
+ client->drop_pevent = true;
+ } else if (prev_ev->type == EV_SYN && prev_ev->code == SYN_REPORT) {
+ prev_ev.time = ev.time;
+ client->buffer[client->head++] = prev_ev;
+ client->head &= mask;
+ client->packet_head = client->head;
+
+ /* drop queue but keep our SYN_DROPPED & SYN_REPORT event */
+ if (unlikely(client->head == client->tail)) {
+ client->tail = (client->head - 2) & mask;
+ client->packet_head = client->tail;
+ }
+ }
}
static void evdev_queue_syn_dropped(struct evdev_client *client)
@@ -235,18 +261,8 @@ static void __pass_event(struct evdev_client *client,
client->head &= client->bufsize - 1;
if (unlikely(client->head == client->tail)) {
- /*
- * This effectively "drops" all unconsumed events, leaving
- * EV_SYN/SYN_DROPPED plus the newest event in the queue.
- */
- client->tail = (client->head - 2) & (client->bufsize - 1);
-
- client->buffer[client->tail].time = event->time;
- client->buffer[client->tail].type = EV_SYN;
- client->buffer[client->tail].code = SYN_DROPPED;
- client->buffer[client->tail].value = 0;
-
client->packet_head = client->tail;
+ __evdev_queue_syn_dropped(client);
}
if (event->type == EV_SYN && event->code == SYN_REPORT) {
@@ -284,6 +300,17 @@ static void evdev_pass_values(struct evdev_client *client,
wakeup = true;
}
+ /*
+ * drop partial events of last packet but queue SYN_REPORT
+ * so that clients would not ignore extra full packet.
+ */
+ if (client->drop_pevent) {
+ if (v->type == EV_SYN && v->code == SYN_REPORT)
+ client->drop_pevent = false;
+ else
+ continue;
+ }
+
event.type = v->type;
event.code = v->code;
event.value = v->value;
--
2.6.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] [v3]Input: evdev - drop partial events after emptying the buffer
2016-01-04 21:30 [PATCH] [v3]Input: evdev - drop partial events after emptying the buffer Aniroop Mathur
@ 2016-01-04 21:49 ` kbuild test robot
2016-01-04 21:56 ` Aniroop Mathur
2016-01-04 22:00 ` kbuild test robot
1 sibling, 1 reply; 4+ messages in thread
From: kbuild test robot @ 2016-01-04 21:49 UTC (permalink / raw)
Cc: kbuild-all, dmitry.torokhov, benjamin.tissoires, peter.hutterer,
dh.herrmann, rydberg, aniroop.mathur, linux-input, linux-kernel,
Aniroop Mathur
[-- Attachment #1: Type: text/plain, Size: 1993 bytes --]
Hi Aniroop,
[auto build test ERROR on input/next]
[also build test ERROR on v4.4-rc8 next-20160104]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Aniroop-Mathur/Input-evdev-drop-partial-events-after-emptying-the-buffer/20160105-053003
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: avr32-atstk1006_defconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=avr32
All errors (new ones prefixed by >>):
drivers/input/evdev.c: In function '__evdev_queue_syn_dropped':
drivers/input/evdev.c:195: error: request for member 'time' in something not a structure or union
>> drivers/input/evdev.c:196: error: incompatible types in assignment
--
/kbuild/src/um/drivers/input/evdev.c: In function '__evdev_queue_syn_dropped':
/kbuild/src/um/drivers/input/evdev.c:195: error: request for member 'time' in something not a structure or union
>> /kbuild/src/um/drivers/input/evdev.c:196: error: incompatible types in assignment
vim +196 drivers/input/evdev.c
189 * ignore partial events and if last packet is fully stored, queue
190 * SYN_REPORT so that clients would not ignore next full packet.
191 */
192 if (prev_ev->type != EV_SYN && prev_ev->code != SYN_REPORT) {
193 client->drop_pevent = true;
194 } else if (prev_ev->type == EV_SYN && prev_ev->code == SYN_REPORT) {
> 195 prev_ev.time = ev.time;
> 196 client->buffer[client->head++] = prev_ev;
197 client->head &= mask;
198 client->packet_head = client->head;
199
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 13514 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [v3]Input: evdev - drop partial events after emptying the buffer
2016-01-04 21:49 ` kbuild test robot
@ 2016-01-04 21:56 ` Aniroop Mathur
0 siblings, 0 replies; 4+ messages in thread
From: Aniroop Mathur @ 2016-01-04 21:56 UTC (permalink / raw)
To: kbuild test robot
Cc: Aniroop Mathur, kbuild-all, Dmitry Torokhov, Benjamin Tissoires,
Peter Hutterer, David Herrmann, Henrik Rydberg,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Just now sent v4. Please ignore v3.
On Tue, Jan 5, 2016 at 3:19 AM, kbuild test robot <lkp@intel.com> wrote:
> Hi Aniroop,
>
> [auto build test ERROR on input/next]
> [also build test ERROR on v4.4-rc8 next-20160104]
> [if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
>
> url: https://github.com/0day-ci/linux/commits/Aniroop-Mathur/Input-evdev-drop-partial-events-after-emptying-the-buffer/20160105-053003
> base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
> config: avr32-atstk1006_defconfig (attached as .config)
> reproduce:
> wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # save the attached .config to linux build tree
> make.cross ARCH=avr32
>
> All errors (new ones prefixed by >>):
>
> drivers/input/evdev.c: In function '__evdev_queue_syn_dropped':
> drivers/input/evdev.c:195: error: request for member 'time' in something not a structure or union
>>> drivers/input/evdev.c:196: error: incompatible types in assignment
> --
> /kbuild/src/um/drivers/input/evdev.c: In function '__evdev_queue_syn_dropped':
> /kbuild/src/um/drivers/input/evdev.c:195: error: request for member 'time' in something not a structure or union
>>> /kbuild/src/um/drivers/input/evdev.c:196: error: incompatible types in assignment
>
> vim +196 drivers/input/evdev.c
>
> 189 * ignore partial events and if last packet is fully stored, queue
> 190 * SYN_REPORT so that clients would not ignore next full packet.
> 191 */
> 192 if (prev_ev->type != EV_SYN && prev_ev->code != SYN_REPORT) {
> 193 client->drop_pevent = true;
> 194 } else if (prev_ev->type == EV_SYN && prev_ev->code == SYN_REPORT) {
> > 195 prev_ev.time = ev.time;
> > 196 client->buffer[client->head++] = prev_ev;
> 197 client->head &= mask;
> 198 client->packet_head = client->head;
> 199
>
> ---
> 0-DAY kernel test infrastructure Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all Intel Corporation
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] [v3]Input: evdev - drop partial events after emptying the buffer
2016-01-04 21:30 [PATCH] [v3]Input: evdev - drop partial events after emptying the buffer Aniroop Mathur
2016-01-04 21:49 ` kbuild test robot
@ 2016-01-04 22:00 ` kbuild test robot
1 sibling, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2016-01-04 22:00 UTC (permalink / raw)
Cc: kbuild-all, dmitry.torokhov, benjamin.tissoires, peter.hutterer,
dh.herrmann, rydberg, aniroop.mathur, linux-input, linux-kernel,
Aniroop Mathur
[-- Attachment #1: Type: text/plain, Size: 1760 bytes --]
Hi Aniroop,
[auto build test ERROR on input/next]
[also build test ERROR on v4.4-rc8 next-20160104]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Aniroop-Mathur/Input-evdev-drop-partial-events-after-emptying-the-buffer/20160105-053003
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
config: i386-randconfig-x005-01040616 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
drivers/input/evdev.c: In function '__evdev_queue_syn_dropped':
>> drivers/input/evdev.c:195:10: error: request for member 'time' in something not a structure or union
prev_ev.time = ev.time;
^
>> drivers/input/evdev.c:196:34: error: incompatible types when assigning to type 'struct input_event' from type 'struct input_event *'
client->buffer[client->head++] = prev_ev;
^
vim +/time +195 drivers/input/evdev.c
189 * ignore partial events and if last packet is fully stored, queue
190 * SYN_REPORT so that clients would not ignore next full packet.
191 */
192 if (prev_ev->type != EV_SYN && prev_ev->code != SYN_REPORT) {
193 client->drop_pevent = true;
194 } else if (prev_ev->type == EV_SYN && prev_ev->code == SYN_REPORT) {
> 195 prev_ev.time = ev.time;
> 196 client->buffer[client->head++] = prev_ev;
197 client->head &= mask;
198 client->packet_head = client->head;
199
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 25174 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-01-04 22:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-04 21:30 [PATCH] [v3]Input: evdev - drop partial events after emptying the buffer Aniroop Mathur
2016-01-04 21:49 ` kbuild test robot
2016-01-04 21:56 ` Aniroop Mathur
2016-01-04 22:00 ` kbuild test robot
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).