Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935390AbZJOVvQ (ORCPT ); Thu, 15 Oct 2009 17:51:16 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S935344AbZJOVvP (ORCPT ); Thu, 15 Oct 2009 17:51:15 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:44515 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935314AbZJOVvO (ORCPT ); Thu, 15 Oct 2009 17:51:14 -0400 Date: Thu, 15 Oct 2009 14:49:56 -0700 (PDT) From: Linus Torvalds X-X-Sender: torvalds@localhost.localdomain To: OGAWA Hirofumi cc: Alan Cox , Oleg Nesterov , Paul Fulghum , Boyan , "Rafael J. Wysocki" , Linux Kernel Mailing List , Kernel Testers List , Dmitry Torokhov , Ed Tomlinson Subject: Re: [Bug #14388] keyboard under X with 2.6.31 In-Reply-To: <87aazsh80x.fsf@devron.myhome.or.jp> Message-ID: References: <56acieJJ2fF.A.nEB.Hzl0KB@chimera> <87ljjgfcbu.fsf@spindle.srvr.nix> <4AD3F769.5080405@gmail.com> <4AD437F9.9020708@yahoo.co.uk> <4AD4DE4C.4010402@yahoo.co.uk> <4AD4F548.2030506@microgate.com> <1255478932.19056.24.camel@localhost.localdomain> <4AD51D6B.7010509@microgate.com> <20091014125846.1a3c8d40@lxorguk.ukuu.org.uk> <87aazsh80x.fsf@devron.myhome.or.jp> User-Agent: Alpine 2.01 (LFD 1184 2008-12-16) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1517 Lines: 54 On Fri, 16 Oct 2009, OGAWA Hirofumi wrote: > > I.e. the following or something, > > static inline int input_available_p(struct tty_struct *tty, int amt) > { > int try = 0; > > retry: > if (tty->icanon) { > if (tty->canon_data) > return 1; > } else if (tty->read_cnt >= (amt ? amt : 1)) > return 1; > > if (!checked) { > tty_flush_to_ldisc(tty); > try = 1; > goto retry; > } > > return 0; > } Yeah, we could do that. Especially if we ever see this in any profiles. I doubt we do, but.. > Sorry if I'm missing the point. Doesn't this have (possible) race with > schedule_delayed_work() (i.e. by tty writer)? > > cpu0 cpu1 > > if (del_timer(&dwork->timer)) { > // cpu0 doesn't set _PENDING > schedule_delayed_work() We don't care. We want to make sure that a writer that wrote the data strictly _before_ the reader is reading will always have the data show up. But if the writer is exactly concurrent with the reader, it's fine to not see the data. Because at that point, we will rely not on the tty buffers, but on the writer doing a tty_wakeup() to notify us that there is new data. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/