File xen.xentrace-74584a367051bc0d6f4b96fd360fa7bc6538fc39.patch of Package xen
From: Olaf Hering <olaf@aepfle.de>
Date: Mon, 19 Jun 2023 12:18:13 +0200
Subject: xentrace 74584a367051bc0d6f4b96fd360fa7bc6538fc39
Revert "xentrace: handle sparse cpu ids correctly in xen trace buffer handling"
This reverts commit 74584a367051bc0d6f4b96fd360fa7bc6538fc39.
---
tools/xentrace/xentrace.c | 2 +-
xen/common/trace.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
--- a/tools/xentrace/xentrace.c
+++ b/tools/xentrace/xentrace.c
@@ -591,25 +591,25 @@ static unsigned int get_num_cpus(void)
{
xc_physinfo_t physinfo;
int ret;
ret = xc_physinfo(xc_handle, &physinfo);
if ( ret != 0 )
{
PERROR("Failure to get logical CPU count from Xen");
exit(EXIT_FAILURE);
}
- return physinfo.max_cpu_id + 1;
+ return physinfo.nr_cpus;
}
/**
* event_init - setup to receive the VIRQ_TBUF event
*/
static void event_init(void)
{
int rc;
xce_handle = xenevtchn_open(NULL, 0);
if (xce_handle == NULL) {
perror("event channel open");
--- a/xen/common/trace.c
+++ b/xen/common/trace.c
@@ -101,25 +101,25 @@ static uint32_t calc_tinfo_first_offset(void)
* in the currently sized struct t_info and allows prod and cons to
* reach double the value without overflow.
* The t_info layout is fixed and cant be changed without breaking xentrace.
* Initialize t_info_pages based on number of trace pages.
*/
static int calculate_tbuf_size(unsigned int pages, uint16_t t_info_first_offset)
{
struct t_buf dummy_size;
typeof(dummy_size.prod) max_size;
struct t_info dummy_pages;
typeof(dummy_pages.tbuf_size) max_pages;
typeof(dummy_pages.mfn_offset[0]) max_mfn_offset;
- unsigned int max_cpus = nr_cpu_ids;
+ unsigned int max_cpus = num_online_cpus();
unsigned int t_info_words;
/* force maximum value for an unsigned type */
max_size = -1;
max_pages = -1;
max_mfn_offset = -1;
/* max size holds up to n pages */
max_size /= PAGE_SIZE;
if ( max_size < max_pages )
max_pages = max_size;
@@ -137,31 +137,31 @@ static int calculate_tbuf_size(unsigned int pages, uint16_t t_info_first_offset)
max_pages = max_mfn_offset;
if ( pages > max_pages )
{
printk(XENLOG_INFO "xentrace: requested number of %u pages "
"reduced to %u\n",
pages, max_pages);
pages = max_pages;
}
/*
* NB this calculation is correct, because t_info_first_offset is
- * in words, not bytes
+ * in words, not bytes, not bytes
*/
- t_info_words = nr_cpu_ids * pages + t_info_first_offset;
+ t_info_words = num_online_cpus() * pages + t_info_first_offset;
t_info_pages = PFN_UP(t_info_words * sizeof(uint32_t));
printk(XENLOG_INFO "xentrace: requesting %u t_info pages "
"for %u trace pages on %u cpus\n",
- t_info_pages, pages, nr_cpu_ids);
+ t_info_pages, pages, num_online_cpus());
return pages;
}
/**
* alloc_trace_bufs - performs initialization of the per-cpu trace buffers.
*
* This function is called at start of day in order to initialize the per-cpu
* trace buffers. The trace buffers are then available for debugging use, via
* the %TRACE_xD macros exported in <xen/trace.h>.
*
* This function may also be called later when enabling trace buffers
* via the SET_SIZE hypercall.