[PATCH 33/36] tty: Keep the default buffering to sub-page units

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Greg Kroah-Hartman
Date: Tuesday, March 2, 2010 - 4:36 pm

From: Alan Cox <alan@linux.intel.com>

We allocate during interrupts so while our buffering is normally diced up
small anyway on some hardware at speed we can pressure the VM excessively
for page pairs. We don't really need big buffers to be linear so don't try
so hard.

In order to make this work well we will tidy up excess callers to request_room,
which cannot itself enforce this break up.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/char/tty_buffer.c |    6 ++++--
 include/linux/tty.h       |   10 ++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/char/tty_buffer.c b/drivers/char/tty_buffer.c
index 66fa4e1..f27c4d6 100644
--- a/drivers/char/tty_buffer.c
+++ b/drivers/char/tty_buffer.c
@@ -247,7 +247,8 @@ int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars,
 {
 	int copied = 0;
 	do {
-		int space = tty_buffer_request_room(tty, size - copied);
+		int goal = min(size - copied, TTY_BUFFER_PAGE);
+		int space = tty_buffer_request_room(tty, goal);
 		struct tty_buffer *tb = tty->buf.tail;
 		/* If there is no space then tb may be NULL */
 		if (unlikely(space == 0))
@@ -283,7 +284,8 @@ int tty_insert_flip_string_flags(struct tty_struct *tty,
 {
 	int copied = 0;
 	do {
-		int space = tty_buffer_request_room(tty, size - copied);
+		int goal = min(size - copied, TTY_BUFFER_PAGE);
+		int space = tty_buffer_request_room(tty, goal);
 		struct tty_buffer *tb = tty->buf.tail;
 		/* If there is no space then tb may be NULL */
 		if (unlikely(space == 0))
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 6abfcf5..d96e588 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -68,6 +68,16 @@ struct tty_buffer {
 	unsigned long data[0];
 };
 
+/*
+ * We default to dicing tty buffer allocations to this many characters
+ * in order to avoid multiple page allocations. We assume tty_buffer itself
+ * is under 256 bytes. See tty_buffer_find for the allocation logic this
+ * must match
+ */
+
+#define TTY_BUFFER_PAGE		((PAGE_SIZE  - 256) / 2)
+
+
 struct tty_bufhead {
 	struct delayed_work work;
 	spinlock_t lock;
-- 
1.7.0.1

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[GIT PATCH] TTY patches for 2.6.33-git, Greg KH, (Tue Mar 2, 4:09 pm)
[PATCH 01/36] serial: fit blackfin uart over sport driver ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 02/36] serial: copy UART properties of UPF_FIXED_TY ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 03/36] serial: 68328serial.c: remove BAUD_TABLE_SIZ ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 04/36] serial: atmel_serial: add poll_get_char and ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 05/36] serial: synclink_gt: dropped transmit data b ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 06/36] serial: 8250_pci: add support for MCS9865 / ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 07/36] serial: imx: fix NULL dereference Oops when ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 08/36] serial: add support for Korenix JetCard, Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 09/36] serial: fix test of unsigned, Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 10/36] serial: Char: cyclades, fix compiler warning, Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 11/36] serial: cyclades: allow overriding ISA defau ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 12/36] tty: char: mxser, remove unnecessary tty test, Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 13/36] serial: isicom.c: use pr_fmt and pr_&lt;level&gt;, Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 14/36] hvc_console: fix test on unsigned in hvc_con ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 15/36] tty: moxa: remove #ifdef MODULE completely., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 16/36] ip2: remove #ifdef MODULE from ip2main.c, Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 17/36] ip2: Add module parameter., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 18/36] tty: declare MODULE_FIRMWARE in various drivers, Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 19/36] Char: synclink, remove unnecessary checks, Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 20/36] serial: bfin_5xx: remove useless gpio handli ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 21/36] serial: bfin_5xx: need to disable DMA TX int ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 22/36] serial: bfin_5xx: kgdboc should accept gdb b ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 23/36] serial: bfin_5xx: pull in linux/io.h for ior ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 24/36] serial: bcm63xx_uart: don't use kfree() on n ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 25/36] serial: bcm63xx_uart: allow more than one ua ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 26/36] sdio_uart: Use kfifo instead of the messy ci ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 27/36] nozomi: Add tty_port usage, Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 28/36] nozomi: Fix mutex handling, Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 29/36] nozomi: Tidy up the PCI table, Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 30/36] serial: timberdale: Remove dependancies, Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 31/36] tty: Fix the ldisc hangup race, Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 32/36] tty: Fix up char drivers request_room usage, Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 33/36] tty: Keep the default buffering to sub-page ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 34/36] tty: Add a new VT mode which is like VT_PROC ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 35/36] jsm: removing the uart structure and filenam ..., Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)
[PATCH 36/36] jsm: fixing error if the driver fails to load, Greg Kroah-Hartman, (Tue Mar 2, 4:36 pm)