From: Jason Wessel <jason.wessel@windriver.com>
To: Andrei Warkentin <andreiw@vmware.com>
Cc: <kgdb-bugreport@lists.sourceforge.net>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] KDB: Fix usability issues relating to the 'enter' key.
Date: Sun, 26 Feb 2012 07:58:37 -0600 [thread overview]
Message-ID: <4F4A3A8D.7030700@windriver.com> (raw)
In-Reply-To: <4F4A2F60.1060700@windriver.com>
[-- Attachment #1: Type: text/plain, Size: 2784 bytes --]
On 02/26/2012 07:10 AM, Jason Wessel wrote:
> On 02/17/2012 05:52 PM, Andrei Warkentin wrote:
>> This fixes the following problems:
>> 1) Typematic-repeat of 'enter' gives warning message.
>> 2) Use of 'keypad enter' gives warning message.
>> 3) Lag on the order of seconds between "break" and "make" when
>> expecting the enter "break" code. Seen under virtualized
>> environments such as VMware ESX.
>>
>> Explanations:
>> 1) Holding down 'enter' will not set a repeating sequence
>> of 0x1c(make)-0x9c(make), but a repeating sequence
>> of make codes, followed by one break code when the key
>> is released. Thus, it's wrong to expect the break code
>> after seeing the 'enter' make code.
>> 2) Keypad enter generates different make/break, namely
>> 0xe0 0x1c and 0xe0 0x9c. The 'generic' logic handles
>> the 0xe0 escape already, but the special 'enter' logic
>> always expects '0x9c' and not '0xe0 0x9c', so you get
>> a warning message, again.
>> 3) When expecting the 'enter' break code, the code polls
>> the status register in a tight loop, like so -
>> > while ((inb(KBD_STATUS_REG) & KBD_STAT_OBF) == 0);
>>
>> However, it really should do something like -
>> > while ((inb(KBD_STATUS_REG) & KBD_STAT_OBF) == 0)
>> > cpu_relax(); /* pause */
>>
>> Basically, it's a common optimization to have a fast
>> path for accessing often accessed and slow changing I/O
>> in a virtualized environment. The tight spinning in KDB
>> seems to run against the logic by ESX keyboard virtualization
>> code to detect when the fast path or the slow path should
>> be used to satisfy the keyboard status read, leading to
>> multi-second timeouts before the 'real' status comes through.
>> Without knowing ESX internals, it's hard to say if this is
>> an ESX bug or not, but letting the VM be explicitely descheduled
>> seems to resolve the problem. I've seen something similar with
>> shared MMIO buffers with VMs on Hyper-V.
>>
>> Anyway, given (3), (2) and (1), we might as well blow away the
>> entire special casing for 'enter'. The break codes will already
>> be handled correctly, and we get rid of the bugs with repeat
>> enters and keypad enter key. And of course, there is no
>> need to AND with 0x7f when checking for 'enter', because we'll
>> never ever get to this code with a break code (checked for much
>> earlier).
>>
>> I tried to figure out the history behind the 'enter' key special
>> casing code, and it seems to have come from whatever the original
>> KDB patch was. Perhaps someone can chime in.
>>
>
Andrei, if you agree with the attached patch, I'll put it in the merge queue. If you find problems we can go another iteration. :-)
Cheers,
Jason.
[-- Attachment #2: 0001-From-Andrei-Warkentin-andreiw-vmware.com.patch --]
[-- Type: text/x-diff, Size: 3277 bytes --]
>From 797a228abdd5d560dddf217572d984b1dce97154 Mon Sep 17 00:00:00 2001
From: Jason Wessel <jason.wessel@windriver.com>
Date: Sun, 26 Feb 2012 07:49:16 -0600
Subject: [PATCH 1/1] From: Andrei Warkentin <andreiw@vmware.com> Subject:
[PATCH] KDB: Fix usability issues relating to the
'enter' key. Date: Sun Feb 26 07:51:01 CST 2012
This fixes the following problems:
1) Typematic-repeat of 'enter' gives warning message.
2) Use of 'keypad enter' gives warning message.
3) Lag on the order of seconds between "break" and "make" when
expecting the enter "break" code. Seen under virtualized
environments such as VMware ESX.
Explanations:
1) Holding down 'enter' will not set a repeating sequence
of 0x1c(make)-0x9c(make), but a repeating sequence
of make codes, followed by one break code when the key
is released. Thus, it's wrong to expect the break code
after seeing the 'enter' make code.
2) Keypad enter generates different make/break, namely
0xe0 0x1c and 0xe0 0x9c. The 'generic' logic handles
the 0xe0 escape already, but the special 'enter' logic
always expects '0x9c' and not '0xe0 0x9c', so you get
a warning message, again.
3) When expecting the 'enter' break code, the code polls
the status register in a tight loop, like so -
> while ((inb(KBD_STATUS_REG) & KBD_STAT_OBF) == 0);
However, it really should do something like -
> while ((inb(KBD_STATUS_REG) & KBD_STAT_OBF) == 0)
> cpu_relax(); /* pause */
Basically, it's a common optimization to have a fast
path for accessing often accessed and slow changing I/O
in a virtualized environment. The tight spinning in KDB
seems to run against the logic by ESX keyboard virtualization
code to detect when the fast path or the slow path should
be used to satisfy the keyboard status read, leading to
multi-second timeouts before the 'real' status comes through.
Without knowing ESX internals, it's hard to say if this is
an ESX bug or not, but letting the VM be explicitely descheduled
seems to resolve the problem. I've seen something similar with
shared MMIO buffers with VMs on Hyper-V.
Signed-off-by: Andrei Warkentin <andreiw@vmware.com>
[jason.wessel@windriver.com: use cpu_relax() and remove expected msg]
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
---
kernel/debug/kdb/kdb_keyboard.c | 11 ++---------
1 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/kernel/debug/kdb/kdb_keyboard.c b/kernel/debug/kdb/kdb_keyboard.c
index 4bca634..0351d0c 100644
--- a/kernel/debug/kdb/kdb_keyboard.c
+++ b/kernel/debug/kdb/kdb_keyboard.c
@@ -183,7 +183,7 @@ int kdb_get_kbd_char(void)
* enter key. All done. Absorb the release scancode.
*/
while ((inb(KBD_STATUS_REG) & KBD_STAT_OBF) == 0)
- ;
+ cpu_relax();
/*
* Fetch the scancode
@@ -192,18 +192,11 @@ int kdb_get_kbd_char(void)
scanstatus = inb(KBD_STATUS_REG);
while (scanstatus & KBD_STAT_MOUSE_OBF) {
+ cpu_relax();
scancode = inb(KBD_DATA_REG);
scanstatus = inb(KBD_STATUS_REG);
}
- if (scancode != 0x9c) {
- /*
- * Wasn't an enter-release, why not?
- */
- kdb_printf("kdb: expected enter got 0x%x status 0x%x\n",
- scancode, scanstatus);
- }
-
return 13;
}
--
1.7.5.4
next prev parent reply other threads:[~2012-02-26 13:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-17 23:52 [PATCH] KDB: Fix usability issues relating to the 'enter' key Andrei Warkentin
2012-02-25 3:20 ` Andrei Warkentin
2012-02-26 13:10 ` Jason Wessel
2012-02-26 13:58 ` Jason Wessel [this message]
2012-02-27 1:04 ` Andrei Warkentin
2012-02-27 22:50 ` Jason Wessel
2012-02-27 23:18 ` Andrei Warkentin
2012-02-27 23:28 ` Jason Wessel
2012-02-27 23:35 ` Andrei Warkentin
2012-02-28 1:27 ` Andrei Warkentin
2012-02-28 4:26 ` Andrei Warkentin
2012-02-28 13:53 ` Jason Wessel
2012-02-28 17:24 ` Andrei Warkentin
2012-02-27 1:01 ` Andrei Warkentin
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=4F4A3A8D.7030700@windriver.com \
--to=jason.wessel@windriver.com \
--cc=andreiw@vmware.com \
--cc=kgdb-bugreport@lists.sourceforge.net \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.