Commit 849696bb authored by Andrew Morton's avatar Andrew Morton Committed by Jaroslav Kysela

[PATCH] speed up read_zero() for !CONFIG_MMU

The read_zero() implementation for !CONFIG_MMU was very inefficient.
This sped-up version has been tested and acked by Greg Ungerer.
parent 48a789a9
...@@ -475,17 +475,19 @@ static int mmap_zero(struct file * file, struct vm_area_struct * vma) ...@@ -475,17 +475,19 @@ static int mmap_zero(struct file * file, struct vm_area_struct * vma)
static ssize_t read_zero(struct file * file, char * buf, static ssize_t read_zero(struct file * file, char * buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
unsigned long left; size_t todo = count;
if (!count) while (todo) {
return 0; size_t chunk = todo;
for (left = count; left > 0; left--, buf++) { if (chunk > 4096)
if (put_user(0, buf)) chunk = 4096; /* Just for latency reasons */
if (clear_user(buf, chunk))
return -EFAULT; return -EFAULT;
buf += chunk;
todo -= chunk;
cond_resched(); cond_resched();
} }
return count; return count;
} }
......
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