Re: [2.6.33-rc7] tty: page allocation failure (fromtty_buffer_request_room)

From: Alan Cox
Date: Fri Feb 12 2010 - 19:09:40 EST


> > You are doing some output on console, for example write to a device /dev/tty.
> > Inside tty_buffer_request_room I found, that kmalloc was called and interrupts
> > are disabled. That means, memory can not swap out - if no free page is
> > available. tty_buffer_request_room checks for NULL returns. So, it assumes,
> > that kmalloc can fail. Unless they have forgotten to set __GFP_NOWARN. - Or it
> > is a defective design, and kmalloc should not called inside a spin_lock.


Neither - if we can't allocate a small buffer (and I would expect this to
be a small buffer of under one page) then we lose data and while we
continue to run it indicates a very serious low memory condition that the
user really ought to be aware of.

If anything what this says is that tty_insert_flip_string and friends
ought to be tweaked to do

nt tty_insert_flip_string(struct tty_struct *tty, const unsigned char
*chars, size_t size)
{
int copied = 0;
do {
int want = min(size - copied, TTY_BUFFER_PAGE);
int space = tty_buffer_request_room(tty, want);
...


where TTY_BUFFER_PAGE is defined to be the size to request so the buffer
will fit in one page of memory.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/