Re: [Xen-ia64-devel] [PATCH] tlbflush_clock

2006-10-17 Thread Alex Williamson
On Mon, 2006-10-16 at 16:00 +0900, Isaku Yamahata wrote:
 tlbflush_clock
 This patch introduces xen compile time option, xen_ia64_tlbflush_clock=y.

   Applied.  This one and your other micro-optimization together reduced
my domU parallel kernel build by several seconds!  Nice work!  Thanks,

Alex

-- 
Alex Williamson HP Open Source  Linux Org.


___
Xen-ia64-devel mailing list
Xen-ia64-devel@lists.xensource.com
http://lists.xensource.com/xen-ia64-devel


[Xen-ia64-devel] [PATCH] tlbflush_clock

2006-10-16 Thread Isaku Yamahata

tlbflush_clock
This patch introduces xen compile time option, xen_ia64_tlbflush_clock=y.

-- 
yamahata
# HG changeset patch
# User [EMAIL PROTECTED]
# Date 1160981399 -32400
# Node ID 0b16566e129874f29708d8b5c40c8542649a7bcb
# Parent  fcd746cf4647e06b8e88e620c29610ba43e3ad7c
tlbflush_clock
This patch introduces xen compile time option, xen_ia64_tlbflush_clock=y.
PATCHNAME: tlbflush_clock

Signed-off-by: Isaku Yamahata [EMAIL PROTECTED]

diff -r fcd746cf4647 -r 0b16566e1298 xen/arch/ia64/Rules.mk
--- a/xen/arch/ia64/Rules.mkSat Oct 14 18:10:08 2006 -0600
+++ b/xen/arch/ia64/Rules.mkMon Oct 16 15:49:59 2006 +0900
@@ -9,6 +9,7 @@ xen_ia64_pervcpu_vhpt   ?= y
 xen_ia64_pervcpu_vhpt  ?= y
 xen_ia64_tlb_track ?= y
 xen_ia64_tlb_track_cnt ?= n
+xen_ia64_tlbflush_clock?= y
 
 ifneq ($(COMPILE_ARCH),$(TARGET_ARCH))
 CROSS_COMPILE ?= /usr/local/sp_env/v2.2.5/i686/bin/ia64-unknown-linux-
@@ -52,6 +53,9 @@ ifeq ($(xen_ia64_tlb_track_cnt),y)
 ifeq ($(xen_ia64_tlb_track_cnt),y)
 CFLAGS += -DCONFIG_TLB_TRACK_CNT
 endif
+ifeq ($(xen_ia64_tlbflush_clock),y)
+CFLAGS += -DCONFIG_XEN_IA64_TLBFLUSH_CLOCK
+endif
 ifeq ($(no_warns),y)
 CFLAGS += -Wa,--fatal-warnings -Werror -Wno-uninitialized
 endif
diff -r fcd746cf4647 -r 0b16566e1298 xen/arch/ia64/linux-xen/tlb.c
--- a/xen/arch/ia64/linux-xen/tlb.c Sat Oct 14 18:10:08 2006 -0600
+++ b/xen/arch/ia64/linux-xen/tlb.c Mon Oct 16 15:49:59 2006 +0900
@@ -111,7 +111,10 @@ local_flush_tlb_all (void)
 local_flush_tlb_all (void)
 {
unsigned long i, j, flags, count0, count1, stride0, stride1, addr;
-
+#if defined(XEN)
+   /* increment flush clock before mTLB flush */
+   u32 flush_time = tlbflush_clock_inc_and_return();
+#endif
addr= local_cpu_data-ptce_base;
count0  = local_cpu_data-ptce_count[0];
count1  = local_cpu_data-ptce_count[1];
@@ -128,6 +131,10 @@ local_flush_tlb_all (void)
}
local_irq_restore(flags);
ia64_srlz_i();  /* srlz.i implies srlz.d */
+#if defined(XEN)
+   /* update after mTLB flush. */
+   tlbflush_update_time(__get_cpu_var(tlbflush_time), flush_time);
+#endif
 }
 EXPORT_SYMBOL(local_flush_tlb_all);
 
diff -r fcd746cf4647 -r 0b16566e1298 xen/arch/ia64/xen/Makefile
--- a/xen/arch/ia64/xen/MakefileSat Oct 14 18:10:08 2006 -0600
+++ b/xen/arch/ia64/xen/MakefileMon Oct 16 15:49:59 2006 +0900
@@ -30,3 +30,4 @@ obj-y += xencomm.o
 
 obj-$(crash_debug) += gdbstub.o
 obj-$(xen_ia64_tlb_track) += tlb_track.o
+obj-$(xen_ia64_tlbflush_clock) += flushtlb.o
diff -r fcd746cf4647 -r 0b16566e1298 xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.cSat Oct 14 18:10:08 2006 -0600
+++ b/xen/arch/ia64/xen/domain.cMon Oct 16 15:49:59 2006 +0900
@@ -80,35 +80,52 @@ ia64_disable_vhpt_walker(void)
ia64_set_pta(VHPT_SIZE_LOG2  2);
 }
 
-static void flush_vtlb_for_context_switch(struct vcpu* vcpu)
+static void flush_vtlb_for_context_switch(struct vcpu* prev, struct vcpu* next)
 {
int cpu = smp_processor_id();
-   int last_vcpu_id = vcpu-domain-arch.last_vcpu[cpu].vcpu_id;
-   int last_processor = vcpu-arch.last_processor;
-
-   if (is_idle_domain(vcpu-domain))
+   int last_vcpu_id = next-domain-arch.last_vcpu[cpu].vcpu_id;
+   int last_processor = next-arch.last_processor;
+
+   if (!is_idle_domain(prev-domain))
+   
tlbflush_update_time(prev-domain-arch.last_vcpu[cpu].tlbflush_timestamp, 
tlbflush_current_time());
+
+   if (is_idle_domain(next-domain))
return;
-   
-   vcpu-domain-arch.last_vcpu[cpu].vcpu_id = vcpu-vcpu_id;
-   vcpu-arch.last_processor = cpu;
-
-   if ((last_vcpu_id != vcpu-vcpu_id 
+
+   next-domain-arch.last_vcpu[cpu].vcpu_id = next-vcpu_id;
+   next-arch.last_processor = cpu;
+   if ((last_vcpu_id != next-vcpu_id 
 last_vcpu_id != INVALID_VCPU_ID) ||
-   (last_vcpu_id == vcpu-vcpu_id 
+   (last_vcpu_id == next-vcpu_id 
 last_processor != cpu 
 last_processor != INVALID_PROCESSOR)) {
+#ifdef CONFIG_XEN_IA64_TLBFLUSH_CLOCK
+   u32 last_tlbflush_timestamp =
+   next-domain-arch.last_vcpu[cpu].tlbflush_timestamp;
+#endif
+   int vhpt_is_flushed = 0;
 
// if the vTLB implementation was changed,
// the followings must be updated either.
-   if (VMX_DOMAIN(vcpu)) {
+   if (VMX_DOMAIN(next)) {
// currently vTLB for vt-i domian is per vcpu.
// so any flushing isn't needed.
-   } else if (HAS_PERVCPU_VHPT(vcpu-domain)) {
+   } else if (HAS_PERVCPU_VHPT(next-domain)) {
// nothing to do
} else {
-   local_vhpt_flush();
-   }
-   local_flush_tlb_all();
+   if