public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vojtech Pavlik <vojtech@suse.cz>
To: Sau Dan Lee <danlee@informatik.uni-freiburg.de>
Cc: Giuseppe Bilotta <bilotta78@hotpop.com>,
	linux-kernel@vger.kernel.org,
	Tuukka Toivonen <tuukkat@ee.oulu.fi>
Subject: Re: keyboard problem with 2.6.6
Date: Sun, 30 May 2004 12:19:14 +0200	[thread overview]
Message-ID: <20040530101914.GA1226@ucw.cz> (raw)
In-Reply-To: <xb7y8nab65d.fsf@savona.informatik.uni-freiburg.de>

On Sun, May 30, 2004 at 11:45:02AM +0200, Sau Dan Lee wrote:
> >>>>> "Vojtech" == Vojtech Pavlik <vojtech@suse.cz> writes:
> 
>     >> What I hate is only the part where mouse/keyboard drivers are
>     >> now in kernel space.  The translation of raw byte streams into
>     >> input events should be better done in userland.  One important
>     >> argument is: userland program may be swapped out.  Kernel
>     >> modules can't.
> 
>     Vojtech> Well, keyboard support was always in the kernel - you
>     Vojtech> need it there, because you need the keyboard always to
>     Vojtech> work
> 
> No.   That's not the  case (at  least beginning  from 2.6.6).   If you
> assume the keyboard is always there, they why make 'i8042' and 'atkbd'
> modules?
> 
> I like the fact that 2.6.6 no longer assumes that the keyboard must be
> there (and thanks  for your work to modularize  those pieces of code).
> This assumption doesn't hold,  for instance, in some embedded systems,
> which has  no keyboard  controller and can  only be controlled  via an
> RS232 port.

I meant that keyboard handling was never done in userspace. Of course it
is modular now, but that still counts as 'in the kernel'. ;) On embedded
systems, or when you have an USB keyboard, you can leave the whole PS/2
stuff out.

But still, if you have a working keyboard, the handling is done in the
kernel, and you can do a register dump, process listing, etc, even when
the system is crashed. You wouldn't be able to do that if the processing
of the byte stream was done in an userspace program.

>     Vojtech>  - even in the case of a crash, when all userspace
>     Vojtech> programs may already be dead.
> 
> There are still RS232 ports and the network.

Sure. How convenient it is to have to find an RS232 cable, when your
keyboard is just next to you on the table? I don't advocate _always_
having keyboard support, just the fact that if you have it, that it
should work regardless of system state.

>     Vojtech> That's also the reason why keyboard processing is done in
>     Vojtech> the interrupt context - even if nothing else works in the
>     Vojtech> kernel but interrupts, you still can get a register dump
>     Vojtech> for example, using the keyboard.
> 
> Can't SysRq  be triggered from a  program now, in addition  to using a
> keyboard?

It can. But if your userspace is dead, you cannot run that program. And
that's usually when you need sysrq.

>     Vojtech> Regarding mice: Yes, PS/2 and serial mice can be in
>     Vojtech> userspace, as is proven by reality. With USB mice it's
>     Vojtech> much tougher, and busmice and many other mice on non-PC
>     Vojtech> platforms need their drivers to be in the kernel, as they
>     Vojtech> access hardware directly and not via a byte stream
>     Vojtech> abstraction.
> 
> A kernel driver can turn it into a byte stream.

Sure. You can turn anything into a byte stream. But you already have to
process it in the kernel. There is no point in creating a device
specific bytestream and then disassembling it again in userspace only to
again create a generic format bytestream.

>  What does 'evdev' do,
> then?  Isn't  it  turning  those  events into  a  stream  of  "struct
> input_event"s?  That's a byte stream,  although you have to be careful
> to call read()/write() with a suitable size parameter.

Sure. But it's a generic one, that's able to cover _any_ device. And all
with the same format. That's why it's much better to export this to
userspace than the raw mouse data.

>     Vojtech> For serial mice, doing the processing in the kernel
>     Vojtech> brought us a 4 times better response rate for the
>     Vojtech> mousesystems kind of them and 2 times better for
>     Vojtech> microsoft mice. That actually makes both useable.
> 
> Is that  "improvement" significant for  1200 baud devices?  Even  on a
> 386DX-33?

Yes. Very much significant. Exactly because they're running at 1200
baud, you need get most of that little data they're sending to you. With
the new kernel driver, MouseSystems mice are actually nice to work with,
and not the pain they used to be. Even on 386SX-16.

>     Vojtech> And here are the two main reasons to keep mouse and
>     Vojtech> keyboard processing in the kernel:
> 
>     Vojtech> 1) Latency. The time it takes from keypress to giving it
>     Vojtech> to an application. Adding intermediate programs inbetween
>     Vojtech> doesn't help this at all.
> 
> Well... I believe 'pppd' is more sensitive to latencies problems (when
> talking to the RS232 port) than a mouse driver.  Why don't you migrate
> pppd into the kernel, then?   Remember, we have 56kbps modems (at 2400
> baud?).  I believe pppd should be kernelized before the mouse drivers.
> Making pppd a kernel module  also eliminates the current need for pppd
> to  communicate  with  a  kernel  driver to  create  the  ppp0,  ppp1,
> ... interfaces, too.

Surprise: PPP handling _is_ in the kernel. pppd does the initial
handshaking, and then switches the kernel line discipline, and then the
characters are going straight from the port to the kernel, and then
they're packetized and appear in the ppp0 interface. No pppd interaction
inbetween at all.

> Actually, as long as the low-level byte-stream module has a big enough
> buffer to handle the bursts of  data, and the userland driver is quick
> enough (on average) to consume the incoming data, what's the problem?

The problem is that you get jerky mouse movement. It stays for a while
on one place (when the buffer is filled), and then jumps elsewhere (when
it's processed). You need to do the processing byte by byte, as they
arrive.

>     Vojtech> 2) Unified interface. If an application (X, QtEmbedded,
>     Vojtech> SDL ...) needs to talk to a mouse or keyboard, it can use
>     Vojtech> the event interface instead of knowing a gazillion of
>     Vojtech> different protocols. 
> 
> I've demonstrated how a unified interface can be done using my atkbd.c
> and psmouse userland drivers.  These useland drivers translate the raw
> byte stream,  convert them into "struct input_event",  and then refeed
> them into the input system.  It works!

Yes, it does. Because it uses the _kernel_ input system to do the
interfacing work. But I don't see any benefit of having to go to
userspace and back again into the kernel.

>     Vojtech> This is a kernel job.
> 
> No.  This can be done in userspace.  We should keep the kernel code to
> a  minimal size.   Most other  "drivers" in  Linux has  a  kernel half
> (a.k.a. bottom-half?) and  a userland half.  The kernel  half is to do
> what  must  be  done  in   kernel:  creating  a  device,  reacting  to
> interrupts, putting  the stream  of data in  a buffer.   Mostly simple
> tasks that  must be  done quickly.  The  userland half, which  is more
> computation-intensitive,  gets   the  data  and   do  the  complicated
> processing.

Care to name any? Everything from raw SCSI handling to presenting files
to processes is done in the kernel. Everything from talking to Ethernet
HW to processing IP and TCP and routing and firewalling to presenting
read()able sockets to applications is done in the kernel. No userspace
support there.

> If you  think those  are kernel  jobs, then you  have an  argument for
> implementing  Ghostscript completely  in kernel,  so that  we  can cat
> mythesis.ps  >  /dev/psprinter,  whether   or  not  my  printer  is  a
> Postscript  printer, and  whether or  not it  is connected  locally or
> remotely, right?

Good argument. There are limits of what makes sense to do in the kernel.
Ghostscript is easier to do in userspace, because it needs access to
fonts, has a nontrivial configuration, isn't time critical, etc. Good
candidate for userspace.

-- 
Vojtech Pavlik
SuSE Labs, SuSE CR

  reply	other threads:[~2004-05-30 10:25 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-07 20:55 [PATCH] SERIO_USERDEV: direct userspace access to mouse/keyboard psaux serial ports Tuukka Toivonen
2004-05-08  2:35 ` Andrew Morton
2004-05-25 20:16   ` keyboard problem with 2.6.6 Chris Osicki
2004-05-26  7:54     ` Sau Dan Lee
2004-05-28 13:33       ` Giuseppe Bilotta
2004-05-28 17:37       ` Sau Dan Lee
2004-05-29 13:12         ` Vojtech Pavlik
2004-05-30  9:45           ` Sau Dan Lee
2004-05-30 10:19             ` Vojtech Pavlik [this message]
2004-05-30 11:25               ` Sau Dan Lee
2004-05-30 11:40                 ` Brad Campbell
2004-05-30 12:01                 ` Oliver Neukum
2004-05-30 12:22                   ` Sau Dan Lee
2004-05-30 12:32                     ` Oliver Neukum
2004-05-30 12:16                 ` Vojtech Pavlik
2004-05-30 12:40                   ` Sau Dan Lee
2004-05-30 12:52                     ` Vojtech Pavlik
2004-05-30 16:09                     ` Stefan Seyfried
2004-05-30 17:26                     ` Dmitry Torokhov
2004-06-04 13:58                 ` Pavel Machek
2004-06-04 18:17                   ` Horst von Brand
2004-06-04 18:37                     ` Valdis.Kletnieks
2004-06-04 19:33                       ` Denis Vlasenko
2004-06-04 19:50                         ` Valdis.Kletnieks
2004-06-04 20:48                           ` Denis Vlasenko
2004-06-04 18:39                     ` Pavel Machek
2004-06-04 18:46                       ` Sau Dan Lee
2004-06-04 19:09                         ` Pavel Machek
2004-06-06  9:01                           ` Sau Dan Lee
2004-06-06 16:40                             ` Pavel Machek
2004-05-28 19:39       ` 2.6.* useland replacements of the atkbd and psmouse modules Sau Dan Lee
2004-05-28 19:57       ` keyboard problem with 2.6.6 Andries Brouwer
2004-06-01  8:21       ` BUG: atkbd.c keyboard driver bug [Was: keyboard problem with 2.6.6] Sau Dan Lee
2004-06-01  9:13       ` BUG FIX: " Sau Dan Lee
     [not found]       ` <200406010904.i5194pSo010367@fire-2.osdl.org>
2004-06-01  9:44         ` Sau Dan Lee
2004-06-01  9:55           ` Vojtech Pavlik
2004-06-01 10:03             ` Sau Dan Lee
2004-06-01 12:42             ` Giuseppe Bilotta
2004-05-28 19:41     ` keyboard problem with 2.6.6 Andries Brouwer
2004-05-28 20:10       ` Andries Brouwer
     [not found]       ` <20040528214620.GA2352@gucio>
2004-05-29 13:23         ` Andries Brouwer
2004-05-29 13:46           ` Vojtech Pavlik
2004-05-29 14:30             ` Andries Brouwer
2004-05-29 14:41               ` Vojtech Pavlik
2004-05-29 15:12             ` Giuseppe Bilotta
     [not found] <xb7oenxyqly.fsf@savona.informatik.uni-freiburg.de>
     [not found] ` <200406071551.i57Fpl89023562@turing-police.cc.vt.edu>
     [not found]   ` <xb7zn7fwdia.fsf@savona.informatik.uni-freiburg.de>
     [not found]     ` <200406071636.i57Gafh7024942@turing-police.cc.vt.edu>
     [not found]       ` <xb7r7sqwncc.fsf@savona.informatik.uni-freiburg.de>
     [not found]         ` <200406081502.i58F2gF3013622@turing-police.cc.vt.edu>
2004-06-09  8:17           ` Sau Dan Lee
2004-06-09 16:56             ` Valdis.Kletnieks
2004-06-09 17:12               ` Sau Dan Lee
2004-06-09 17:29                 ` Valdis.Kletnieks
  -- strict thread matches above, loose matches on Subject: below --
2004-06-06  9:43 Sau Dan Lee
2004-06-06  9:37 Sau Dan Lee
2004-06-06 11:29 ` Martin Schlemmer
2004-06-06 12:07 ` Vojtech Pavlik
2004-06-06 15:09 ` Dmitry Torokhov
2004-06-06 16:13   ` Sau Dan Lee
     [not found]   ` <200406061929.45169.vda@port.imtp.ilyichevsk.odessa.ua>
     [not found]     ` <200406061140.35929.dtor_core@ameritech.net>
2004-06-06 16:51       ` Sau Dan Lee
     [not found] <xb7ekp2b34y.fsf@savona.informatik.uni-freiburg.de>
     [not found] ` <20040530112138.GC1377@ucw.cz>
2004-05-30 11:43   ` Sau Dan Lee
2004-05-30 12:45     ` Vojtech Pavlik
2004-05-30 13:25       ` Sau Dan Lee
2004-05-30 10:57 Sau Dan Lee
2004-06-01 11:31 ` Pavel Machek
2004-06-01 14:06   ` John Bradford
2004-05-30 10:45 Sau Dan Lee
2004-05-30 11:20 ` Vojtech Pavlik
2004-05-30 10:39 Sau Dan Lee
2004-05-30 11:18 ` Vojtech Pavlik
2004-05-30 11:40   ` Sau Dan Lee
2004-05-30 11:53     ` Russell King
2004-05-30 12:43     ` Vojtech Pavlik
2004-05-30 13:25       ` Sau Dan Lee
2004-06-01 21:01         ` jsimmons
2004-06-01 21:12           ` Valdis.Kletnieks
2004-05-30 13:54       ` Eduard Bloch
2004-05-30 14:03         ` Vojtech Pavlik
2004-06-01 21:03           ` jsimmons
2004-06-04 14:11     ` Pavel Machek
2004-05-28 13:59 Tuukka Toivonen
2004-05-29 13:14 ` Vojtech Pavlik
2004-06-04 14:54   ` Tuukka Toivonen
2004-06-04 16:06     ` Vojtech Pavlik
     [not found] <MPG.1b2111558bc2d299896a2@news.gmane.org.suse.lists.linux.kernel>
     [not found] ` <20040525201616.GE6512@gucio.suse.lists.linux.kernel>
     [not found]   ` <xb7hdu3fwsj.fsf@savona.informatik.uni-freiburg.de.suse.lists.linux.kernel>
     [not found]     ` <xb7aczscv0q.fsf@savona.informatik.uni-freiburg.de.suse.lists.linux.kernel>
     [not found]       ` <20040529131233.GA6185@ucw.cz.suse.lists.linux.kernel>
     [not found]         ` <xb7y8nab65d.fsf@savona.informatik.uni-freiburg.de.suse.lists.linux.kernel>
     [not found]           ` <20040530101914.GA1226@ucw.cz.suse.lists.linux.kernel>
     [not found]             ` <xb765aeb1i3.fsf@savona.informatik.uni-freiburg.de.suse.lists.linux.kernel>
     [not found]               ` <20040530121606.GA1496@ucw.cz.suse.lists.linux.kernel>

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=20040530101914.GA1226@ucw.cz \
    --to=vojtech@suse.cz \
    --cc=bilotta78@hotpop.com \
    --cc=danlee@informatik.uni-freiburg.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tuukkat@ee.oulu.fi \
    /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