From: Alan Cox <alan@linux.intel.com>
To: greg@kroah.com, linux-serial@vger.kernel.org
Subject: [PATCH 1/6] tty: Keep the default buffering to sub-page units
Date: Thu, 18 Feb 2010 16:43:47 +0000 [thread overview]
Message-ID: <20100218164343.31856.8374.stgit@localhost.localdomain> (raw)
In-Reply-To: <20100218164104.31856.89546.stgit@localhost.localdomain>
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>
---
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;
next prev parent reply other threads:[~2010-02-18 17:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-18 16:43 [PATCH 0/6] Clean up tty buffering v page allocation Alan Cox
2010-02-18 16:43 ` Alan Cox [this message]
2010-02-18 16:43 ` [PATCH 2/6] tty: Add a function to insert a string of characters with the same flag Alan Cox
2010-02-18 16:44 ` [PATCH 3/6] tty: Prune uses of tty_request_room in the USB layer Alan Cox
2010-02-18 16:44 ` [PATCH 4/6] tty: sort out the request_room handling for whiteheat Alan Cox
2010-02-18 16:44 ` [PATCH 5/6] tty: kill request_room for USB ACM class Alan Cox
2010-02-18 16:44 ` [PATCH 6/6] tty: Fix up char drivers request_room usage Alan Cox
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=20100218164343.31856.8374.stgit@localhost.localdomain \
--to=alan@linux.intel.com \
--cc=greg@kroah.com \
--cc=linux-serial@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).