[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.2.01.0910130721530.3438@localhost.localdomain>
Date: Tue, 13 Oct 2009 07:39:31 -0700 (PDT)
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Alan Cox <alan@...rguk.ukuu.org.uk>
cc: Nix <nix@...eri.org.uk>, Paul Fulghum <paulkf@...rogate.com>,
"Justin P. Mattock" <justinmattock@...il.com>,
"Rafael J. Wysocki" <rjw@...k.pl>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Kernel Testers List <kernel-testers@...r.kernel.org>,
Boyan <btanastasov@...oo.co.uk>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
Ed Tomlinson <edt@....ca>,
Frédéric L. W. Meunier
<fredlwm@...il.com>, OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>
Subject: Re: [Bug #14388] keyboard under X with 2.6.31
On Tue, 13 Oct 2009, Alan Cox wrote:
>
> There is a simple reason the locking is sufficient. If you can call the
> function from two places at once in your serial driver at the same you've
> scrambled the data order so you've already lost.
Umm. No, Alan.
You also can race with:
- whoever is _reading_ the buffer, and due to memory ordering may see the
update to the buffer length _before_ it actually sees the data itself.
That spinlock does all the memory ordering too.
- scrambling the data order with two writers is certainly less annoying
than potentially screwing up ->used entirely, and having the memcpy's
overflow the buffer. Both writers may have decided that there is enough
room for each one - but that does not mean that there is enough room
for _both_.
Now, I do agree that generally there should be locking at a higher level,
and you should never see two concurrent writers. But even if the locking
is only for reading, the old locking is simply _wrong_.
> > pointless: they then call tty_insert_flip_string(), which means that the
> > tty_buffer_request_room() call was totally redundant ]
>
> It's a performance tweak. With a 3G USB modem or similar device running
> at 20Mbits or more being able to generate one allocation per chunk
> received for DMA made a measurable performance difference on some
> platforms.
Have you even _read_ the code, Alan?
It's not a f*cking performance tweak, and you're ludicrous to claim it is.
It's pointless, and it's making the code _slower_ rather than faster.
Lookie here, Alan - the common sequence is crap like this:
tty_buffer_request_room(tty, buf->size);
tty_insert_flip_string(tty, buf->base, buf->size);
and anybody who claims that is a "performance tweak" doesn't know what the
hell he is talking about.
Look again.
The first thing that tty_insert_flup_string() does is to re-do the same
tty_buffer_request_room() call.
Performance tweak? No. Most of them are stupid, pointless, and worthless.
Many of them do it for a single character too.
Not all, no. One or two seem to do one tty_buffer_request_room() call, and
then some one-byte-at-a-time thing, but quite frankly, those are sure as
hell not going to push lots of data quickly that way either.
Maybe there is some driver where there's a point to it, but from a quick
grep, I couldn't find any.
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists