ia64/xen-unstable

changeset 4084:47e1cb8a3d38

bitkeeper revision 1.1244 (42308dfaWqh7O5QB-sS9WJ1R4LYoEA)

various hacks for batching mode and stats gathering

Signed-off-by: michael.fetterman@cl.cam.ac.uk
author rneugeba@wyvis.research.intel-research.net
date Thu Mar 10 18:12:10 2005 +0000 (2005-03-10)
parents 24703bde489b
children 2c4ca5aad6c4
files .rootkeys linux-2.6.10-xen-sparse/arch/xen/Kconfig linux-2.6.10-xen-sparse/arch/xen/i386/kernel/Makefile linux-2.6.10-xen-sparse/arch/xen/i386/kernel/entry.S linux-2.6.10-xen-sparse/arch/xen/i386/kernel/syscall_stats.c linux-2.6.10-xen-sparse/arch/xen/i386/mm/hypervisor.c linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h linux-2.6.10-xen-sparse/mm/memory.c tools/misc/Makefile tools/misc/cpuperf/cpuperf.c tools/misc/xc_shadow.c
line diff
     1.1 --- a/.rootkeys	Wed Mar 02 17:22:02 2005 +0000
     1.2 +++ b/.rootkeys	Thu Mar 10 18:12:10 2005 +0000
     1.3 @@ -159,6 +159,7 @@ 40f56238YQIJoYG2ehDGEcdTgLmGbg linux-2.6
     1.4  40f56238nWMQg7CKbyTy0KJNvCzbtg linux-2.6.10-xen-sparse/arch/xen/i386/kernel/signal.c
     1.5  41811cac4lkCB-fHir6CcxuEJ2pGsQ linux-2.6.10-xen-sparse/arch/xen/i386/kernel/smp.c
     1.6  41811ca9mbGpqBrZVrUGEiv8CTV3ng linux-2.6.10-xen-sparse/arch/xen/i386/kernel/smpboot.c
     1.7 +42308df8u332Gs7XX-jX4gsfFU2zOQ linux-2.6.10-xen-sparse/arch/xen/i386/kernel/syscall_stats.c
     1.8  40f56238qVGkpO_ycnQA8k03kQzAgA linux-2.6.10-xen-sparse/arch/xen/i386/kernel/time.c
     1.9  40f56238NzTgeO63RGoxHrW5NQeO3Q linux-2.6.10-xen-sparse/arch/xen/i386/kernel/timers/Makefile
    1.10  40f56238BMqG5PuSHufpjbvp_helBw linux-2.6.10-xen-sparse/arch/xen/i386/kernel/timers/timer_tsc.c
    1.11 @@ -601,6 +602,7 @@ 3f6dc142IHaf6XIcAYGmhV9nNSIHFQ tools/mis
    1.12  40c9c469kT0H9COWzA4XzPBjWK0WsA tools/misc/netfix
    1.13  4022a73cEKvrYe_DVZW2JlAxobg9wg tools/misc/nsplitd/Makefile
    1.14  4022a73cKms4Oq030x2JBzUB426lAQ tools/misc/nsplitd/nsplitd.c
    1.15 +42308df9dv_ZuP49nNPIROEMQ3F_LA tools/misc/xc_shadow.c
    1.16  3f5ef5a2ir1kVAthS14Dc5QIRCEFWg tools/misc/xen-clone
    1.17  3f5ef5a2dTZP0nnsFoeq2jRf3mWDDg tools/misc/xen-clone.README
    1.18  405eedf6_nnNhFQ1I85lhCkLK6jFGA tools/misc/xencons
     2.1 --- a/linux-2.6.10-xen-sparse/arch/xen/Kconfig	Wed Mar 02 17:22:02 2005 +0000
     2.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/Kconfig	Thu Mar 10 18:12:10 2005 +0000
     2.3 @@ -115,9 +115,38 @@ config XEN_BLKDEV_TAP
     2.4  	  space.  Odds are that you want to say N here.
     2.5  
     2.6  config XEN_WRITABLE_PAGETABLES
     2.7 -	bool
     2.8 +	bool "writable page tables"
     2.9  	default y
    2.10  
    2.11 +config XEN_SYSCALL_STATS
    2.12 +	bool "system call statistics"
    2.13 +	default n
    2.14 +
    2.15 +config XEN_DEBUG_NO_MMU_BATCHING
    2.16 +	bool "Disables batching on MMU updates"
    2.17 +	default n
    2.18 +    help
    2.19 +      This does a hypercall per PTE update
    2.20 +      we only use this for benchmarking
    2.21 +      enable only if you know what you are doing
    2.22 +
    2.23 +config XEN_BATCH_MODE1
    2.24 +	bool "A variant of writable pagetable using the batch interface"
    2.25 +	default n
    2.26 +    help
    2.27 +      default is no batching and minor mods for some batching
    2.28 +      we only use this for benchmarking
    2.29 +      enable only if you know what you are doing
    2.30 +
    2.31 +config XEN_BATCH_MODE2
    2.32 +	bool "forward port of 2.4 batching"
    2.33 +	default n
    2.34 +    help
    2.35 +      default is batching + flushes where 2.4 had them
    2.36 +      we only use this for benchmarking
    2.37 +      enable only if you know what you are doing
    2.38 +
    2.39 +
    2.40  config XEN_SCRUB_PAGES
    2.41  	bool "Scrub memory before freeing it to Xen"
    2.42  	default y
     3.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/Makefile	Wed Mar 02 17:22:02 2005 +0000
     3.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/Makefile	Thu Mar 10 18:12:10 2005 +0000
     3.3 @@ -43,6 +43,8 @@ c-obj-$(CONFIG_HPET_TIMER) 	+= time_hpet
     3.4  c-obj-$(CONFIG_EFI) 		+= efi.o efi_stub.o
     3.5  c-obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
     3.6  
     3.7 +c-obj-$(CONFIG_XEN_SYSCALL_STATS) += syscall_stats.o
     3.8 +
     3.9  EXTRA_AFLAGS   := -traditional
    3.10  
    3.11  c-obj-$(CONFIG_SCx200)		+= scx200.o
     4.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/entry.S	Wed Mar 02 17:22:02 2005 +0000
     4.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/entry.S	Thu Mar 10 18:12:10 2005 +0000
     4.3 @@ -280,7 +280,10 @@ 1:	movl (%ebp),%ebp
     4.4  	jnz syscall_trace_entry
     4.5  	cmpl $(nr_syscalls), %eax
     4.6  	jae syscall_badsys
     4.7 -	call *sys_call_table(,%eax,4)
     4.8 +#ifdef CONFIG_XEN_SYSCALL_STATS
     4.9 +    lock incl syscall_stats(,%eax,4)
    4.10 +#endif
    4.11 +    call *sys_call_table(,%eax,4)
    4.12  	movl %eax,EAX(%esp)
    4.13  	cli
    4.14  	movl TI_flags(%ebp), %ecx
    4.15 @@ -305,7 +308,10 @@ ENTRY(system_call)
    4.16  	cmpl $(nr_syscalls), %eax
    4.17  	jae syscall_badsys
    4.18  syscall_call:
    4.19 -	call *sys_call_table(,%eax,4)
    4.20 +#ifdef CONFIG_XEN_SYSCALL_STATS
    4.21 +    lock incl syscall_stats(,%eax,4)
    4.22 +#endif
    4.23 +    call *sys_call_table(,%eax,4)
    4.24  	movl %eax,EAX(%esp)		# store the return value
    4.25  syscall_exit:
    4.26  	XEN_BLOCK_EVENTS(%esi)		# make sure we don't miss an interrupt
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/syscall_stats.c	Thu Mar 10 18:12:10 2005 +0000
     5.3 @@ -0,0 +1,91 @@
     5.4 +/* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
     5.5 + ****************************************************************************
     5.6 + * (C) 2005 - Rolf Neugebauer - Intel Research Cambridge
     5.7 + ****************************************************************************
     5.8 + *
     5.9 + *        File: syscall_stats.c
    5.10 + *      Author: Rolf Neugebauer (rolf.neugebauer@intel.com)
    5.11 + *        Date: Mar 2005
    5.12 + * 
    5.13 + * Description: add a proc interface to get per system call stats
    5.14 + */
    5.15 +
    5.16 +
    5.17 +#include <linux/config.h>
    5.18 +#include <linux/proc_fs.h>
    5.19 +#include <linux/seq_file.h>
    5.20 +#include <asm/unistd.h>
    5.21 +
    5.22 +unsigned long syscall_stats[NR_syscalls];
    5.23 +static unsigned char foobar[4];
    5.24 +
    5.25 +/* a write just resests the counter */
    5.26 +static ssize_t syscall_write(struct file *f, const  char *data,
    5.27 +                             size_t size, loff_t  *pos)
    5.28 +{
    5.29 +    printk("resetting syscall stats\n");
    5.30 +    memset(&syscall_stats, 0, sizeof(syscall_stats));
    5.31 +    return size;
    5.32 +}
    5.33 +
    5.34 +static int show_syscall(struct seq_file *m, void *v)
    5.35 +{
    5.36 +    int i;
    5.37 +    for ( i=0; i<NR_syscalls; i++ )
    5.38 +    {
    5.39 +        seq_printf(m, "%lu ", syscall_stats[i]);
    5.40 +    }
    5.41 +    seq_printf(m, "\n");
    5.42 +    return 0;
    5.43 +}
    5.44 +
    5.45 +static void *c_start(struct seq_file *m, loff_t *pos)
    5.46 +{
    5.47 +    return *pos == 0 ? foobar : NULL;
    5.48 +}
    5.49 +
    5.50 +static void *c_next(struct seq_file *m, void *v, loff_t *pos)
    5.51 +{
    5.52 +    ++*pos;
    5.53 +    return c_start(m, pos);
    5.54 +}
    5.55 +
    5.56 +static void c_stop(struct seq_file *m, void *v)
    5.57 +{
    5.58 +}
    5.59 +
    5.60 +static struct seq_operations syscall_op = {
    5.61 +    start:  c_start,
    5.62 +    next:   c_next,
    5.63 +    stop:   c_stop,
    5.64 +    show:   show_syscall,
    5.65 +};
    5.66 +
    5.67 +static int syscall_open(struct inode *inode, struct file *file)
    5.68 +{
    5.69 +    return seq_open(file, &syscall_op);
    5.70 +}
    5.71 +
    5.72 +static struct file_operations proc_syscall_operations = {
    5.73 +    open:           syscall_open,
    5.74 +    read:           seq_read,
    5.75 +    write:          syscall_write,
    5.76 +    llseek:         seq_lseek,
    5.77 +    release:        seq_release,
    5.78 +};
    5.79 +
    5.80 +
    5.81 +static struct proc_dir_entry *entry;
    5.82 +
    5.83 +static int __init syscall_stats_init(void)
    5.84 +{
    5.85 +    printk("Initialising syscall stats.\n");
    5.86 +
    5.87 +    entry = create_proc_entry("syscalls", 0777, NULL);
    5.88 +    if (entry)
    5.89 +        entry->proc_fops = &proc_syscall_operations;
    5.90 +    else
    5.91 +        printk("Unable to create /proc/syscalls.\n");
    5.92 +    return 0;
    5.93 +}
    5.94 +subsys_initcall(syscall_stats_init);
     6.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/mm/hypervisor.c	Wed Mar 02 17:22:02 2005 +0000
     6.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/mm/hypervisor.c	Thu Mar 10 18:12:10 2005 +0000
     6.3 @@ -133,6 +133,9 @@ void queue_l1_entry_update(pte_t *ptr, u
     6.4      per_cpu(update_queue[idx], cpu).ptr = virt_to_machine(ptr);
     6.5      per_cpu(update_queue[idx], cpu).val = val;
     6.6      increment_index();
     6.7 +#ifdef CONFIG_XEN_DEBUG_NO_MMU_BATCHING
     6.8 +    __flush_page_update_queue();
     6.9 +#endif
    6.10      spin_unlock_irqrestore(&update_lock, flags);
    6.11  }
    6.12  
     7.1 --- a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h	Wed Mar 02 17:22:02 2005 +0000
     7.2 +++ b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h	Thu Mar 10 18:12:10 2005 +0000
     7.3 @@ -36,7 +36,16 @@ do { \
     7.4  #endif
     7.5  #define set_pte_atomic(pteptr, pteval) set_pte(pteptr, pteval)
     7.6  #else
     7.7 +#if defined(CONFIG_XEN_DEBUG_NO_MMU_BATCHING)
     7.8 +#define set_pte(pteptr, pteval)\
     7.9 +    set_pte_batched(pteptr, pteval)
    7.10 +#elif defined(CONFIG_XEN_BATCH_MODE)
    7.11 +#define set_pte(pteptr, pteval)({\
    7.12 +    set_pte_batched(pteptr, pteval);\
    7.13 +    _flush_page_update_queue();})
    7.14 +#else
    7.15  #define set_pte(pteptr, pteval) (*(pteptr) = pteval)
    7.16 +#endif
    7.17  #define set_pte_atomic(pteptr, pteval) set_pte(pteptr,pteval)
    7.18  #endif
    7.19  /*
     8.1 --- a/linux-2.6.10-xen-sparse/mm/memory.c	Wed Mar 02 17:22:02 2005 +0000
     8.2 +++ b/linux-2.6.10-xen-sparse/mm/memory.c	Thu Mar 10 18:12:10 2005 +0000
     8.3 @@ -218,6 +218,11 @@ out:
     8.4   * dst->page_table_lock is held on entry and exit,
     8.5   * but may be dropped within pmd_alloc() and pte_alloc_map().
     8.6   */
     8.7 +#ifdef CONFIG_XEN_BATCH_MODE1
     8.8 +#undef set_pte
     8.9 +#define set_pte(pteptr, pteval)\
    8.10 +    set_pte_batched(pteptr, pteval);
    8.11 +#endif
    8.12  int copy_page_range(struct mm_struct *dst, struct mm_struct *src,
    8.13  			struct vm_area_struct *vma)
    8.14  {
    8.15 @@ -354,8 +359,11 @@ cont_copy_pte_range_noset:
    8.16  			cond_resched_lock(&dst->page_table_lock);
    8.17  cont_copy_pmd_range:
    8.18  			src_pmd++;
    8.19 -			dst_pmd++;
    8.20 +			dst_pmd++;            
    8.21  		} while ((unsigned long)src_pmd & PMD_TABLE_MASK);
    8.22 +#ifdef CONFIG_XEN_BATCH_MODE1
    8.23 +        _flush_page_update_queue();
    8.24 +#endif
    8.25  	}
    8.26  out_unlock:
    8.27  	spin_unlock(&src->page_table_lock);
    8.28 @@ -445,9 +453,19 @@ static void zap_pte_range(struct mmu_gat
    8.29  			free_swap_and_cache(pte_to_swp_entry(pte));
    8.30  		pte_clear(ptep);
    8.31  	}
    8.32 +#ifdef CONFIG_XEN_BATCH_MODE1
    8.33 +    _flush_page_update_queue();
    8.34 +#endif
    8.35  	pte_unmap(ptep-1);
    8.36  }
    8.37  
    8.38 +#ifdef CONFIG_XEN_BATCH_MODE1
    8.39 +#undef set_pte
    8.40 +#define set_pte(pteptr, pteval)\
    8.41 +    set_pte_batched(pteptr, pteval);\
    8.42 +    _flush_page_update_queue()
    8.43 +#endif
    8.44 +
    8.45  static void zap_pmd_range(struct mmu_gather *tlb,
    8.46  		pgd_t * dir, unsigned long address,
    8.47  		unsigned long size, struct zap_details *details)
    8.48 @@ -839,6 +857,11 @@ out:
    8.49  
    8.50  EXPORT_SYMBOL(get_user_pages);
    8.51  
    8.52 +#ifdef CONFIG_XEN_BATCH_MODE1
    8.53 +#undef set_pte
    8.54 +#define set_pte(pteptr, pteval)\
    8.55 +    set_pte_batched(pteptr, pteval);
    8.56 +#endif
    8.57  static void zeromap_pte_range(pte_t * pte, unsigned long address,
    8.58                                       unsigned long size, pgprot_t prot)
    8.59  {
    8.60 @@ -855,7 +878,18 @@ static void zeromap_pte_range(pte_t * pt
    8.61  		address += PAGE_SIZE;
    8.62  		pte++;
    8.63  	} while (address && (address < end));
    8.64 +
    8.65 +#ifdef CONFIG_XEN_BATCH_MODE1
    8.66 +    _flush_page_update_queue();
    8.67 +#endif
    8.68 +
    8.69  }
    8.70 +#ifdef CONFIG_XEN_BATCH_MODE1
    8.71 +#undef set_pte
    8.72 +#define set_pte(pteptr, pteval)\
    8.73 +    set_pte_batched(pteptr, pteval);\
    8.74 +    _flush_page_update_queue()
    8.75 +#endif
    8.76  
    8.77  static inline int zeromap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address,
    8.78                                      unsigned long size, pgprot_t prot)
    8.79 @@ -917,6 +951,11 @@ int zeromap_page_range(struct vm_area_st
    8.80   * mappings are removed. any references to nonexistent pages results
    8.81   * in null mappings (currently treated as "copy-on-access")
    8.82   */
    8.83 +#ifdef CONFIG_XEN_BATCH_MODE1
    8.84 +#undef set_pte
    8.85 +#define set_pte(pteptr, pteval)\
    8.86 +    set_pte_batched(pteptr, pteval);
    8.87 +#endif
    8.88  static inline void remap_pte_range(pte_t * pte, unsigned long address, unsigned long size,
    8.89  	unsigned long pfn, pgprot_t prot)
    8.90  {
    8.91 @@ -934,7 +973,16 @@ static inline void remap_pte_range(pte_t
    8.92  		pfn++;
    8.93  		pte++;
    8.94  	} while (address && (address < end));
    8.95 +#ifdef CONFIG_XEN_BATCH_MODE1
    8.96 +    _flush_page_update_queue();
    8.97 +#endif
    8.98  }
    8.99 +#ifdef CONFIG_XEN_BATCH_MODE1
   8.100 +#undef set_pte
   8.101 +#define set_pte(pteptr, pteval)\
   8.102 +    set_pte_batched(pteptr, pteval);\
   8.103 +    _flush_page_update_queue()
   8.104 +#endif
   8.105  
   8.106  static inline int remap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address, unsigned long size,
   8.107  	unsigned long pfn, pgprot_t prot)
     9.1 --- a/tools/misc/Makefile	Wed Mar 02 17:22:02 2005 +0000
     9.2 +++ b/tools/misc/Makefile	Thu Mar 10 18:12:10 2005 +0000
     9.3 @@ -14,7 +14,7 @@ CFLAGS   += $(INCLUDES)
     9.4  
     9.5  HDRS     = $(wildcard *.h)
     9.6  
     9.7 -TARGETS  = xenperf
     9.8 +TARGETS  = xenperf xc_shadow
     9.9  
    9.10  INSTALL_BIN  = $(TARGETS) xencons
    9.11  INSTALL_SBIN = netfix xm xend xensv xenperf
    10.1 --- a/tools/misc/cpuperf/cpuperf.c	Wed Mar 02 17:22:02 2005 +0000
    10.2 +++ b/tools/misc/cpuperf/cpuperf.c	Thu Mar 10 18:12:10 2005 +0000
    10.3 @@ -246,7 +246,7 @@ int main(int argc, char **argv)
    10.4          while((cpu_mask&1)) {
    10.5              int i;
    10.6              for (i=0x300;i<0x312;i++) {
    10.7 -                printf("%010llx ",cpus_rdmsr( cpu_mask, i ) );
    10.8 +                printf("%010llu ",cpus_rdmsr( cpu_mask, i ) );
    10.9              }
   10.10              printf("\n");
   10.11              cpu_mask>>=1;
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/tools/misc/xc_shadow.c	Thu Mar 10 18:12:10 2005 +0000
    11.3 @@ -0,0 +1,70 @@
    11.4 +/* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
    11.5 + ****************************************************************************
    11.6 + * (C) 2005 - Rolf Neugebauer - Intel Research Cambridge
    11.7 + ****************************************************************************
    11.8 + *
    11.9 + *        File: xc_shadow.c
   11.10 + *      Author: Rolf Neugebauer (rolf.neugebauer@intel.com)
   11.11 + *        Date: Mar 2005
   11.12 + * 
   11.13 + * Description: 
   11.14 + */
   11.15 +
   11.16 +
   11.17 +#include <xc.h>
   11.18 +#include <stdio.h>
   11.19 +#include <stdlib.h>
   11.20 +#include <sys/mman.h>
   11.21 +#include <errno.h>
   11.22 +#include <string.h>
   11.23 +
   11.24 +void usage()
   11.25 +{
   11.26 +    printf("xc_shadow: -[0|1|2]\n");
   11.27 +    printf("    set shadow mode\n");
   11.28 +    exit(0);
   11.29 +}
   11.30 +
   11.31 +int main(int argc, char *argv[])
   11.32 +{
   11.33 +    int xc_handle;
   11.34 +    int mode;
   11.35 +
   11.36 +    if ( argc > 1 )
   11.37 +    {
   11.38 +        char *p = argv[1];
   11.39 +        if (*p++ == '-') {
   11.40 +            if (*p == '1')
   11.41 +                mode = 1;
   11.42 +            else if (*p == '2')
   11.43 +                mode = 2;
   11.44 +            else if (*p == '0')
   11.45 +                mode = 0;
   11.46 +            else
   11.47 +                usage();
   11.48 +        } else
   11.49 +            usage();
   11.50 +    } 
   11.51 +    else
   11.52 +        usage();
   11.53 +
   11.54 +    if ( (xc_handle = xc_interface_open()) == -1 )
   11.55 +    {
   11.56 +        fprintf(stderr, "Error opening xc interface: %d (%s)\n",
   11.57 +                errno, strerror(errno));
   11.58 +        return 1;
   11.59 +    }
   11.60 +
   11.61 +    if ( xc_shadow_control(xc_handle,
   11.62 +                           0,
   11.63 +                           mode, 
   11.64 +                           NULL,
   11.65 +                           0,
   11.66 +                           NULL) < 0 )
   11.67 +    {    
   11.68 +        fprintf(stderr, "Error reseting performance counters: %d (%s)\n",
   11.69 +                errno, strerror(errno));
   11.70 +        return 1;
   11.71 +    }
   11.72 +    return 0;
   11.73 +}