patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / arch / sparc64 / mm / init.c
index a5518c2..043861f 100644 (file)
@@ -152,9 +152,9 @@ __inline__ void flush_dcache_page_impl(struct page *page)
 #define dcache_dirty_cpu(page) \
        (((page)->flags >> 24) & (NR_CPUS - 1UL))
 
-static __inline__ void set_dcache_dirty(struct page *page)
+static __inline__ void set_dcache_dirty(struct page *page, int this_cpu)
 {
-       unsigned long mask = smp_processor_id();
+       unsigned long mask = this_cpu;
        unsigned long non_cpu_bits = ~((NR_CPUS - 1UL) << 24UL);
        mask = (mask << 24) | (1UL << PG_dcache_dirty);
        __asm__ __volatile__("1:\n\t"
@@ -206,16 +206,19 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t p
            (page = pfn_to_page(pfn), page_mapping(page)) &&
            ((pg_flags = page->flags) & (1UL << PG_dcache_dirty))) {
                int cpu = ((pg_flags >> 24) & (NR_CPUS - 1UL));
+               int this_cpu = get_cpu();
 
                /* This is just to optimize away some function calls
                 * in the SMP case.
                 */
-               if (cpu == smp_processor_id())
+               if (cpu == this_cpu)
                        flush_dcache_page_impl(page);
                else
                        smp_flush_dcache_page_impl(page, cpu);
 
                clear_dcache_dirty_cpu(page, cpu);
+
+               put_cpu();
        }
        if (get_thread_fault_code())
                __update_mmu_cache(vma->vm_mm->context & TAG_CONTEXT_BITS,
@@ -227,14 +230,15 @@ void flush_dcache_page(struct page *page)
        struct address_space *mapping = page_mapping(page);
        int dirty = test_bit(PG_dcache_dirty, &page->flags);
        int dirty_cpu = dcache_dirty_cpu(page);
+       int this_cpu = get_cpu();
 
        if (mapping && !mapping_mapped(mapping)) {
                if (dirty) {
-                       if (dirty_cpu == smp_processor_id())
-                               return;
+                       if (dirty_cpu == this_cpu)
+                               goto out;
                        smp_flush_dcache_page_impl(page, dirty_cpu);
                }
-               set_dcache_dirty(page);
+               set_dcache_dirty(page, this_cpu);
        } else {
                /* We could delay the flush for the !page_mapping
                 * case too.  But that case is for exec env/arg
@@ -243,6 +247,9 @@ void flush_dcache_page(struct page *page)
                 */
                flush_dcache_page_impl(page);
        }
+
+out:
+       put_cpu();
 }
 
 /* When shared+writable mmaps of files go away, we lose all dirty
@@ -1582,7 +1589,7 @@ void __init paging_init(void)
  * prom_set_traptable() call, and OBP is allocating a scratchpad
  * for saving client program register state etc.
  */
-void __init sort_memlist(struct linux_mlist_p1275 *thislist)
+static void __init sort_memlist(struct linux_mlist_p1275 *thislist)
 {
        int swapi = 0;
        int i, mitr;