ia64/xen-unstable

view xen/arch/ia64/xen/flushtlb.c @ 16785:af3550f53874

[IA64] domheap: Don't pin xenheap down. Now it's unnecessary.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Thu Jan 17 12:05:43 2008 -0700 (2008-01-17)
parents d9f7f4f9c7ff
children 7dfc0a20fa59
line source
1 /******************************************************************************
2 * flushtlb.c
3 * based on x86 flushtlb.c
4 *
5 * Copyright (c) 2006 Isaku Yamahata <yamahata at valinux co jp>
6 * VA Linux Systems Japan K.K.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
24 #include <xen/sched.h>
25 #include <xen/softirq.h>
26 #include <asm/vcpu.h>
27 #include <asm/vhpt.h>
28 #include <asm/flushtlb.h>
30 /* Debug builds: Wrap frequently to stress-test the wrap logic. */
31 #ifdef NDEBUG
32 #define WRAP_MASK (0xFFFFFFFFU)
33 #else
34 #define WRAP_MASK (0x000003FFU)
35 #endif
37 volatile u32 tlbflush_clock = 1U; /* 1 greater than tlbflush_time. */
38 DEFINE_PER_CPU(volatile u32, tlbflush_time);
40 u32
41 tlbflush_clock_inc_and_return(void)
42 {
43 u32 t, t1, t2;
45 t = tlbflush_clock;
46 do {
47 t1 = t2 = t;
48 /* Clock wrapped: someone else is leading a global TLB shootdown. */
49 if (unlikely(t1 == 0))
50 return t2;
51 t2 = (t + 1) & WRAP_MASK;
52 t = ia64_cmpxchg(acq, &tlbflush_clock, t1, t2, sizeof(tlbflush_clock));
53 } while (unlikely(t != t1));
55 /* Clock wrapped: we will lead a global TLB shootdown. */
56 if (unlikely(t2 == 0))
57 raise_softirq(NEW_TLBFLUSH_CLOCK_PERIOD_SOFTIRQ);
59 return t2;
60 }
62 static void
63 tlbflush_clock_local_flush(void *unused)
64 {
65 local_vhpt_flush();
66 local_flush_tlb_all();
67 }
69 void
70 new_tlbflush_clock_period(void)
71 {
72 /* flush all vhpt of physical cpu and mTLB */
73 on_each_cpu(tlbflush_clock_local_flush, NULL, 1, 1);
75 /*
76 * if global TLB shootdown is finished, increment tlbflush_time
77 * atomic operation isn't necessary because we know that tlbflush_clock
78 * stays 0.
79 */
80 tlbflush_clock++;
81 }
83 /*
84 * Local variables:
85 * mode: C
86 * c-set-style: "BSD"
87 * c-basic-offset: 4
88 * tab-width: 4
89 * indent-tabs-mode: nil
90 * End:
91 */