WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

[Xen-ia64-devel] [patch] sn2 global_tlb_purge implementation

To: Alex Williamson <alex.williamson@xxxxxx>
Subject: [Xen-ia64-devel] [patch] sn2 global_tlb_purge implementation
From: Jes Sorensen <jes@xxxxxxx>
Date: Tue, 19 Jun 2007 10:04:16 +0200
Cc: xen-ia64-devel <xen-ia64-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Tue, 19 Jun 2007 01:02:07 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.4 (X11/20060527)
Hi,

Here's a working global_tlb_purge for sn2 - it's sloooooooow and
inefficient, but at least it boots.

Cheers,
Jes
# HG changeset patch
# User jes@xxxxxxxxxxxxxxxx
# Date 1182239992 -7200
# Node ID 5f526ad0298b4ad9b4d6da5a89cbaaa1f37deb23
# Parent  f5c03237a7f0e136721291e390374826e9c97f4a
Very simple global tlb purge implementation for SN2. ptcga isn't
propagated between nodes so IPI a CPU on each node to get the job
done. This is _slow_ and inefficient, but it works for now.

Signed-off-by: Jes Sorensen <jes@xxxxxxx>

diff -r f5c03237a7f0 -r 5f526ad0298b xen/arch/ia64/linux-xen/sn/kernel/sn2_smp.c
--- a/xen/arch/ia64/linux-xen/sn/kernel/sn2_smp.c       Tue Jun 19 09:35:38 
2007 +0200
+++ b/xen/arch/ia64/linux-xen/sn/kernel/sn2_smp.c       Tue Jun 19 09:59:52 
2007 +0200
@@ -160,21 +160,97 @@ void sn_tlb_migrate_finish(struct mm_str
 // static cpumask_t mask_all = CPU_MASK_ALL;
 #endif
 
+static DEFINE_SPINLOCK(sn2_ptcg_lock);
+
+struct sn_flush_struct {
+       unsigned long start;
+       unsigned long end;
+       unsigned long nbits;
+};
+
+static void sn_flush_ptcga_cpu(void *ptr)
+{
+       struct sn_flush_struct *sn_flush = ptr;
+       unsigned long start, end, nbits;
+
+       start = sn_flush->start;
+       end = sn_flush->end;
+       nbits = sn_flush->nbits;
+
+       /*
+        * Contention me harder!!!
+        */
+       /* HW requires global serialization of ptc.ga.  */
+       spin_lock(&sn2_ptcg_lock);
+       {
+               do {
+                       /*
+                        * Flush ALAT entries also.
+                        */
+                       ia64_ptcga(start, (nbits<<2));
+                       ia64_srlz_i();
+                       start += (1UL << nbits);
+               } while (start < end);
+       }
+       spin_unlock(&sn2_ptcg_lock);
+}
+
+#ifdef XEN
 void
-#ifndef XEN
+sn2_global_tlb_purge(unsigned long start,
+                    unsigned long end, unsigned long nbits)
+{
+       nodemask_t nodes_flushed;
+       cpumask_t selected_cpus;
+       int cpu, cnode, i;
+       static DEFINE_SPINLOCK(sn2_ptcg_lock2);
+
+       nodes_clear(nodes_flushed);
+       cpus_clear(selected_cpus);
+
+       spin_lock(&sn2_ptcg_lock2);
+       node_set(cpu_to_node(smp_processor_id()), nodes_flushed);
+       i = 0;
+       for_each_cpu(cpu) {
+               cnode = cpu_to_node(cpu);
+               if (!node_isset(cnode, nodes_flushed)) {
+                       cpu_set(cpu, selected_cpus);
+                       i++;
+               }
+               node_set(cnode, nodes_flushed);
+       }
+
+       /* HW requires global serialization of ptc.ga.  */
+       spin_lock(&sn2_ptcg_lock);
+       {
+               do {
+                       /*
+                        * Flush ALAT entries also.
+                        */
+                       ia64_ptcga(start, (nbits<<2));
+                       ia64_srlz_i();
+                       start += (1UL << nbits);
+               } while (start < end);
+       }
+       spin_unlock(&sn2_ptcg_lock);
+
+       if (i) {
+               struct sn_flush_struct flush_data;
+               flush_data.start = start;
+               flush_data.end = end;
+               flush_data.nbits = nbits;
+               on_selected_cpus(selected_cpus, sn_flush_ptcga_cpu,
+                                &flush_data, 1, 1);
+       }
+       spin_unlock(&sn2_ptcg_lock2);
+}
+#else
+void
 sn2_global_tlb_purge(struct mm_struct *mm, unsigned long start,
-#else
-sn2_global_tlb_purge(unsigned long start,
-#endif
                     unsigned long end, unsigned long nbits)
 {
        int i, ibegin, shub1, cnode, mynasid, cpu, lcpu = 0, nasid;
-#ifndef XEN
        int mymm = (mm == current->active_mm && mm == current->mm);
-#else
-       // struct mm_struct *mm;
-       int mymm = 0;
-#endif
        int use_cpu_ptcga;
        volatile unsigned long *ptc0, *ptc1;
        unsigned long itc, itc2, flags, data0 = 0, data1 = 0, rr_value, old_rr 
= 0;
@@ -206,6 +282,7 @@ sn2_global_tlb_purge(unsigned long start
 
        preempt_disable();
 
+#ifndef XEN
        if (likely(i == 1 && lcpu == smp_processor_id() && mymm)) {
                do {
                        ia64_ptcl(start, nbits << 2);
@@ -217,13 +294,8 @@ sn2_global_tlb_purge(unsigned long start
                return;
        }
 
-#ifndef XEN
        if (atomic_read(&mm->mm_users) == 1 && mymm) {
-#ifndef XEN  /* I hate Xen! */
                flush_tlb_mm(mm);
-#else
-               flush_tlb_mask(mask_all);
-#endif
                __get_cpu_var(ptcstats).change_rid++;
                preempt_enable();
                return;
@@ -335,6 +407,7 @@ sn2_global_tlb_purge(unsigned long start
 
        preempt_enable();
 }
+#endif
 
 /*
  * sn2_ptc_deadlock_recovery
_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel