From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yu Zhiguo Subject: Re: tools/xenbaked: fix bug of getting trace buffer size Date: Wed, 10 Feb 2010 11:25:30 +0800 Message-ID: <4B72272A.4060309@cn.fujitsu.com> References: <4B71349F.6060808@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <4B71349F.6060808@cn.fujitsu.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Hi, Keir Please ignore this patch. Run xenbaked will occur Segmentation fault, because some other bugs exist: the tbuf's meta&data which be gotten is wrong, so SIGSEGV occurs in routine process_record() static int process_record(int cpu, struct t_rec *r) { ...snip... if ( r->cycles_included ) --- SIGSEGV The method to get tbuf's meta is wrong, I think it can be fixed according to xentrace and I'll make a new patch. regards, Yu Yu Zhiguo wrote: > Size of t_info pages is regarded as trace buffer size now, > it is wrong. This size should be t_info->tbuf_size * XC_PAGE_SIZE. > > Signed-off-by: Yu Zhiguo > > diff --git a/tools/xenmon/xenbaked.c b/tools/xenmon/xenbaked.c > --- a/tools/xenmon/xenbaked.c > +++ b/tools/xenmon/xenbaked.c > @@ -469,6 +469,40 @@ > return physinfo.nr_cpus; > } > > +/** > + * get_tbuf_size - get the size in pages of each trace buffer > + */ > +uint16_t get_tbuf_size(unsigned long tbufs_mfn, unsigned long tinfo_size) > +{ > + struct t_info *t_info; > + int xc_handle; > + > + xc_handle = xc_interface_open(); > + if ( xc_handle < 0 ) > + { > + exit(EXIT_FAILURE); > + } > + > + t_info = xc_map_foreign_range(xc_handle, DOMID_XEN, > + tinfo_size, PROT_READ | PROT_WRITE, > + tbufs_mfn); > + > + if ( t_info == 0 ) > + { > + PERROR("Failed to mmap trace buffers"); > + exit(EXIT_FAILURE); > + } > + > + if ( t_info->tbuf_size == 0 ) > + { > + fprintf(stderr, "%s: tbuf_size 0!\n", __func__); > + exit(EXIT_FAILURE); > + } > + > + xc_interface_close(xc_handle); > + > + return t_info->tbuf_size; > +} > > /** > * monitor_tbufs - monitor the contents of tbufs > @@ -483,6 +517,8 @@ > * where they are mapped into user space. */ > unsigned long tbufs_mfn; /* mfn of the tbufs */ > unsigned int num; /* number of trace buffers / logical CPUS */ > + unsigned long tinfo_size; /* size of t_info metadata map */ > + uint16_t tbuf_size; /* Size in pages of each trace buffer */ > unsigned long size; /* size of a single trace buffer */ > > unsigned long data_size, rec_size; > @@ -496,9 +532,12 @@ > printf("CPU Frequency = %7.2f\n", opts.cpu_freq); > > /* setup access to trace buffers */ > - get_tbufs(&tbufs_mfn, &size); > + get_tbufs(&tbufs_mfn, &tinfo_size); > > - tbufs_mapped = map_tbufs(tbufs_mfn, num, size); > + tbufs_mapped = map_tbufs(tbufs_mfn, num, tinfo_size); > + > + tbuf_size = get_tbuf_size(tbufs_mfn, tinfo_size); > + size = tbuf_size * XC_PAGE_SIZE; > > data_size = size - sizeof(struct t_buf); > > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel > > >