mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mikael Pettersson <mikpe@it.uu.se>,
	"Rafael J. Wysocki" <rjw@sisk.pl>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Kernel Testers List <kernel-testers@vger.kernel.org>,
	Alan Cox <alan@linux.intel.com>, Greg KH <gregkh@suse.de>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [Bug #14015] pty regressed again, breaking expect and gcc's testsuite
Date: Sun, 06 Sep 2009 02:00:52 +0900	[thread overview]
Message-ID: <87pra55nsr.fsf@devron.myhome.or.jp> (raw)
In-Reply-To: <alpine.LFD.2.00.0909040910140.4537@eeepc.linux-foundation.org> (Linus Torvalds's message of "Fri, 4 Sep 2009 09:11:58 -1000 (HST)")

Linus Torvalds <torvalds@linux-foundation.org> writes:

> On Fri, 4 Sep 2009, Linus Torvalds wrote:
>> 
>> So I'm starting to suspect that the real bug is that we do that 
>> 'pty_space()' in pty_write() call at all. The _callers_ should already 
>> have done the write_room() check, and if somebody doesn't do it, then the 
>> tty buffering will eventually do a hard limit at the 65kB allocation mark.
>
> Ok, so the thought was right, but the patch was obviously not even 
> compiled, because the compiler points out that 'c' was not initialized.
>
> I'm sure you already figured the obvious meaning out, but here's a fixed 
> version.

This is not meaning to object to your patch though, I think we would be
good to fix pty_space(), not leaving as wrong. With fix it, I guess we
don't get strange behavior in the near of buffer limit.

Also, it seems the non-n_tty path doesn't use tty_write_room() check,
and instead it just try to write and check written bytes which returned
by tty->ops->write().

So, it will use the 64kb limit at least few paths, and I'm not sure
though, non-n_tty path (e.g. ppp) doesn't use tty_write_room() check
always. It may not be consistent if we removed pty_space() in pty_write().

So, it may not be issue though, I made this patch to fix
pty_space(). What do you think?

Well, anyway, I've tested your patch and this patch fixed the
gcc-testsuite on my machine.

Thanks.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>



Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---

diff -puN drivers/char/pty.c~tty-debug drivers/char/pty.c
--- linux-2.6/drivers/char/pty.c~tty-debug	2009-09-05 20:10:35.000000000 +0900
+++ linux-2.6-hirofumi/drivers/char/pty.c	2009-09-06 01:50:44.000000000 +0900
@@ -91,7 +91,7 @@ static void pty_unthrottle(struct tty_st
 
 static int pty_space(struct tty_struct *to)
 {
-	int n = 8192 - to->buf.memory_used;
+	int n = 8192 - tty_buffer_used(to);
 	if (n < 0)
 		return 0;
 	return n;
diff -puN drivers/char/tty_buffer.c~tty-debug drivers/char/tty_buffer.c
--- linux-2.6/drivers/char/tty_buffer.c~tty-debug	2009-09-05 21:02:48.000000000 +0900
+++ linux-2.6-hirofumi/drivers/char/tty_buffer.c	2009-09-05 21:08:47.000000000 +0900
@@ -231,6 +231,30 @@ int tty_buffer_request_room(struct tty_s
 EXPORT_SYMBOL_GPL(tty_buffer_request_room);
 
 /**
+ *	tty_buffer_used		-	return used tty buffer size
+ *	@tty: tty structure
+ *
+ *	Return used tty buffer size.
+ */
+size_t tty_buffer_used(struct tty_struct *tty)
+{
+	size_t size;
+	int left;
+	unsigned long flags;
+
+	spin_lock_irqsave(&tty->buf.lock, flags);
+	if (tty->buf.tail)
+		left = tty->buf.tail->size - tty->buf.tail->used;
+	else
+		left = 0;
+	size = tty->buf.memory_used - left;
+	spin_unlock_irqrestore(&tty->buf.lock, flags);
+
+	return size;
+}
+EXPORT_SYMBOL_GPL(tty_buffer_used);
+
+/**
  *	tty_insert_flip_string	-	Add characters to the tty buffer
  *	@tty: tty structure
  *	@chars: characters
diff -puN include/linux/tty_flip.h~tty-debug include/linux/tty_flip.h
--- linux-2.6/include/linux/tty_flip.h~tty-debug	2009-09-05 21:06:25.000000000 +0900
+++ linux-2.6-hirofumi/include/linux/tty_flip.h	2009-09-05 21:06:39.000000000 +0900
@@ -2,6 +2,7 @@
 #define _LINUX_TTY_FLIP_H
 
 extern int tty_buffer_request_room(struct tty_struct *tty, size_t size);
+extern size_t tty_buffer_used(struct tty_struct *tty);
 extern int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size);
 extern int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size);
 extern int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size);
_

  parent reply	other threads:[~2009-09-05 17:01 UTC|newest]

Thread overview: 120+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-25 20:00 2.6.31-rc7-git2: Reported regressions from 2.6.30 Rafael J. Wysocki
2009-08-25 20:00 ` [Bug #13645] NULL pointer dereference at (null) (level2_spare_pgt) Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13809] oprofile: possible circular locking dependency detected Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13740] X server crashes with 2.6.31-rc2 when options are changed Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13819] system freeze when switching to console Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13733] 2.6.31-rc2: irq 16: nobody cared Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13848] iwlwifi (4965) regression since 2.6.30 Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13836] suspend script fails, related to stdout? Rafael J. Wysocki
2009-08-26 11:10   ` Tomas M.
2009-08-26 20:56     ` Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13906] Huawei E169 GPRS connection causes Ooops Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13935] 2.6.31-rcX breaks Apple MightyMouse (Bluetooth version) Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13869] Radeon framebuffer (w/o KMS) corruption at boot Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13940] iwlagn and sky2 stopped working, ACPI-related Rafael J. Wysocki
2009-08-26  0:00   ` Ricardo Jorge da Fonseca Marques Ferreira
2009-08-26 20:58     ` Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13942] Troubles with AoE and uninitialized object Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13941] x86 Geode issue Rafael J. Wysocki
2009-08-25 23:37   ` Martin-Éric Racine
2009-08-26 20:59     ` Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13943] WARNING: at net/mac80211/mlme.c:2292 with ath5k Rafael J. Wysocki
2009-08-26  6:39   ` Fabio Comolli
2009-08-26 21:00     ` Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13950] Oops when USB Serial disconnected while in use Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13960] rtl8187 not connect to wifi Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13948] ath5k broken after suspend-to-ram Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13947] Libertas: Association request to the driver failed Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #13987] Received NMI interrupt at resume Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #14012] latest git fried my x86_64 imac Rafael J. Wysocki
2009-08-26  0:28   ` Justin P. Mattock
2009-08-26 21:06     ` Rafael J. Wysocki
2009-08-26 21:58       ` Justin P. Mattock
2009-08-27 18:01       ` Justin P. Mattock
2009-08-27 19:45         ` Rafael J. Wysocki
2009-08-27 20:47           ` Randy Dunlap
2009-08-27 21:01             ` Justin P. Mattock
2009-08-25 20:34 ` [Bug #14011] Kernel paging request failed in kmem_cache_alloc Rafael J. Wysocki
2009-08-26  6:17   ` Pekka Enberg
2009-08-26 14:01     ` Matthias Dahl
2009-08-26 14:59       ` Pekka Enberg
2009-08-26 15:08         ` Eric Paris
2009-08-26 21:03         ` Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #14015] pty regressed again, breaking expect and gcc's testsuite Rafael J. Wysocki
2009-08-27 19:54   ` Mikael Pettersson
2009-08-28 18:56     ` Rafael J. Wysocki
2009-08-28 20:23       ` Mikael Pettersson
2009-08-29 14:16         ` Mikael Pettersson
2009-08-29 19:01           ` Rafael J. Wysocki
2009-08-31 13:22             ` Mikael Pettersson
2009-09-01  1:34               ` Mikael Pettersson
2009-09-01 18:42                 ` Rafael J. Wysocki
2009-09-03  1:23                   ` Linus Torvalds
2009-09-03 11:29                     ` OGAWA Hirofumi
2009-09-03 21:00                       ` Mikael Pettersson
2009-09-04  0:01                       ` Linus Torvalds
2009-09-04  1:41                         ` OGAWA Hirofumi
2009-09-04  1:52                           ` Linus Torvalds
2009-09-04 15:28                         ` Alan Cox
2009-09-04 17:33                           ` Linus Torvalds
2009-09-03 20:27                     ` Mikael Pettersson
2009-09-04 13:23                     ` Mikael Pettersson
2009-09-04 17:30                       ` Linus Torvalds
2009-09-04 17:53                         ` Linus Torvalds
2009-09-04 17:55                           ` Linus Torvalds
2009-09-04 18:11                             ` Linus Torvalds
2009-09-04 19:11                               ` Linus Torvalds
2009-09-04 19:19                                 ` Linus Torvalds
2009-09-05 10:46                                   ` Mikael Pettersson
2009-09-05 20:29                                     ` Linus Torvalds
2009-09-05 22:42                                       ` Mikael Pettersson
2009-09-05 17:00                                 ` OGAWA Hirofumi [this message]
2009-09-05 18:06                                   ` Linus Torvalds
2009-09-05 18:56                                     ` OGAWA Hirofumi
2009-09-05 21:56                                   ` Alan Cox
2009-09-05 22:46                                     ` OGAWA Hirofumi
2009-09-04 21:12                               ` Alan Cox
2009-08-25 20:34 ` [Bug #14016] mm/ipw2200 regression Rafael J. Wysocki
2009-08-26  6:09   ` Pekka Enberg
2009-08-26  8:27     ` Johannes Weiner
2009-08-26  9:37       ` Mel Gorman
2009-08-26 14:44         ` Andrew Morton
2009-08-27  9:11           ` Zhu Yi
2009-08-27  9:45             ` Mel Gorman
2009-08-28  3:42           ` ipw2200: firmware DMA loading rework Zhu Yi
2009-08-30 12:37             ` Bartlomiej Zolnierkiewicz
2009-09-02 17:48               ` Bartlomiej Zolnierkiewicz
2009-09-02 18:02                 ` Luis R. Rodriguez
2009-09-02 18:26                   ` Bartlomiej Zolnierkiewicz
2009-09-19 13:25                     ` Bartlomiej Zolnierkiewicz
2009-09-21  8:58                       ` Mel Gorman
2009-09-21  9:59                         ` Bartlomiej Zolnierkiewicz
2009-09-21 10:08                           ` Mel Gorman
2009-09-21 10:46                             ` Bartlomiej Zolnierkiewicz
2009-09-21 10:56                               ` Pekka Enberg
2009-09-21 13:12                                 ` Bartlomiej Zolnierkiewicz
2009-09-21 13:37                                   ` Mel Gorman
2009-09-21 11:02                               ` Mel Gorman
2009-09-03 12:49                   ` Mel Gorman
2009-09-05 14:28                     ` Theodore Tso
2009-09-08 11:00                       ` Mel Gorman
2009-09-08 20:39                         ` Simon Kitching
2009-08-26  9:51       ` [Bug #14016] mm/ipw2200 regression Johannes Weiner
2009-08-25 20:34 ` [Bug #14013] hd don't show up Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #14017] _end symbol missing from Symbol.map Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #14018] kernel freezes, inotify problem Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #14030] Kernel NULL pointer dereference at 0000000000000008, pty-related Rafael J. Wysocki
2009-08-26  0:16   ` Linus Torvalds
2009-08-26 21:11     ` Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #14057] Strange network timeouts w/ e100 Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #14031] dvb_usb_af9015: Oops on hotplugging Rafael J. Wysocki
2009-08-25 23:57   ` Stefan Lippers-Hollmann
2009-08-26  0:03     ` Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #14060] oops: sysfs_remove_link and i915 Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #14058] Oops in fsnotify Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #14061] Crash due to buggy flat_phys_pkg_id Rafael J. Wysocki
2009-08-25 20:34 ` [Bug #14062] Failure to boot as xen guest Rafael J. Wysocki
2009-09-01 19:47   ` Jeremy Fitzhardinge
  -- strict thread matches above, loose matches on Subject: below --
2009-08-19 20:20 2.6.31-rc6-git5: Reported regressions from 2.6.30 Rafael J. Wysocki
2009-08-19 20:27 ` [Bug #14015] pty regressed again, breaking expect and gcc's testsuite Rafael J. Wysocki
2009-08-24 10:08   ` Mikael Pettersson
2009-08-24 18:32     ` Rafael J. Wysocki

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=87pra55nsr.fsf@devron.myhome.or.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=akpm@linux-foundation.org \
    --cc=alan@linux.intel.com \
    --cc=gregkh@suse.de \
    --cc=kernel-testers@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikpe@it.uu.se \
    --cc=rjw@sisk.pl \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome