From 873015a8c8de62f3c7ef5b3861d15b10ef7d438b Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Sat, 12 Apr 2003 12:58:42 -0700 Subject: [PATCH] [PATCH] /proc/interrupts allocates too much memory From: David Mosberger interrupts_open() can easily try to kmalloc() more memory than supported by kmalloc. E.g., with 16KB page size and NR_CPUS==64, it would try to allocate 147456 bytes. The workaround below is to allocate 4KB per 8 CPUs. Not really a solution, but the fundamental problem is that /proc/interrupts shouldn't use a fixed buffer size in the first place. I suppose another solution would be to use vmalloc() instead. It all feels like bandaids though. --- fs/proc/proc_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c index af764fe47c6c8..2d2f791eb598a 100644 --- a/fs/proc/proc_misc.c +++ b/fs/proc/proc_misc.c @@ -386,7 +386,7 @@ static int devices_read_proc(char *page, char **start, off_t off, extern int show_interrupts(struct seq_file *p, void *v); static int interrupts_open(struct inode *inode, struct file *file) { - unsigned size = PAGE_SIZE * (1 + NR_CPUS / 8); + unsigned size = 4096 * (1 + num_online_cpus() / 8); char *buf = kmalloc(size, GFP_KERNEL); struct seq_file *m; int res; -- 2.53.0