From: Alejandro Vallejo <alejandro.vallejo@cloud.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Alejandro Vallejo <alejandro.vallejo@cloud.com>,
Andrew Cooper <andrew.cooper3@citrix.com>, Wei Liu <wl@xen.org>,
Anthony PERARD <anthony.perard@citrix.com>
Subject: [PATCH 3/7] tools: Refactor the console/io.c to avoid using xc_domain_getinfo()
Date: Wed, 26 Apr 2023 15:59:28 +0100 [thread overview]
Message-ID: <20230426145932.3340-4-alejandro.vallejo@cloud.com> (raw)
In-Reply-To: <20230426145932.3340-1-alejandro.vallejo@cloud.com>
It has 2 avoidable occurences
* Check whether a domain is valid, which can be done faster with
xc_domain_getinfo_single()
* Domain discovery, which can be done much faster with the sysctl
interface through xc_domain_getinfolist().
Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Wei Liu <wl@xen.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>
---
tools/console/daemon/io.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 6bfe96715b..1fc56f6643 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -405,13 +405,7 @@ static void buffer_advance(struct buffer *buffer, size_t len)
static bool domain_is_valid(int domid)
{
- bool ret;
- xc_dominfo_t info;
-
- ret = (xc_domain_getinfo(xc, domid, 1, &info) == 1 &&
- info.domid == domid);
-
- return ret;
+ return xc_domain_getinfo_single(xc, domid, NULL) == 0;
}
static int create_hv_log(void)
@@ -959,26 +953,35 @@ static void shutdown_domain(struct domain *d)
static unsigned enum_pass = 0;
+/**
+ * Memory set aside to query the state of every
+ * domain in the hypervisor in a single hypercall.
+ */
+static xc_domaininfo_t domaininfo[DOMID_FIRST_RESERVED - 1];
+
static void enum_domains(void)
{
- int domid = 1;
- xc_dominfo_t dominfo;
+ int ret;
struct domain *dom;
enum_pass++;
- while (xc_domain_getinfo(xc, domid, 1, &dominfo) == 1) {
- dom = lookup_domain(dominfo.domid);
- if (dominfo.dying) {
+ /* Fetch info on every valid domain except for dom0 */
+ ret = xc_domain_getinfolist(xc, 1, DOMID_FIRST_RESERVED - 1, domaininfo);
+ if (ret < 0)
+ return;
+
+ for (size_t i = 0; i < ret; i++) {
+ dom = lookup_domain(domaininfo[i].domain);
+ if (domaininfo[i].flags & XEN_DOMINF_dying) {
if (dom)
shutdown_domain(dom);
} else {
if (dom == NULL)
- dom = create_domain(dominfo.domid);
+ dom = create_domain(domaininfo[i].domain);
}
if (dom)
dom->last_seen = enum_pass;
- domid = dominfo.domid + 1;
}
}
--
2.34.1
next prev parent reply other threads:[~2023-04-26 15:00 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-26 14:59 [PATCH 0/7] Rationalize usage of xc_domain_getinfo{,list}() Alejandro Vallejo
2023-04-26 14:59 ` [PATCH 1/7] tools: Make some callers of xc_domain_getinfo use xc_domain_getinfolist Alejandro Vallejo
2023-04-27 9:51 ` Andrew Cooper
2023-04-27 14:37 ` Alejandro Vallejo
2023-04-26 14:59 ` [PATCH 2/7] tools: Create xc_domain_getinfo_single() Alejandro Vallejo
2023-04-27 9:53 ` Andrew Cooper
2023-04-26 14:59 ` Alejandro Vallejo [this message]
2023-04-27 10:36 ` [PATCH 3/7] tools: Refactor the console/io.c to avoid using xc_domain_getinfo() Andrew Cooper
2023-04-26 14:59 ` [PATCH 4/7] tools: Make init-xenstore-domain use xc_domain_getinfolist() Alejandro Vallejo
2023-04-26 15:20 ` Juergen Gross
2023-04-27 14:29 ` Alejandro Vallejo
2023-04-26 14:59 ` [PATCH 5/7] tools: Modify single-domid callers of xc_domain_getinfolist Alejandro Vallejo
2023-04-27 11:14 ` Andrew Cooper
2023-04-26 14:59 ` [PATCH 6/7] tools: Use new xc function for some xc_domain_getinfo calls Alejandro Vallejo
2023-04-27 12:35 ` Andrew Cooper
2023-04-27 18:07 ` Alejandro Vallejo
2023-04-26 14:59 ` [PATCH 7/7] domctl: Modify getdomaininfo to fail if domid is not found Alejandro Vallejo
2023-04-27 11:15 ` Andrew Cooper
2023-04-26 22:30 ` Gitlab curiosity: Was [PATCH 0/7] Rationalize usage of xc_domain_getinfo{,list}() Andrew Cooper
2023-04-27 9:26 ` Andrew Cooper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230426145932.3340-4-alejandro.vallejo@cloud.com \
--to=alejandro.vallejo@cloud.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@citrix.com \
--cc=wl@xen.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.