ia64/xen-unstable

changeset 1147:95d5df5c2097

bitkeeper revision 1.767 (4048c2ebEScP6JGNbkJsrrd8z5M6zQ)

trace.c:
Clean up trace.c.
author kaf24@scramble.cl.cam.ac.uk
date Fri Mar 05 18:11:55 2004 +0000 (2004-03-05)
parents 5c59473e9416
children d0dacd33c1db
files xen/common/trace.c
line diff
     1.1 --- a/xen/common/trace.c	Fri Mar 05 18:04:53 2004 +0000
     1.2 +++ b/xen/common/trace.c	Fri Mar 05 18:11:55 2004 +0000
     1.3 @@ -49,8 +49,8 @@ int tb_init_done = 0;
     1.4  void init_trace_bufs(void)
     1.5  {
     1.6      extern int opt_tbuf_size;
     1.7 -    int           i, pages_order;
     1.8 -    unsigned long total_size;
     1.9 +    int           i, order;
    1.10 +    unsigned long nr_pages;
    1.11      char         *rawbuf;
    1.12      struct t_buf *buf;
    1.13      
    1.14 @@ -60,27 +60,18 @@ void init_trace_bufs(void)
    1.15          return;
    1.16      }
    1.17  
    1.18 -    /* calculate page_order - we'll allocate 2^page_order pages */
    1.19 -    pages_order = 0;
    1.20 -    total_size = smp_num_cpus * opt_tbuf_size;
    1.21 +    nr_pages = smp_num_cpus * opt_tbuf_size;
    1.22 +    order    = get_order(nr_pages * PAGE_SIZE);
    1.23      
    1.24 -    while( (total_size) >> ( pages_order + 1 ) )
    1.25 -        pages_order++;
    1.26 -
    1.27 -    /* if total_size is not an exact power of two then over-allocate */
    1.28 -    if( total_size & ~( 1 << pages_order ) )
    1.29 -        pages_order++;
    1.30 -
    1.31 -    /* we allocate 2^page_order pages to hold the data */
    1.32 -    if ( (rawbuf = (char *)__get_free_pages(GFP_KERNEL, pages_order)) == NULL )
    1.33 +    if ( (rawbuf = (char *)__get_free_pages(GFP_KERNEL, order)) == NULL )
    1.34      {
    1.35          printk("Xen trace buffers: memory allocation failed\n");
    1.36          return;
    1.37      }
    1.38  
    1.39      /* share pages so that xentrace can map them */
    1.40 -    for( i = 0; i < total_size; i++)
    1.41 -        SHARE_PFN_WITH_DOMAIN( &frame_table[(__pa(rawbuf)>>PAGE_SHIFT)+i], 0);
    1.42 +    for( i = 0; i < nr_pages; i++)
    1.43 +        SHARE_PFN_WITH_DOMAIN(virt_to_page(rawbuf+(i*PAGE_SIZE)), 0);
    1.44      
    1.45      for ( i = 0; i < smp_num_cpus; i++ )
    1.46      {
    1.47 @@ -97,7 +88,7 @@ void init_trace_bufs(void)
    1.48  
    1.49          /* For use in both. */
    1.50          buf->size = (opt_tbuf_size * PAGE_SIZE - sizeof(struct t_buf))
    1.51 -                                                        / sizeof(struct t_rec);
    1.52 +            / sizeof(struct t_rec);
    1.53      }
    1.54  
    1.55      printk("Xen trace buffers: initialised\n");