Commit 873015a8 authored by Andrew Morton's avatar Andrew Morton Committed by James Bottomley

[PATCH] /proc/interrupts allocates too much memory

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.
parent 830d6ef2
...@@ -386,7 +386,7 @@ static int devices_read_proc(char *page, char **start, off_t off, ...@@ -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); extern int show_interrupts(struct seq_file *p, void *v);
static int interrupts_open(struct inode *inode, struct file *file) 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); char *buf = kmalloc(size, GFP_KERNEL);
struct seq_file *m; struct seq_file *m;
int res; int res;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment