ia64/xen-unstable

changeset 3964:24703bde489b

bitkeeper revision 1.1243 (4225f63a_DvywTD0qmXez00zLLTU9Q)

manual merge

Signed-off-by: michael.fetterman@cl.cam.ac.uk
author rneugeba@wyvis.research.intel-research.net
date Wed Mar 02 17:22:02 2005 +0000 (2005-03-02)
parents cfee4c4a8ed6 180fe147132c
children 47e1cb8a3d38
files linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/system.h patches/linux-2.6.10/agpgart.patch tools/blktap/blktaplib.h tools/libxc/xc.h tools/libxutil/sxpr_parser.c tools/python/xen/lowlevel/xu/xu.c tools/xcs/xcs.c tools/xcs/xcs.h xen/arch/x86/mm.c xen/arch/x86/x86_32/asm-offsets.c xen/arch/x86/x86_32/entry.S xen/arch/x86/x86_64/asm-offsets.c xen/arch/x86/x86_64/entry.S xen/common/perfc.c xen/include/asm-x86/msr.h xen/include/asm-x86/x86_32/asm_defns.h xen/include/asm-x86/x86_64/asm_defns.h xen/include/xen/perfc.h xen/include/xen/perfc_defn.h
line diff
     1.1 --- a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/system.h	Wed Mar 02 17:18:39 2005 +0000
     1.2 +++ b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/system.h	Wed Mar 02 17:22:02 2005 +0000
     1.3 @@ -119,13 +119,8 @@ static inline unsigned long _get_base(ch
     1.4  
     1.5  #endif	/* __KERNEL__ */
     1.6  
     1.7 -static inline void wbinvd(void)
     1.8 -{
     1.9 -	mmu_update_t u;
    1.10 -	u.ptr = MMU_EXTENDED_COMMAND;
    1.11 -	u.val = MMUEXT_FLUSH_CACHE;
    1.12 -	(void)HYPERVISOR_mmu_update(&u, 1, NULL);
    1.13 -}
    1.14 +#define wbinvd() \
    1.15 +	__asm__ __volatile__ ("wbinvd": : :"memory");
    1.16  
    1.17  static inline unsigned long get_limit(unsigned long segment)
    1.18  {
     2.1 --- a/patches/linux-2.6.10/agpgart.patch	Wed Mar 02 17:18:39 2005 +0000
     2.2 +++ b/patches/linux-2.6.10/agpgart.patch	Wed Mar 02 17:22:02 2005 +0000
     2.3 @@ -350,22 +350,3 @@ diff -ur linux-2.6.9/drivers/char/agp/un
     2.4   
     2.5   	for (i = 0; i < num_entries; i++) {
     2.6   		agp_bridge->gatt_table[i] =
     2.7 -diff -ur linux-2.6.9/include/asm-i386/agp.h linux-2.6.9-new/include/asm-i386/agp.h
     2.8 ---- linux-2.6.9/include/asm-i386/agp.h	2004-10-18 22:53:06.000000000 +0100
     2.9 -+++ linux-2.6.9-new/include/asm-i386/agp.h	2004-11-28 19:32:03.000000000 +0000
    2.10 -@@ -3,6 +3,7 @@
    2.11 - 
    2.12 - #include <asm/pgtable.h>
    2.13 - #include <asm/cacheflush.h>
    2.14 -+#include <asm/system.h>
    2.15 - 
    2.16 - /* 
    2.17 -  * Functions to keep the agpgart mappings coherent with the MMU.
    2.18 -@@ -19,6 +20,6 @@
    2.19 - /* Could use CLFLUSH here if the cpu supports it. But then it would
    2.20 -    need to be called for each cacheline of the whole page so it may not be 
    2.21 -    worth it. Would need a page for it. */
    2.22 --#define flush_agp_cache() asm volatile("wbinvd":::"memory")
    2.23 -+#define flush_agp_cache() wbinvd()
    2.24 - 
    2.25 - #endif
     3.1 --- a/tools/blktap/blktaplib.h	Wed Mar 02 17:18:39 2005 +0000
     3.2 +++ b/tools/blktap/blktaplib.h	Wed Mar 02 17:22:02 2005 +0000
     3.3 @@ -10,22 +10,6 @@
     3.4  
     3.5  #include <stdint.h>
     3.6  
     3.7 -typedef uint8_t            u8;
     3.8 -typedef uint16_t           u16;
     3.9 -typedef uint32_t           u32;
    3.10 -typedef uint64_t           u64;
    3.11 -typedef int8_t             s8;
    3.12 -typedef int16_t            s16;
    3.13 -typedef int32_t            s32;
    3.14 -typedef int64_t            s64;
    3.15 -                                                                                
    3.16 -#if defined(__i386__)
    3.17 -#define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
    3.18 -#define wmb() __asm__ __volatile__ ( "" : : : "memory" )
    3.19 -#else
    3.20 -#error "Define barriers"
    3.21 -#endif
    3.22 -    
    3.23  #include <sys/user.h>
    3.24  #include <xen/xen.h>
    3.25  #include <xen/io/blkif.h>
     4.1 --- a/tools/libxc/xc.h	Wed Mar 02 17:18:39 2005 +0000
     4.2 +++ b/tools/libxc/xc.h	Wed Mar 02 17:22:02 2005 +0000
     4.3 @@ -25,9 +25,25 @@ typedef int64_t            s64;
     4.4  #include <xen/event_channel.h>
     4.5  #include <xen/sched_ctl.h>
     4.6  
     4.7 -/*\
     4.8 +
     4.9 +/*
    4.10 + *  DEFINITIONS FOR CPU BARRIERS
    4.11 + */ 
    4.12 +
    4.13 +#if defined(__i386__)
    4.14 +#define rmb() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
    4.15 +#define wmb() __asm__ __volatile__ ("" : : : "memory")
    4.16 +#elif defined(__x86_64__)
    4.17 +#define mb()     asm volatile("mfence":::"memory")
    4.18 +#define rmb()    asm volatile("lfence":::"memory")
    4.19 +#define wmb()    asm volatile( "" :::"memory")
    4.20 +#else
    4.21 +#error "Define barriers"
    4.22 +#endif
    4.23 +
    4.24 +/*
    4.25   *  INITIALIZATION FUNCTIONS
    4.26 -\*/ 
    4.27 + */ 
    4.28  
    4.29  /**
    4.30   * This function opens a handle to the hypervisor interface.  This function can
    4.31 @@ -55,9 +71,9 @@ int xc_interface_open(void);
    4.32   */
    4.33  int xc_interface_close(int xc_handle);
    4.34  
    4.35 -/*\
    4.36 +/*
    4.37   * DOMAIN MANAGEMENT FUNCTIONS
    4.38 -\*/
    4.39 + */
    4.40  
    4.41  typedef struct {
    4.42      u32           domid;
    4.43 @@ -257,9 +273,9 @@ int xc_rrobin_global_get(int xc_handle, 
    4.44  
    4.45  typedef evtchn_status_t xc_evtchn_status_t;
    4.46  
    4.47 -/*\
    4.48 +/*
    4.49   * EVENT CHANNEL FUNCTIONS
    4.50 -\*/
    4.51 + */
    4.52  
    4.53  /**
    4.54   * This function allocates an unbound port.  Ports are named endpoints used for
     5.1 --- a/tools/libxutil/sxpr_parser.c	Wed Mar 02 17:18:39 2005 +0000
     5.2 +++ b/tools/libxutil/sxpr_parser.c	Wed Mar 02 17:22:02 2005 +0000
     5.3 @@ -43,6 +43,7 @@
     5.4   */
     5.5  
     5.6  #define dprintf(fmt, args...) IOStream_print(iostdout, "[DEBUG] %s" fmt, __FUNCTION__, ##args)
     5.7 +#undef printf
     5.8  #define printf(fmt, args...)   IOStream_print(iostdout, fmt, ##args)
     5.9  
    5.10  static void reset(Parser *z);
     6.1 --- a/tools/python/xen/lowlevel/xu/xu.c	Wed Mar 02 17:18:39 2005 +0000
     6.2 +++ b/tools/python/xen/lowlevel/xu/xu.c	Wed Mar 02 17:22:02 2005 +0000
     6.3 @@ -49,14 +49,6 @@
     6.4  /* Size of a machine page frame. */
     6.5  #define PAGE_SIZE 4096
     6.6  
     6.7 -#if defined(__i386__)
     6.8 -#define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
     6.9 -#define wmb() __asm__ __volatile__ ( "" : : : "memory" )
    6.10 -#else
    6.11 -#error "Define barriers"
    6.12 -#endif
    6.13 -
    6.14 -
    6.15  /* Set the close-on-exec flag on a file descriptor.  Doesn't currently bother
    6.16   * to check for errors. */
    6.17  /*
     7.1 --- a/tools/xcs/xcs.c	Wed Mar 02 17:18:39 2005 +0000
     7.2 +++ b/tools/xcs/xcs.c	Wed Mar 02 17:22:02 2005 +0000
     7.3 @@ -674,7 +674,7 @@ int main (int argc, char *argv[])
     7.4   
     7.5      for (;;)
     7.6      {
     7.7 -        int n, ret;
     7.8 +        int n = 0, ret;
     7.9          fd_set rd, wr, er;
    7.10          FD_ZERO ( &rd );
    7.11          FD_ZERO ( &wr );
     8.1 --- a/tools/xcs/xcs.h	Wed Mar 02 17:18:39 2005 +0000
     8.2 +++ b/tools/xcs/xcs.h	Wed Mar 02 17:22:02 2005 +0000
     8.3 @@ -39,13 +39,6 @@
     8.4  /* Size of a machine page frame. */
     8.5  #define PAGE_SIZE 4096
     8.6  
     8.7 -#if defined(__i386__)
     8.8 -#define rmb() __asm__ __volatile__ ( "lock; addl $0,0(%%esp)" : : : "memory" )
     8.9 -#define wmb() __asm__ __volatile__ ( "" : : : "memory" )
    8.10 -#else
    8.11 -#error "Define barriers"
    8.12 -#endif
    8.13 -
    8.14  #ifndef timersub /* XOPEN and __BSD don't cooperate well... */
    8.15  #define timersub(a, b, result)                                                \
    8.16    do {                                                                        \
     9.1 --- a/xen/arch/x86/mm.c	Wed Mar 02 17:18:39 2005 +0000
     9.2 +++ b/xen/arch/x86/mm.c	Wed Mar 02 17:22:02 2005 +0000
     9.3 @@ -1685,28 +1685,9 @@ int do_mmu_update(
     9.4          }
     9.5      }
     9.6  
     9.7 -#ifdef PERF_COUNTERS
     9.8      perfc_incrc(calls_to_mmu_update); 
     9.9      perfc_addc(num_page_updates, count);
    9.10 -    /*
    9.11 -     * histogram: special treatment for 0 and 1 count. After that equally
    9.12 -     * spaced with last bucket taking the rest.
    9.13 -     */
    9.14 -    if ( count == 0 )
    9.15 -    {
    9.16 -        perfc_incra(bpt_updates, 0);
    9.17 -    } else if ( count == 1 )
    9.18 -    {
    9.19 -        perfc_incra(bpt_updates, 1);
    9.20 -    } else if ( ((count-2) / PERFC_PT_UPDATES_BUCKET_SIZE)
    9.21 -                < (PERFC_MAX_PT_UPDATES - 3) )
    9.22 -    {
    9.23 -        perfc_incra(bpt_updates, ((count-2)/PERFC_PT_UPDATES_BUCKET_SIZE) + 2);
    9.24 -    } else
    9.25 -    {
    9.26 -        perfc_incra(bpt_updates, PERFC_MAX_PT_UPDATES - 1);
    9.27 -    }
    9.28 -#endif
    9.29 +    perfc_incr_histo(bpt_updates, count, PT_UPDATES);
    9.30  
    9.31      if ( unlikely(!array_access_ok(VERIFY_READ, ureqs, count, sizeof(req))) )
    9.32      {
    9.33 @@ -2254,7 +2235,9 @@ void ptwr_flush(const int which)
    9.34      int            i, cpu = smp_processor_id();
    9.35      struct exec_domain *ed = current;
    9.36      struct domain *d = ed->domain;
    9.37 -    unsigned int   count;
    9.38 +#ifdef PERF_COUNTERS
    9.39 +    unsigned int   modified = 0;
    9.40 +#endif
    9.41  
    9.42      l1va = ptwr_info[cpu].ptinfo[which].l1va;
    9.43      ptep = (unsigned long *)&linear_pg_table[l1_linear_offset(l1va)];
    9.44 @@ -2313,7 +2296,7 @@ void ptwr_flush(const int which)
    9.45      /*
    9.46       * STEP 2. Validate any modified PTEs.
    9.47       */
    9.48 -    count = 0;
    9.49 +
    9.50      pl1e = ptwr_info[cpu].ptinfo[which].pl1e;
    9.51      for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ )
    9.52      {
    9.53 @@ -2323,8 +2306,10 @@ void ptwr_flush(const int which)
    9.54          if ( likely(l1_pgentry_val(ol1e) == l1_pgentry_val(nl1e)) )
    9.55              continue;
    9.56  
    9.57 -        /* update number of entries modified */
    9.58 -        count++;
    9.59 +#ifdef PERF_COUNTERS
    9.60 +        /* Update number of entries modified. */
    9.61 +        modified++;
    9.62 +#endif
    9.63  
    9.64          /*
    9.65           * Fast path for PTEs that have merely been write-protected
    9.66 @@ -2367,27 +2352,7 @@ void ptwr_flush(const int which)
    9.67      }
    9.68      unmap_domain_mem(pl1e);
    9.69  
    9.70 -#ifdef PERF_COUNTERS
    9.71 -    /*
    9.72 -     * histogram: special treatment for 0 and 1 count. After that equally
    9.73 -     * spaced with last bucket taking the rest.
    9.74 -     */
    9.75 -    if ( count == 0 )
    9.76 -    {
    9.77 -        perfc_incra(wpt_updates, 0);
    9.78 -    } else if ( count == 1 ) 
    9.79 -    {
    9.80 -        perfc_incra(wpt_updates, 1);
    9.81 -    } else if ( ((count-2) / PERFC_PT_UPDATES_BUCKET_SIZE)
    9.82 -                < (PERFC_MAX_PT_UPDATES - 3) )
    9.83 -    {
    9.84 -        perfc_incra(wpt_updates, ((count-2)/PERFC_PT_UPDATES_BUCKET_SIZE) + 2);
    9.85 -    } else
    9.86 -    {
    9.87 -        perfc_incra(wpt_updates, PERFC_MAX_PT_UPDATES - 1);
    9.88 -    }
    9.89 -#endif
    9.90 -    
    9.91 +    perfc_incr_histo(wpt_updates, modified, PT_UPDATES);
    9.92  
    9.93      /*
    9.94       * STEP 3. Reattach the L1 p.t. page into the current address space.
    10.1 --- a/xen/arch/x86/x86_32/asm-offsets.c	Wed Mar 02 17:18:39 2005 +0000
    10.2 +++ b/xen/arch/x86/x86_32/asm-offsets.c	Wed Mar 02 17:22:02 2005 +0000
    10.3 @@ -4,6 +4,7 @@
    10.4   * to extract and format the required data.
    10.5   */
    10.6  
    10.7 +#include <xen/config.h>
    10.8  #include <xen/sched.h>
    10.9  #include <xen/config.h>
   10.10  
   10.11 @@ -59,6 +60,12 @@ void __dummy__(void)
   10.12      OFFSET(TRAPBOUNCE_eip, struct trap_bounce, eip);
   10.13      BLANK();
   10.14  
   10.15 +#if PERF_COUNTERS
   10.16 +    OFFSET(PERFC_hypercalls, struct perfcounter, hypercalls);
   10.17 +    OFFSET(PERFC_exceptions, struct perfcounter, exceptions);
   10.18 +    BLANK();
   10.19 +#endif
   10.20 +
   10.21      OFFSET(MULTICALL_op, multicall_entry_t, op);
   10.22      OFFSET(MULTICALL_arg0, multicall_entry_t, args[0]);
   10.23      OFFSET(MULTICALL_arg1, multicall_entry_t, args[1]);
    11.1 --- a/xen/arch/x86/x86_32/entry.S	Wed Mar 02 17:18:39 2005 +0000
    11.2 +++ b/xen/arch/x86/x86_32/entry.S	Wed Mar 02 17:22:02 2005 +0000
    11.3 @@ -60,7 +60,7 @@
    11.4  #include <asm/apicdef.h>
    11.5  #include <asm/page.h>
    11.6  #include <public/xen.h>
    11.7 -        
    11.8 +
    11.9  #define GET_CURRENT(reg)         \
   11.10          movl $STACK_SIZE-4, reg; \
   11.11          orl  %esp, reg;          \
   11.12 @@ -279,12 +279,10 @@ ENTRY(hypercall)
   11.13          subl $4,%esp
   11.14  	SAVE_ALL(b)
   11.15          sti
   11.16 -#ifdef PERF_COUNTERS
   11.17 -        lock incl SYMBOL_NAME(perfcounters)+PERFC_hypercalls(,%eax,4)
   11.18 -#endif
   11.19          GET_CURRENT(%ebx)
   11.20          andl $(NR_hypercalls-1),%eax
   11.21 -	call *SYMBOL_NAME(hypercall_table)(,%eax,4)
   11.22 +        PERFC_INCR(PERFC_hypercalls, %eax)
   11.23 +        call *SYMBOL_NAME(hypercall_table)(,%eax,4)
   11.24          movl %eax,XREGS_eax(%esp)       # save the return value
   11.25  
   11.26  test_all_events:
   11.27 @@ -470,10 +468,8 @@ 1:      sti                             
   11.28          movw  XREGS_entry_vector(%esp),%ax
   11.29          movl  %esp,%edx
   11.30  	pushl %edx			# push the xen_regs pointer
   11.31 -#ifdef PERF_COUNTERS
   11.32 -        lock incl SYMBOL_NAME(perfcounters)+PERFC_exceptions(,%eax,4)
   11.33 -#endif        
   11.34  	GET_CURRENT(%ebx)
   11.35 +        PERFC_INCR(PERFC_exceptions, %eax)
   11.36  	call  *SYMBOL_NAME(exception_table)(,%eax,4)
   11.37          addl  $4,%esp
   11.38          movl  XREGS_eflags(%esp),%eax
    12.1 --- a/xen/arch/x86/x86_64/asm-offsets.c	Wed Mar 02 17:18:39 2005 +0000
    12.2 +++ b/xen/arch/x86/x86_64/asm-offsets.c	Wed Mar 02 17:22:02 2005 +0000
    12.3 @@ -4,6 +4,7 @@
    12.4   * to extract and format the required data.
    12.5   */
    12.6  
    12.7 +#include <xen/config.h>
    12.8  #include <xen/sched.h>
    12.9  
   12.10  #define DEFINE(_sym, _val) \
   12.11 @@ -62,6 +63,12 @@ void __dummy__(void)
   12.12      OFFSET(TRAPBOUNCE_eip, struct trap_bounce, eip);
   12.13      BLANK();
   12.14  
   12.15 +#if PERF_COUNTERS
   12.16 +    OFFSET(PERFC_hypercalls, struct perfcounter, hypercalls);
   12.17 +    OFFSET(PERFC_exceptions, struct perfcounter, exceptions);
   12.18 +    BLANK();
   12.19 +#endif
   12.20 +
   12.21      OFFSET(MULTICALL_op, multicall_entry_t, op);
   12.22      OFFSET(MULTICALL_arg0, multicall_entry_t, args[0]);
   12.23      OFFSET(MULTICALL_arg1, multicall_entry_t, args[1]);
    13.1 --- a/xen/arch/x86/x86_64/entry.S	Wed Mar 02 17:18:39 2005 +0000
    13.2 +++ b/xen/arch/x86/x86_64/entry.S	Wed Mar 02 17:22:02 2005 +0000
    13.3 @@ -141,6 +141,7 @@ hypercall:
    13.4          movq  %r10,%rcx
    13.5          andq  $(NR_hypercalls-1),%rax
    13.6          leaq  SYMBOL_NAME(hypercall_table)(%rip),%r10
    13.7 +        PERFC_INCR(PERFC_hypercalls, %rax)
    13.8          callq *(%r10,%rax,8)
    13.9          movq %rax,XREGS_rax(%rsp)       # save the return value
   13.10  
   13.11 @@ -297,6 +298,7 @@ 1:      sti
   13.12          movl  XREGS_entry_vector(%rsp),%eax
   13.13          leaq  SYMBOL_NAME(exception_table)(%rip),%rdx
   13.14          GET_CURRENT(%rbx)
   13.15 +        PERFC_INCR(PERFC_exceptions, %rax)
   13.16          callq *(%rdx,%rax,8)
   13.17          testb $3,XREGS_cs(%rsp)
   13.18          jz    restore_all_xen
    14.1 --- a/xen/common/perfc.c	Wed Mar 02 17:18:39 2005 +0000
    14.2 +++ b/xen/common/perfc.c	Wed Mar 02 17:22:02 2005 +0000
    14.3 @@ -68,9 +68,9 @@ void perfc_printall(unsigned char key)
    14.4              printk("TOTAL[%10d]  ", sum);
    14.5              for ( j = 0; j < perfc_info[i].nr_elements; j++ )
    14.6              {
    14.7 -                printk("A%02d[%10d]  ", j, atomic_read(&counters[j]));
    14.8 -                if ( !(j % 4) )
    14.9 -                    printk("\n ");
   14.10 +                if ( (j != 0) && ((j % 4) == 0) )
   14.11 +                    printk("\n                   ");
   14.12 +                printk("ARR%02d[%10d]  ", j, atomic_read(&counters[j]));
   14.13              }
   14.14              counters += j;
   14.15              break;
    15.1 --- a/xen/include/asm-x86/msr.h	Wed Mar 02 17:18:39 2005 +0000
    15.2 +++ b/xen/include/asm-x86/msr.h	Wed Mar 02 17:22:02 2005 +0000
    15.3 @@ -12,7 +12,7 @@
    15.4  			  : "c" (msr), "a" (val1), "d" (val2))
    15.5  
    15.6  #define rdmsr_user(msr,val1,val2) ({\
    15.7 -    int _rc = 0; \
    15.8 +    int _rc; \
    15.9      __asm__ __volatile__( \
   15.10          "1: rdmsr\n2:\n" \
   15.11          ".section .fixup,\"ax\"\n" \
   15.12 @@ -22,12 +22,12 @@
   15.13          "   "__FIXUP_ALIGN"\n" \
   15.14          "   "__FIXUP_WORD" 1b,3b\n" \
   15.15          ".previous\n" \
   15.16 -        : "=a" (val1), "=d" (val2), "=r" (_rc) \
   15.17 -        : "c" (msr)); \
   15.18 +        : "=a" (val1), "=d" (val2), "=&r" (_rc) \
   15.19 +        : "c" (msr), "2" (0)); \
   15.20      _rc; })
   15.21  
   15.22  #define wrmsr_user(msr,val1,val2) ({\
   15.23 -    int _rc = 0; \
   15.24 +    int _rc; \
   15.25      __asm__ __volatile__( \
   15.26          "1: wrmsr\n2:\n" \
   15.27          ".section .fixup,\"ax\"\n" \
   15.28 @@ -37,8 +37,8 @@
   15.29          "   "__FIXUP_ALIGN"\n" \
   15.30          "   "__FIXUP_WORD" 1b,3b\n" \
   15.31          ".previous\n" \
   15.32 -        : "=r" (_rc) \
   15.33 -        : "c" (msr), "a" (val1), "d" (val2)); \
   15.34 +        : "=&r" (_rc) \
   15.35 +        : "c" (msr), "a" (val1), "d" (val2), "0" (0)); \
   15.36      _rc; })
   15.37  
   15.38  #define rdtsc(low,high) \
    16.1 --- a/xen/include/asm-x86/x86_32/asm_defns.h	Wed Mar 02 17:18:39 2005 +0000
    16.2 +++ b/xen/include/asm-x86/x86_32/asm_defns.h	Wed Mar 02 17:22:02 2005 +0000
    16.3 @@ -76,6 +76,13 @@
    16.4          SET_XEN_SEGMENTS(_reg) \
    16.5          1:
    16.6  
    16.7 +#ifdef PERF_COUNTERS
    16.8 +#define PERFC_INCR(_name,_idx) \
    16.9 +    lock incl SYMBOL_NAME(perfcounters)+_name(,_idx,4)
   16.10 +#else
   16.11 +#define PERFC_INCR(_name,_idx)
   16.12 +#endif
   16.13 +
   16.14  #endif
   16.15  
   16.16  #define BUILD_SMP_INTERRUPT(x,v) XBUILD_SMP_INTERRUPT(x,v)
    17.1 --- a/xen/include/asm-x86/x86_64/asm_defns.h	Wed Mar 02 17:18:39 2005 +0000
    17.2 +++ b/xen/include/asm-x86/x86_64/asm_defns.h	Wed Mar 02 17:22:02 2005 +0000
    17.3 @@ -76,6 +76,16 @@
    17.4          popq  %rsi; \
    17.5          popq  %rdi;
    17.6  
    17.7 +#ifdef PERF_COUNTERS
    17.8 +#define PERFC_INCR(_name,_idx) \
    17.9 +    pushq %rdx; \
   17.10 +    leaq SYMBOL_NAME(perfcounters)+_name(%rip),%rdx; \
   17.11 +    lock incl (%rdx,_idx,4); \
   17.12 +    popq %rdx;
   17.13 +#else
   17.14 +#define PERFC_INCR(_name,_idx)
   17.15 +#endif
   17.16 +
   17.17  #endif
   17.18  
   17.19  #define BUILD_SMP_INTERRUPT(x,v) XBUILD_SMP_INTERRUPT(x,v)
    18.1 --- a/xen/include/xen/perfc.h	Wed Mar 02 17:18:39 2005 +0000
    18.2 +++ b/xen/include/xen/perfc.h	Wed Mar 02 17:22:02 2005 +0000
    18.3 @@ -54,26 +54,51 @@ extern struct perfcounter perfcounters;
    18.4  
    18.5  #define perfc_value(x)    atomic_read(&perfcounters.x[0])
    18.6  #define perfc_valuec(x)   atomic_read(&perfcounters.x[smp_processor_id()])
    18.7 -#define perfc_valuea(x,y) \
    18.8 -  { if(y<(sizeof(perfcounters.x)/sizeof(*perfcounters.x))) \
    18.9 -    atomic_read(&perfcounters.x[y]); }
   18.10 +#define perfc_valuea(x,y)                                               \
   18.11 +    do {                                                                \
   18.12 +        if ( (y) < (sizeof(perfcounters.x) / sizeof(*perfcounters.x)) ) \
   18.13 +            atomic_read(&perfcounters.x[y]);                            \
   18.14 +    } while ( 0 )
   18.15  #define perfc_set(x,v)    atomic_set(&perfcounters.x[0], v)
   18.16  #define perfc_setc(x,v)   atomic_set(&perfcounters.x[smp_processor_id()], v)
   18.17 -#define perfc_seta(x,y,v) \
   18.18 -  { if(y<(sizeof(perfcounters.x)/sizeof(*perfcounters.x))) \
   18.19 -    atomic_set(&perfcounters.x[y], v); }
   18.20 +#define perfc_seta(x,y,v)                                               \
   18.21 +    do {                                                                \
   18.22 +        if ( (y) < (sizeof(perfcounters.x) / sizeof(*perfcounters.x)) ) \
   18.23 +            atomic_set(&perfcounters.x[y], v);                          \
   18.24 +    } while ( 0 )
   18.25  #define perfc_incr(x)     atomic_inc(&perfcounters.x[0])
   18.26  #define perfc_decr(x)     atomic_dec(&perfcounters.x[0])
   18.27  #define perfc_incrc(x)    atomic_inc(&perfcounters.x[smp_processor_id()])
   18.28 -#define perfc_incra(x,y)  \
   18.29 -  { if(y<(sizeof(perfcounters.x)/sizeof(*perfcounters.x))) \
   18.30 -    atomic_inc(&perfcounters.x[y]); }
   18.31 +#define perfc_incra(x,y)                                                \
   18.32 +    do {                                                                \
   18.33 +        if ( (y) < (sizeof(perfcounters.x) / sizeof(*perfcounters.x)) ) \
   18.34 +            atomic_inc(&perfcounters.x[y]);                             \
   18.35 +    } while ( 0 )
   18.36  #define perfc_add(x,y)    atomic_add((y), &perfcounters.x[0])
   18.37  #define perfc_addc(x,y)   atomic_add((y), &perfcounters.x[smp_processor_id()])
   18.38 -#define perfc_adda(x,y,z) \
   18.39 -  { if(y<(sizeof(perfcounters.x)/sizeof(*perfcounters.x))) \
   18.40 -    atomic_add((z), &perfcounters.x[y]); }
   18.41 +#define perfc_adda(x,y,z)                                               \
   18.42 +    do {                                                                \
   18.43 +        if ( (y) < (sizeof(perfcounters.x) / sizeof(*perfcounters.x)) ) \
   18.44 +            atomic_add((z), &perfcounters.x[y]);                        \
   18.45 +    } while ( 0 )
   18.46  
   18.47 +/*
   18.48 + * Histogram: special treatment for 0 and 1 count. After that equally spaced 
   18.49 + * with last bucket taking the rest.
   18.50 + */
   18.51 +#define perfc_incr_histo(_x,_v,_n)                                          \
   18.52 +    do {                                                                    \
   18.53 +        if ( (_v) == 0 )                                                    \
   18.54 +            perfc_incra(_x, 0);                                             \
   18.55 +        else if ( (_v) == 1 )                                               \
   18.56 +            perfc_incra(_x, 1);                                             \
   18.57 +        else if ( (((_v)-2) / PERFC_ ## _n ## _BUCKET_SIZE) <               \
   18.58 +                  (PERFC_MAX_ ## _n - 3) )                                  \
   18.59 +            perfc_incra(_x, (((_v)-2) / PERFC_ ## _n ## _BUCKET_SIZE) + 2); \
   18.60 +        else                                                                \
   18.61 +            perfc_incra(_x, PERFC_MAX_ ## _n - 1);                          \
   18.62 +    } while ( 0 )
   18.63 +    
   18.64  #else /* PERF_COUNTERS */
   18.65  
   18.66  #define perfc_value(x)    (0)
   18.67 @@ -89,6 +114,7 @@ extern struct perfcounter perfcounters;
   18.68  #define perfc_add(x,y)    ((void)0)
   18.69  #define perfc_addc(x,y)   ((void)0)
   18.70  #define perfc_adda(x,y,z) ((void)0)
   18.71 +#define perfc_incr_histo(x,y,z) ((void)0)
   18.72  
   18.73  #endif /* PERF_COUNTERS */
   18.74  
    19.1 --- a/xen/include/xen/perfc_defn.h	Wed Mar 02 17:18:39 2005 +0000
    19.2 +++ b/xen/include/xen/perfc_defn.h	Wed Mar 02 17:22:02 2005 +0000
    19.3 @@ -36,14 +36,13 @@ PERFSTATUS( hl2_table_pages, "current # 
    19.4  PERFCOUNTER_CPU( check_pagetable, "calls to check_pagetable" )
    19.5  PERFCOUNTER_CPU( check_all_pagetables, "calls to check_all_pagetables" )
    19.6  
    19.7 -/* XXX constant from dom0_ops.h */
    19.8  #define PERFC_MAX_PT_UPDATES 64
    19.9  #define PERFC_PT_UPDATES_BUCKET_SIZE 3
   19.10  PERFCOUNTER_ARRAY( wpt_updates, "writable pt updates", PERFC_MAX_PT_UPDATES )
   19.11  PERFCOUNTER_ARRAY( bpt_updates, "batched pt updates", PERFC_MAX_PT_UPDATES )
   19.12  
   19.13  PERFCOUNTER_ARRAY( hypercalls, "hypercalls", NR_hypercalls )
   19.14 -PERFCOUNTER_ARRAY( exceptions, "exceptions", 32 ) /* XXX constant */
   19.15 +PERFCOUNTER_ARRAY( exceptions, "exceptions", 32 )
   19.16  
   19.17  #define VMX_PERF_EXIT_REASON_SIZE 37
   19.18  #define VMX_PERF_VECTOR_SIZE 0x20