]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/xen.git/commitdiff
xentrace: correct formula to calculate t_info_pages
authorOlaf Hering <olaf@aepfle.de>
Sat, 2 Apr 2011 14:50:19 +0000 (15:50 +0100)
committerOlaf Hering <olaf@aepfle.de>
Sat, 2 Apr 2011 14:50:19 +0000 (15:50 +0100)
The current formula to calculate t_info_pages, based on the initial
code, is slightly incorrect. It may allocate more than needed.
Each cpu has some pages/mfns stored as uint32_t.
That list is stored with an offset at tinfo.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
xen/common/trace.c

index a1214a0b32ab7f0e8fa9708f14274d50300bc0cd..a1452ece45960ca1fa9db24eba14db2887d7f546 100644 (file)
@@ -110,7 +110,7 @@ static int calculate_tbuf_size(unsigned int pages)
 {
     struct t_buf dummy;
     typeof(dummy.prod) size;
-    unsigned int t_info_words, t_info_bytes;
+    unsigned int t_info_words;
 
     /* force maximum value for an unsigned type */
     size = -1;
@@ -125,9 +125,8 @@ static int calculate_tbuf_size(unsigned int pages)
         pages = size;
     }
 
-    t_info_words = num_online_cpus() * pages + t_info_first_offset;
-    t_info_bytes = t_info_words * sizeof(uint32_t);
-    t_info_pages = PFN_UP(t_info_bytes);
+    t_info_words = num_online_cpus() * pages * sizeof(uint32_t);
+    t_info_pages = PFN_UP(t_info_first_offset + t_info_words);
     printk(XENLOG_INFO "xentrace: requesting %u t_info pages "
            "for %u trace pages on %u cpus\n",
            t_info_pages, pages, num_online_cpus());