aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorWu Fengguang <fengguang.wu@intel.com>2009-06-16 18:32:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-16 22:47:36 -0400
commited7ce0f1022942301776f93159c981b09382ddea (patch)
treed81e98a13f6a10e6c258aa0f2bec990da40c5ac2 /fs
parent20a0307c0396c2edb651401d2f2db193dda2f3c9 (diff)
proc: kpagecount/kpageflags code cleanup
Move increments of pfn/out to bottom of the loop. Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Cc: Andi Kleen <andi@firstfloor.org> Acked-by: Matt Mackall <mpm@selenic.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/proc/page.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/fs/proc/page.c b/fs/proc/page.c
index 38dd88b7ce84..e73e911b7d0c 100644
--- a/fs/proc/page.c
+++ b/fs/proc/page.c
@@ -12,6 +12,7 @@
12 12
13#define KPMSIZE sizeof(u64) 13#define KPMSIZE sizeof(u64)
14#define KPMMASK (KPMSIZE - 1) 14#define KPMMASK (KPMSIZE - 1)
15
15/* /proc/kpagecount - an array exposing page counts 16/* /proc/kpagecount - an array exposing page counts
16 * 17 *
17 * Each entry is a u64 representing the corresponding 18 * Each entry is a u64 representing the corresponding
@@ -33,20 +34,22 @@ static ssize_t kpagecount_read(struct file *file, char __user *buf,
33 return -EINVAL; 34 return -EINVAL;
34 35
35 while (count > 0) { 36 while (count > 0) {
36 ppage = NULL;
37 if (pfn_valid(pfn)) 37 if (pfn_valid(pfn))
38 ppage = pfn_to_page(pfn); 38 ppage = pfn_to_page(pfn);
39 pfn++; 39 else
40 ppage = NULL;
40 if (!ppage) 41 if (!ppage)
41 pcount = 0; 42 pcount = 0;
42 else 43 else
43 pcount = page_mapcount(ppage); 44 pcount = page_mapcount(ppage);
44 45
45 if (put_user(pcount, out++)) { 46 if (put_user(pcount, out)) {
46 ret = -EFAULT; 47 ret = -EFAULT;
47 break; 48 break;
48 } 49 }
49 50
51 pfn++;
52 out++;
50 count -= KPMSIZE; 53 count -= KPMSIZE;
51 } 54 }
52 55
@@ -99,10 +102,10 @@ static ssize_t kpageflags_read(struct file *file, char __user *buf,
99 return -EINVAL; 102 return -EINVAL;
100 103
101 while (count > 0) { 104 while (count > 0) {
102 ppage = NULL;
103 if (pfn_valid(pfn)) 105 if (pfn_valid(pfn))
104 ppage = pfn_to_page(pfn); 106 ppage = pfn_to_page(pfn);
105 pfn++; 107 else
108 ppage = NULL;
106 if (!ppage) 109 if (!ppage)
107 kflags = 0; 110 kflags = 0;
108 else 111 else
@@ -120,11 +123,13 @@ static ssize_t kpageflags_read(struct file *file, char __user *buf,
120 kpf_copy_bit(kflags, KPF_RECLAIM, PG_reclaim) | 123 kpf_copy_bit(kflags, KPF_RECLAIM, PG_reclaim) |
121 kpf_copy_bit(kflags, KPF_BUDDY, PG_buddy); 124 kpf_copy_bit(kflags, KPF_BUDDY, PG_buddy);
122 125
123 if (put_user(uflags, out++)) { 126 if (put_user(uflags, out)) {
124 ret = -EFAULT; 127 ret = -EFAULT;
125 break; 128 break;
126 } 129 }
127 130
131 pfn++;
132 out++;
128 count -= KPMSIZE; 133 count -= KPMSIZE;
129 } 134 }
130 135