nfsd: optimise the starting of zero threads when none are running.
[safe/jmp/linux-2.6] / arch / sh / mm / pg-sh7705.c
index b052d0f..eaf2514 100644 (file)
@@ -7,11 +7,14 @@
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
+ *
  */
+
 #include <linux/init.h>
 #include <linux/mman.h>
 #include <linux/mm.h>
 #include <linux/threads.h>
+#include <linux/fs.h>
 #include <asm/addrspace.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
@@ -43,13 +46,13 @@ static inline void __flush_purge_virtual_region(void *p1, void *virt, int size)
 
                p = __pa(p1_begin);
 
-               ways = cpu_data->dcache.ways;
+               ways = current_cpu_data.dcache.ways;
                addr = CACHE_OC_ADDRESS_ARRAY;
 
                do {
                        unsigned long data;
 
-                       addr |= (v & cpu_data->dcache.entry_mask);
+                       addr |= (v & current_cpu_data.dcache.entry_mask);
 
                        data = ctrl_inl(addr);
                        if ((data & CACHE_PHYSADDR_MASK) ==
@@ -58,7 +61,7 @@ static inline void __flush_purge_virtual_region(void *p1, void *virt, int size)
                                ctrl_outl(data, addr);
                        }
 
-                       addr += cpu_data->dcache.way_incr;
+                       addr += current_cpu_data.dcache.way_incr;
                } while (--ways);
 
                p1_begin += L1_CACHE_BYTES;
@@ -74,6 +77,7 @@ void clear_user_page(void *to, unsigned long address, struct page *pg)
 {
        struct page *page = virt_to_page(to);
 
+       __set_bit(PG_mapped, &page->flags);
        if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) {
                clear_page(to);
                __flush_wback_region(to, PAGE_SIZE);
@@ -92,11 +96,12 @@ void clear_user_page(void *to, unsigned long address, struct page *pg)
  * @from: P1 address
  * @address: U0 address to be mapped
  */
-void copy_user_page(void *to, void *from, unsigned long address,
-                   struct page *pg)
+void copy_user_page(void *to, void *from, unsigned long address, struct page *pg)
 {
        struct page *page = virt_to_page(to);
 
+
+       __set_bit(PG_mapped, &page->flags);
        if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) {
                copy_page(to, from);
                __flush_wback_region(to, PAGE_SIZE);
@@ -108,3 +113,26 @@ void copy_user_page(void *to, void *from, unsigned long address,
                __flush_wback_region(to, PAGE_SIZE);
        }
 }
+
+/*
+ * For SH7705, we have our own implementation for ptep_get_and_clear
+ * Copied from pg-sh4.c
+ */
+pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
+{
+       pte_t pte = *ptep;
+
+       pte_clear(mm, addr, ptep);
+       if (!pte_not_present(pte)) {
+               unsigned long pfn = pte_pfn(pte);
+               if (pfn_valid(pfn)) {
+                       struct page *page = pfn_to_page(pfn);
+                       struct address_space *mapping = page_mapping(page);
+                       if (!mapping || !mapping_writably_mapped(mapping))
+                               __clear_bit(PG_mapped, &page->flags);
+               }
+       }
+
+       return pte;
+}
+