Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tty: tty_io: Switch to vmalloc() fallback in case of TTY_NO_WRITE_SPLIT

When TTY_NO_WRITE_SPLIT is set and 64 KiB chunks are used, allow
vmalloc() fallback. Supply __GFP_RETRY_MAYFAIL to make kmalloc()
preferable over vmalloc() since we may want a better performance.

Note, both current users copy data to another buffer anyway, so
the type of our allocation doesn't affect their expectations.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20211220133250.3070-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
d6d9d17a e822b497

+3 -10
+3 -6
drivers/tty/tty_io.c
··· 169 169 { 170 170 tty_ldisc_deinit(tty); 171 171 put_device(tty->dev); 172 - kfree(tty->write_buf); 172 + kvfree(tty->write_buf); 173 173 tty->magic = 0xDEADDEAD; 174 174 kfree(tty); 175 175 } ··· 986 986 * layer has problems with bigger chunks. It will 987 987 * claim to be able to handle more characters than 988 988 * it actually does. 989 - * 990 - * FIXME: This can probably go away now except that 64K chunks 991 - * are too likely to fail unless switched to vmalloc... 992 989 */ 993 990 chunk = 2048; 994 991 if (test_bit(TTY_NO_WRITE_SPLIT, &tty->flags)) ··· 1000 1003 if (chunk < 1024) 1001 1004 chunk = 1024; 1002 1005 1003 - buf_chunk = kmalloc(chunk, GFP_KERNEL); 1006 + buf_chunk = kvmalloc(chunk, GFP_KERNEL | __GFP_RETRY_MAYFAIL); 1004 1007 if (!buf_chunk) { 1005 1008 ret = -ENOMEM; 1006 1009 goto out; 1007 1010 } 1008 - kfree(tty->write_buf); 1011 + kvfree(tty->write_buf); 1009 1012 tty->write_cnt = chunk; 1010 1013 tty->write_buf = buf_chunk; 1011 1014 }
-4
drivers/usb/class/cdc-acm.c
··· 685 685 if (retval) 686 686 goto error_get_interface; 687 687 688 - /* 689 - * FIXME: Why do we need this? Allocating 64K of physically contiguous 690 - * memory is really nasty... 691 - */ 692 688 set_bit(TTY_NO_WRITE_SPLIT, &tty->flags); 693 689 acm->control->needs_remote_wakeup = 1; 694 690