summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2013-12-09 09:23:52 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-09 11:09:24 -0800
commitacc0f67f307f52f7aec1cffdc40a786c15dd21d9 (patch)
tree30fe7356b60d42814b63c3de8ab00ac2bf9ed05d /include
parent9bbc3dca9d2212f900396ab9642c48279657a8c0 (diff)
downloadlinux-stable-acc0f67f307f52f7aec1cffdc40a786c15dd21d9.tar.gz
linux-stable-acc0f67f307f52f7aec1cffdc40a786c15dd21d9.tar.bz2
linux-stable-acc0f67f307f52f7aec1cffdc40a786c15dd21d9.zip
tty: Halve flip buffer GFP_ATOMIC memory consumption
tty flip buffers use GFP_ATOMIC allocations for received data which is to be processed by the line discipline. For each byte received, an extra byte is used to indicate the error status of that byte. Instead, if the received data is error-free, encode the entire buffer without status bytes. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/tty.h4
-rw-r--r--include/linux/tty_flip.h8
2 files changed, 10 insertions, 2 deletions
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 38fcc0574ba9..ad98b4376968 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -39,10 +39,14 @@ struct tty_buffer {
int size;
int commit;
int read;
+ int flags;
/* Data points here */
unsigned long data[0];
};
+/* Values for .flags field of tty_buffer */
+#define TTYB_NORMAL 1 /* buffer has no flags buffer */
+
static inline unsigned char *char_buf_ptr(struct tty_buffer *b, int ofs)
{
return ((unsigned char *)b->data) + ofs;
diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h
index 3f821e98af0f..c28dd523f96e 100644
--- a/include/linux/tty_flip.h
+++ b/include/linux/tty_flip.h
@@ -17,8 +17,12 @@ static inline int tty_insert_flip_char(struct tty_port *port,
unsigned char ch, char flag)
{
struct tty_buffer *tb = port->buf.tail;
- if (tb && tb->used < tb->size) {
- *flag_buf_ptr(tb, tb->used) = flag;
+ int change;
+
+ change = (tb->flags & TTYB_NORMAL) && (flag != TTY_NORMAL);
+ if (!change && tb->used < tb->size) {
+ if (~tb->flags & TTYB_NORMAL)
+ *flag_buf_ptr(tb, tb->used) = flag;
*char_buf_ptr(tb, tb->used++) = ch;
return 1;
}