On 10/04/2018 11:51 AM, Juergen Gross wrote:
> 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 <[email protected]>
This looks good:
Reviewed-by: George Dunlap <[email protected]>
Would you mind if I fold in the attached comment when committing?
-George
> ---
> tools/xentrace/xentrace.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/tools/xentrace/xentrace.c b/tools/xentrace/xentrace.c
> index 364a6fdad5..590a91e091 100644
> --- a/tools/xentrace/xentrace.c
> +++ b/tools/xentrace/xentrace.c
> @@ -500,12 +500,14 @@ static struct t_struct *map_tbufs(unsigned long
> tbufs_mfn, unsigned int num,
>
> for(i=0; i<num; i++)
> {
> -
> - const uint32_t *mfn_list = (const uint32_t *)tbufs.t_info
> - + tbufs.t_info->mfn_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; j<tbufs.t_info->tbuf_size; j++)
> pfn_list[j] = (xen_pfn_t)mfn_list[j];
>
> @@ -702,7 +704,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 +713,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;
>
diff --git a/tools/xentrace/xentrace.c b/tools/xentrace/xentrace.c
index 590a91e091..a897223592 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 cpus is offline, it may have
+ * no trace buffers. In this case, the 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 )
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel