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

Re: xentrace buffer size, maxcpus and online cpus


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Olaf Hering <olaf@xxxxxxxxx>
  • Date: Tue, 30 May 2023 22:06:13 +0200
  • Arc-authentication-results: i=1; strato.com; arc=none; dkim=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1685477181; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-ID:Subject:Cc:To:From:Date:Cc:Date: From:Subject:Sender; bh=uYfGoVSOyGoPL5PshkzxCPvn4zASsscH3kmekFXLH/I=; b=QhRFOeeCj0rQgY7qv+kix7AJPB+uyqyLr2NLKrYF+YzlO30ShpC/pS+DJgiCXwjmpx JeC7GOkaDBhxU2V7pc5Ge7BeifUoBWxYvF9bTyXxHFAkgRaf3mdT9XFdk8cc6teZXnt9 nxb5PSONfnUtjZSjLdwUNZoAYN7DWVQu47z+CofIltxjU3t14MraRGuAXGhzFNy2c1dc eP+8hMuwkNU/Sot/w+zuiFFu0Srsl+3idQng5TbQVl0G5MXa0M8Ha/CZ5yPY0vui5NkZ QnBN1GGLOrKDpaB1iikjNy1voPynQ1BEpmBE1xYYsDfKOwuCWmNq1HSMhwC7KC0jjA63 yLlg==
  • Arc-seal: i=1; a=rsa-sha256; t=1685477181; cv=none; d=strato.com; s=strato-dkim-0002; b=gPMvZ02d8pgWLJXgf0m0QKwKMlGMZYEFBgWC8P5RXNRn591fXKRmJMx8OwdsQm8zY3 9LzQgXWf51Osa6KmhZWrpggVBiqjlfOfBbTKL8QLhvjAHXkFpTLxYFyBI/jdJRB/g00U F5KKKCs/PntPZyi1pNYRgIgpeAdO7Ft09uPLnQzwI/wPlN/o00bBEMaTQ0M+Rx+MM7tn Ua8fsk1DwWR+wzgEKQh2CywATO5wqi6F7+wkDLYCF3RF8hSEbDZQ4g1OUwfhRMHb/0nr tm88QggUsLgFnkUs+jdP6qOOa2NE+CkMxz+VgNa8c3GOJ8UvWv1hREhuBOcXf8jcaN2M USLA==
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 30 May 2023 20:06:33 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Tue, 30 May 2023 10:41:07 +0200 Jan Beulich <jbeulich@xxxxxxxx>:

> Using this N would be correct afaict, but that N isn't num_online_cpus().
> CPUs may have been offlined by the time trace buffers are initialized, so
> without looking too closely I think it would be num_present_cpus() that
> you're after.

In my testing num_online_cpus returns N, while num_present_cpus returns
all available pcpus. There is also num_possible_cpus, but this appears to
be an ARM thing.

If Xen is booted with maxcpus=, is there a way to use the remaining cpus?
In case this is possible, the code needs adjustment to reinitialize the
trace buffers. This is not an easy change. But if the remaining cpus
will remain offline, then something like this may work:

+++ b/xen/common/trace.c
@@ -110,7 +110,8 @@ static int calculate_tbuf_size(unsigned int pages, uint16_t 
t_info_first_offset)
     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 nr_cpus = num_online_cpus();
+    unsigned int max_cpus = nr_cpus;
     unsigned int t_info_words;
 
     /* force maximum value for an unsigned type */
@@ -148,11 +149,11 @@ static int calculate_tbuf_size(unsigned int pages, 
uint16_t t_info_first_offset)
      * NB this calculation is correct, because t_info_first_offset is
      * in words, not bytes
      */
-    t_info_words = nr_cpu_ids * pages + t_info_first_offset;
+    t_info_words = nr_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, nr_cpus);
     return pages;
 }
 


Olaf

Attachment: pgpOGbpOBlBlT.pgp
Description: Digitale Signatur von OpenPGP


 


Rackspace

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