svn commit: r205064 - in head/sys/mips: include mips

Neel Natu neel at FreeBSD.org
Fri Mar 12 03:49:18 UTC 2010


Author: neel
Date: Fri Mar 12 03:49:17 2010
New Revision: 205064
URL: http://svn.freebsd.org/changeset/base/205064

Log:
  Make the ddb command "show tlb" SMP friendly.
  
  It now accepts an argument to dump out the tlb of a particular cpu.

Modified:
  head/sys/mips/include/cpuregs.h
  head/sys/mips/include/pmap.h
  head/sys/mips/mips/mp_machdep.c
  head/sys/mips/mips/pmap.c

Modified: head/sys/mips/include/cpuregs.h
==============================================================================
--- head/sys/mips/include/cpuregs.h	Fri Mar 12 03:08:47 2010	(r205063)
+++ head/sys/mips/include/cpuregs.h	Fri Mar 12 03:49:17 2010	(r205064)
@@ -577,6 +577,8 @@
 
 #define MIPS_CONFIG1_TLBSZ_MASK		0x7E000000	/* bits 30..25 # tlb entries minus one */
 #define MIPS_CONFIG1_TLBSZ_SHIFT	25
+#define	MIPS_MAX_TLB_ENTRIES		64
+
 #define MIPS_CONFIG1_IS_MASK		0x01C00000	/* bits 24..22 icache sets per way */
 #define MIPS_CONFIG1_IS_SHIFT		22
 #define MIPS_CONFIG1_IL_MASK		0x00380000	/* bits 21..19 icache line size */

Modified: head/sys/mips/include/pmap.h
==============================================================================
--- head/sys/mips/include/pmap.h	Fri Mar 12 03:08:47 2010	(r205063)
+++ head/sys/mips/include/pmap.h	Fri Mar 12 03:49:17 2010	(r205064)
@@ -219,6 +219,11 @@ pmap_map_fpage(vm_paddr_t pa, struct fpa
     boolean_t check_unmaped);
 void pmap_unmap_fpage(vm_paddr_t pa, struct fpage *fp);
 
+/*
+ * Function to save TLB contents so that they may be inspected in the debugger.
+ */
+extern void pmap_save_tlb(void);
+
 #endif				/* _KERNEL */
 
 #endif				/* !LOCORE */

Modified: head/sys/mips/mips/mp_machdep.c
==============================================================================
--- head/sys/mips/mips/mp_machdep.c	Fri Mar 12 03:08:47 2010	(r205063)
+++ head/sys/mips/mips/mp_machdep.c	Fri Mar 12 03:49:17 2010	(r205064)
@@ -128,6 +128,7 @@ mips_ipi_handler(void *arg)
 			CTR0(KTR_SMP, "IPI_STOP or IPI_STOP_HARD");
 
 			savectx(&stoppcbs[cpu]);
+			pmap_save_tlb();
 
 			/* Indicate we are stopped */
 			atomic_set_int(&stopped_cpus, cpumask);

Modified: head/sys/mips/mips/pmap.c
==============================================================================
--- head/sys/mips/mips/pmap.c	Fri Mar 12 03:08:47 2010	(r205063)
+++ head/sys/mips/mips/pmap.c	Fri Mar 12 03:49:17 2010	(r205064)
@@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/msgbuf.h>
 #include <sys/vmmeter.h>
 #include <sys/mman.h>
+#include <sys/smp.h>
 
 #include <vm/vm.h>
 #include <vm/vm_param.h>
@@ -149,6 +150,8 @@ unsigned pmap_max_asid;		/* max ASID sup
 
 vm_offset_t kernel_vm_end;
 
+static struct tlb tlbstash[MAXCPU][MIPS_MAX_TLB_ENTRIES];
+
 static void pmap_asid_alloc(pmap_t pmap);
 
 /*
@@ -3284,17 +3287,6 @@ db_dump_tlb(int first, int last)
 	}
 }
 
-#ifdef DDB
-#include <sys/kernel.h>
-#include <ddb/ddb.h>
-
-DB_SHOW_COMMAND(tlb, ddb_dump_tlb)
-{
-	db_dump_tlb(0, num_tlbentries - 1);
-}
-
-#endif
-
 /*
  *	Routine:	pmap_kextract
  *	Function:
@@ -3377,3 +3369,61 @@ pmap_flush_pvcache(vm_page_t m)
 		}
 	}
 }
+
+void
+pmap_save_tlb(void)
+{
+	int tlbno, cpu;
+
+	cpu = PCPU_GET(cpuid);
+
+	for (tlbno = 0; tlbno < num_tlbentries; ++tlbno)
+		MachTLBRead(tlbno, &tlbstash[cpu][tlbno]);
+}
+
+#ifdef DDB
+#include <ddb/ddb.h>
+
+DB_SHOW_COMMAND(tlb, ddb_dump_tlb)
+{
+	int cpu, tlbno;
+	struct tlb *tlb;
+
+	if (have_addr)
+		cpu = ((addr >> 4) % 16) * 10 + (addr % 16);
+	else
+		cpu = PCPU_GET(cpuid);
+
+	if (cpu < 0 || cpu >= mp_ncpus) {
+		db_printf("Invalid CPU %d\n", cpu);
+		return;
+	} else
+		db_printf("CPU %d:\n", cpu);
+
+	if (cpu == PCPU_GET(cpuid))
+		pmap_save_tlb();
+
+	for (tlbno = 0; tlbno < num_tlbentries; ++tlbno) {
+		tlb = &tlbstash[cpu][tlbno];
+		if (tlb->tlb_lo0 & PTE_V || tlb->tlb_lo1 & PTE_V) {
+			printf("TLB %2d vad 0x%0lx ",
+				tlbno, (long)(tlb->tlb_hi & 0xffffff00));
+		} else {
+			printf("TLB*%2d vad 0x%0lx ",
+				tlbno, (long)(tlb->tlb_hi & 0xffffff00));
+		}
+		printf("0=0x%0lx ", pfn_to_vad((long)tlb->tlb_lo0));
+		printf("%c", tlb->tlb_lo0 & PTE_V ? 'V' : '-');
+		printf("%c", tlb->tlb_lo0 & PTE_M ? 'M' : '-');
+		printf("%c", tlb->tlb_lo0 & PTE_G ? 'G' : '-');
+		printf(" atr %x ", (tlb->tlb_lo0 >> 3) & 7);
+		printf("1=0x%0lx ", pfn_to_vad((long)tlb->tlb_lo1));
+		printf("%c", tlb->tlb_lo1 & PTE_V ? 'V' : '-');
+		printf("%c", tlb->tlb_lo1 & PTE_M ? 'M' : '-');
+		printf("%c", tlb->tlb_lo1 & PTE_G ? 'G' : '-');
+		printf(" atr %x ", (tlb->tlb_lo1 >> 3) & 7);
+		printf(" sz=%x pid=%x\n", tlb->tlb_mask,
+		       (tlb->tlb_hi & 0x000000ff));
+	}
+}
+#endif	/* DDB */


More information about the svn-src-all mailing list