From: Andrew Morton <akpm@osdl.org>

- Add missing fields to /proc/vmstat

- Revert /proc/meminfo changes.  This info can be accessed from /proc/vmstat.

- Tidy ifdeffing in handle_pte_fault()

- coding style tweaks

Cc: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 fs/proc/proc_misc.c        |   16 +++-------------
 include/linux/page-flags.h |    3 +--
 mm/memory.c                |   38 ++++++++++++++++++++++++--------------
 mm/page_alloc.c            |    6 ++++++
 4 files changed, 34 insertions(+), 29 deletions(-)

diff -puN fs/proc/proc_misc.c~page-fault-patches-optional-page_lock-acquisition-in-tidy fs/proc/proc_misc.c
--- devel/fs/proc/proc_misc.c~page-fault-patches-optional-page_lock-acquisition-in-tidy	2005-07-30 00:43:53.000000000 -0700
+++ devel-akpm/fs/proc/proc_misc.c	2005-07-30 00:43:53.000000000 -0700
@@ -129,7 +129,7 @@ static int meminfo_read_proc(char *page,
 	struct vmalloc_info vmi;
 	long cached;
 
-	get_full_page_state(&ps);
+	get_page_state(&ps);
 	get_zone_counts(&active, &inactive, &free);
 
 /*
@@ -174,12 +174,7 @@ static int meminfo_read_proc(char *page,
 		"PageTables:   %8lu kB\n"
 		"VmallocTotal: %8lu kB\n"
 		"VmallocUsed:  %8lu kB\n"
-		"VmallocChunk: %8lu kB\n"
-		"Spurious page faults    : %8lu\n"
-		"cmpxchg fail flag update: %8lu\n"
-		"cmpxchg fail COW reuse  : %8lu\n"
-		"cmpxchg fail anon read  : %8lu\n"
-		"cmpxchg fail anon write : %8lu\n",
+		"VmallocChunk: %8lu kB\n",
 		K(i.totalram),
 		K(i.freeram),
 		K(i.bufferram),
@@ -202,12 +197,7 @@ static int meminfo_read_proc(char *page,
 		K(ps.nr_page_table_pages),
 		(unsigned long)VMALLOC_TOTAL >> 10,
 		vmi.used >> 10,
-		vmi.largest_chunk >> 10,
-		ps.spurious_page_faults,
-		ps.cmpxchg_fail_flag_update,
-		ps.cmpxchg_fail_flag_reuse,
-		ps.cmpxchg_fail_anon_read,
-		ps.cmpxchg_fail_anon_write
+		vmi.largest_chunk >> 10
 		);
 
 		len += hugetlb_report_meminfo(page + len);
diff -puN include/linux/page-flags.h~page-fault-patches-optional-page_lock-acquisition-in-tidy include/linux/page-flags.h
--- devel/include/linux/page-flags.h~page-fault-patches-optional-page_lock-acquisition-in-tidy	2005-07-30 00:43:53.000000000 -0700
+++ devel-akpm/include/linux/page-flags.h	2005-07-30 00:43:53.000000000 -0700
@@ -131,11 +131,10 @@ struct page_state {
 
 	unsigned long pgrotated;	/* pages rotated to tail of the LRU */
 	unsigned long nr_bounce;	/* pages for bounce buffers */
-
-	/* Page fault related counters */
 	unsigned long spurious_page_faults;	/* Faults with no ops */
 	unsigned long cmpxchg_fail_flag_update;	/* cmpxchg failures for pte flag update */
 	unsigned long cmpxchg_fail_flag_reuse;	/* cmpxchg failures when cow reuse of pte */
+
 	unsigned long cmpxchg_fail_anon_read;	/* cmpxchg failures on anonymous read */
 	unsigned long cmpxchg_fail_anon_write;	/* cmpxchg failures on anonymous write */
 };
diff -puN mm/memory.c~page-fault-patches-optional-page_lock-acquisition-in-tidy mm/memory.c
--- devel/mm/memory.c~page-fault-patches-optional-page_lock-acquisition-in-tidy	2005-07-30 00:43:53.000000000 -0700
+++ devel-akpm/mm/memory.c	2005-07-30 00:43:53.000000000 -0700
@@ -1748,7 +1748,8 @@ do_anonymous_page(struct mm_struct *mm, 
 	if (unlikely(!write_access)) {
 
 		/* Read-only mapping of ZERO_PAGE. */
-		entry = pte_wrprotect(mk_pte(ZERO_PAGE(addr), vma->vm_page_prot));
+		entry = pte_wrprotect(mk_pte(ZERO_PAGE(addr),
+					vma->vm_page_prot));
 
 		/*
 		 * If the cmpxchg fails then another cpu may
@@ -1757,8 +1758,9 @@ do_anonymous_page(struct mm_struct *mm, 
 		if (ptep_cmpxchg(mm, addr, page_table, orig_entry, entry)) {
 			update_mmu_cache(vma, addr, entry);
 			lazy_mmu_prot_update(entry);
-		} else
+		} else {
 			inc_page_state(cmpxchg_fail_anon_read);
+		}
 		pte_unmap(page_table);
 		goto minor_fault;
 	}
@@ -1999,32 +2001,39 @@ static inline int handle_pte_fault(struc
 		 * not present allowing atomic insertion of ptes.
 		 */
 		if (pte_none(entry))
-			return do_no_page(mm, vma, address, write_access, pte, pmd, entry);
+			return do_no_page(mm, vma, address, write_access,
+						pte, pmd, entry);
 		if (pte_file(entry))
-			return do_file_page(mm, vma, address, write_access, pte, pmd, entry);
-		return do_swap_page(mm, vma, address, pte, pmd, entry, write_access);
+			return do_file_page(mm, vma, address, write_access,
+						pte, pmd, entry);
+		return do_swap_page(mm, vma, address, pte, pmd,
+						entry, write_access);
 	}
 
 	new_entry = pte_mkyoung(entry);
 	if (write_access) {
 		if (!pte_write(entry)) {
 #ifdef CONFIG_ATOMIC_TABLE_OPS
-			/* do_wp_page modifies a pte. We can add a pte without the
-			 * page_table_lock but not modify a pte since a cmpxchg
-			 * does not allow us to verify that the page was not
-			 * changed under us. So acquire the page table lock.
+			/*
+			 * do_wp_page modifies a pte. We can add a pte without
+			 * the page_table_lock but not modify a pte since a
+			 * cmpxchg does not allow us to verify that the page
+			 * was not changed under us. So acquire the page table
+			 * lock.
 			 */
 			spin_lock(&mm->page_table_lock);
 			if (pte_same(entry, *pte))
-#endif
-				return do_wp_page(mm, vma, address, pte, pmd, entry);
-#ifdef CONFIG_ATOMIC_TABLE_OPS
-			/* pte was changed under us. Another processor may have
+				return do_wp_page(mm, vma, address, pte,
+							pmd, entry);
+			/*
+			 * pte was changed under us. Another processor may have
 			 * done what we needed to do.
 			 */
 			pte_unmap(pte);
 			spin_unlock(&mm->page_table_lock);
 			return VM_FAULT_MINOR;
+#else
+			return do_wp_page(mm, vma, address, pte, pmd, entry);
 #endif
 		}
 		entry = pte_mkdirty(entry);
@@ -2039,8 +2048,9 @@ static inline int handle_pte_fault(struc
 		flush_tlb_page(vma, address);
 		update_mmu_cache(vma, address, entry);
 		lazy_mmu_prot_update(entry);
-	} else
+	} else {
 		inc_page_state(cmpxchg_fail_flag_update);
+	}
 
 	pte_unmap(pte);
 	page_table_atomic_stop(mm);
diff -puN mm/page_alloc.c~page-fault-patches-optional-page_lock-acquisition-in-tidy mm/page_alloc.c
--- devel/mm/page_alloc.c~page-fault-patches-optional-page_lock-acquisition-in-tidy	2005-07-30 00:43:53.000000000 -0700
+++ devel-akpm/mm/page_alloc.c	2005-07-30 00:43:53.000000000 -0700
@@ -2210,6 +2210,12 @@ static char *vmstat_text[] = {
 
 	"pgrotated",
 	"nr_bounce",
+	"spurious_page_faults",
+	"cmpxchg_fail_flag_update",
+	"cmpxchg_fail_flag_reuse",
+
+	"cmpxchg_fail_anon_read",
+	"cmpxchg_fail_anon_write",
 };
 
 static void *vmstat_start(struct seq_file *m, loff_t *pos)
_