]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] /proc/interrupts allocates too much memory
authorAndrew Morton <akpm@digeo.com>
Sat, 12 Apr 2003 19:58:42 +0000 (12:58 -0700)
committerJames Bottomley <jejb@raven.il.steeleye.com>
Sat, 12 Apr 2003 19:58:42 +0000 (12:58 -0700)
From: David Mosberger <davidm@napali.hpl.hp.com>

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

index af764fe47c6c8ff0017a01f614e70c8bf5d77533..2d2f791eb598a4219b0665460e044feee11e2170 100644 (file)
@@ -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;