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

tty: remove buffer special casing

Long long ago a 4K kmalloc allocated two pages so the tty layer used the
page allocator, except on some machines where the page size was huge. This was
removed from the core tty layer with the tty buffer re-implementation but not
from tty_audit or the n_tty ldisc.

Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alan Cox and committed by
Linus Torvalds
c481c707 aba6593b

+4 -17
+2 -9
drivers/char/n_tty.c
··· 76 76 static inline unsigned char *alloc_buf(void) 77 77 { 78 78 gfp_t prio = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; 79 - 80 - if (PAGE_SIZE != N_TTY_BUF_SIZE) 81 - return kmalloc(N_TTY_BUF_SIZE, prio); 82 - else 83 - return (unsigned char *)__get_free_page(prio); 79 + return kmalloc(N_TTY_BUF_SIZE, prio); 84 80 } 85 81 86 82 static inline void free_buf(unsigned char *buf) 87 83 { 88 - if (PAGE_SIZE != N_TTY_BUF_SIZE) 89 - kfree(buf); 90 - else 91 - free_page((unsigned long) buf); 84 + kfree(buf); 92 85 } 93 86 94 87 static inline int tty_put_user(struct tty_struct *tty, unsigned char x,
+2 -8
drivers/char/tty_audit.c
··· 29 29 buf = kmalloc(sizeof(*buf), GFP_KERNEL); 30 30 if (!buf) 31 31 goto err; 32 - if (PAGE_SIZE != N_TTY_BUF_SIZE) 33 - buf->data = kmalloc(N_TTY_BUF_SIZE, GFP_KERNEL); 34 - else 35 - buf->data = (unsigned char *)__get_free_page(GFP_KERNEL); 32 + buf->data = kmalloc(N_TTY_BUF_SIZE, GFP_KERNEL); 36 33 if (!buf->data) 37 34 goto err_buf; 38 35 atomic_set(&buf->count, 1); ··· 49 52 static void tty_audit_buf_free(struct tty_audit_buf *buf) 50 53 { 51 54 WARN_ON(buf->valid != 0); 52 - if (PAGE_SIZE != N_TTY_BUF_SIZE) 53 - kfree(buf->data); 54 - else 55 - free_page((unsigned long)buf->data); 55 + kfree(buf->data); 56 56 kfree(buf); 57 57 } 58 58