Re: [Bug #14388] keyboard under X with 2.6.31

Linus Torvalds
2009-10-13T16:42:39Z

On Tue, 13 Oct 2009, Alan Cox wrote:
>
> I actually think you should make the tty_insert_flip_string internal
> length checking change because:
> - It makes the consistency of tty_insert_flip_string clearer to any
> future reader

It does that, although then you're still stuck looking at the (few)
tty_prepare_flip_*() calls that have that "racy feel".

But there aren't _that_ many callers, and it would probably be easier to
at least comment on those.

> - It's a very very mindbogglingly slight performance win

I suspect the loop is always done exactly once in practice, so I'm not
sure it will matter for performance one way or the other.

However, if we do hold the spinlock over the whole operation, what we
_could_ do is to then just combine it with tty_flip_buffer_push(), and do
that
tb->commit = tb->used;

part inside the lock. There's a number of people who effectively do

tty_tty_buffer_request_room(tty, size);
tty_insert_flip_string(tty, buffer, size);
tty_flip_buffer_push(tty);

and that just takes that silly spinlock _three_ times for no good reason.

> - It'll no doubt make you feel less grumpy ;)

Not likely. Grumpy is my baseline.

Linus