提交 d9661adf 编写于 作者: A Alan Cox 提交者: Greg Kroah-Hartman

tty: Keep the default buffering to sub-page units

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: NAlan Cox <alan@linux.intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 4165fe4e
......@@ -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))
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册