[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] xentrace: allow sparse cpu list



commit 28a936790c16d3c6ae9a43cd59b57d52c36dc7b4
Author:     Juergen Gross <jgross@xxxxxxxx>
AuthorDate: Thu Oct 4 12:47:23 2018 +0100
Commit:     George Dunlap <george.dunlap@xxxxxxxxxx>
CommitDate: Thu Oct 4 12:47:23 2018 +0100

    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 <jgross@xxxxxxxx>
    Reviewed-by: George Dunlap <george.dunlap@xxxxxxxxxx>
---
 tools/xentrace/xentrace.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

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; 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 +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;
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.