From: Juergen Gross Date: Thu, 4 Oct 2018 11:47:23 +0000 (+0100) Subject: xentrace: allow sparse cpu list X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~3199 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=28a936790c16d3c6ae9a43cd59b57d52c36dc7b4;p=xen.git xentrace: allow sparse cpu list Modify the xentrace utility to allow sparse cpu list resulting in not all possible cpus having a trace buffer allocated. Signed-off-by: Juergen Gross Reviewed-by: George Dunlap --- diff --git a/tools/xentrace/xentrace.c b/tools/xentrace/xentrace.c index 364a6fdad5..a9cb4b15a9 100644 --- a/tools/xentrace/xentrace.c +++ b/tools/xentrace/xentrace.c @@ -489,7 +489,11 @@ static struct t_struct *map_tbufs(unsigned long tbufs_mfn, unsigned int num, exit(EXIT_FAILURE); } - /* Map per-cpu buffers */ + /* + * Map per-cpu buffers. NB that if a cpu is offline, it may have + * no trace buffers. In this case, the respective mfn_offset will + * be 0, and the index should be ignored. + */ tbufs.meta = (struct t_buf **)calloc(num, sizeof(struct t_buf *)); tbufs.data = (unsigned char **)calloc(num, sizeof(unsigned char *)); if ( tbufs.meta == NULL || tbufs.data == NULL ) @@ -500,12 +504,14 @@ static struct t_struct *map_tbufs(unsigned long tbufs_mfn, unsigned int num, for(i=0; imfn_offset[i]; + const uint32_t *mfn_list; int j; xen_pfn_t pfn_list[tbufs.t_info->tbuf_size]; + if ( !tbufs.t_info->mfn_offset[i] ) + continue; + + mfn_list = (const uint32_t *)tbufs.t_info + tbufs.t_info->mfn_offset[i]; for ( j=0; jtbuf_size; j++) pfn_list[j] = (xen_pfn_t)mfn_list[j]; @@ -702,7 +708,8 @@ static int monitor_tbufs(void) if ( opts.discard ) for ( i = 0; i < num; i++ ) - meta[i]->cons = meta[i]->prod; + if ( meta[i] ) + meta[i]->cons = meta[i]->prod; /* now, scan buffers for events */ while ( 1 ) @@ -710,7 +717,10 @@ static int monitor_tbufs(void) for ( i = 0; i < num; i++ ) { unsigned long start_offset, end_offset, window_size, cons, prod; - + + if ( !meta[i] ) + continue; + /* Read window information only once. */ cons = meta[i]->cons; prod = meta[i]->prod;