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

Re: [PATCH 3/7] tools: Refactor the console/io.c to avoid using xc_domain_getinfo()


  • To: Alejandro Vallejo <alejandro.vallejo@xxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Thu, 27 Apr 2023 11:36:22 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3iNQPhyiP0Ij1u2HvRwvPqHUNERwQ0Zytpd+yZyPP5s=; b=CUpK8kC6b6MJjoXCKzc/m0gYQ/jT4esg6CKXXEyl1Ot+vWK+kRYhG0Fhyo5prL7Bl3IT/GmEtQs2qurtdPUfOsmejTzl9GwIJjD4dI1aMmiYCGDkrEIk2kXxD/tzmUsWXcVwldAQAr78abOeFPXG9lfDzQ84Um7LwtKX1XYLJi3VxH1SwJgjLGX1CPL6HKDeZPI4oWZinAlEJ3QCc/Z45lVPjiog73T/8XIDxKVe+NzpnqFAUHhV7/f7HSHCag6eBdgJ2iSReYeQcUGgpVVZApTN1vMaKAY/osdQR2MsemgLQxixPpm3QvmagiDLNsQ3qLHuHGPHuvQnj/cWcVTfqA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IlOZu7Z5kQ000+YzhT+aywnpb5eJ59UruwG7gk8tPde2c0Htx2oV+RwFC0glTlU/sFxx3NLPy+2/f6nKWIlwyQXmcqnoEaRa7mKRzPMPwwKsf02byNH0CfKa8SgJrdIyu7Cv+PUiXNM3P71gZFl1cl00n1yRh3tszNIW3AdcWsXDkIe7ZSvKLopgWT19Sg6MY/GPjSNapr2cfVefADyl2imv63/RrUOrFYyAnzjbjFmgOUuaowVtGALpMHBs6iAOGM5JFLeJQTmD99EdhHzzQ9MAeS9nt913fh0gdEKUveRSLXJJsj6/SZ6k4F6gxw5eqBPabJS743mmgRZyNLLYFg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Thu, 27 Apr 2023 10:37:01 +0000
  • Ironport-data: A9a23:gC5bTa20Q/3BqtAdnfbD5eRwkn2cJEfYwER7XKvMYLTBsI5bpzwPn zYcDWDXPKvfa2P9eYt3a9jk/UlQsJaGy4RiHQs5pC1hF35El5HIVI+TRqvS04F+DeWYFR46s J9OAjXkBJppJpMJjk71atANlVEliefTAOK6ULWeUsxIbVcMYD87jh5+kPIOjIdtgNyoayuAo tq3qMDEULOf82cc3lk8tuTS+XuDgNyo4GlD5gBkOqgR1LPjvyJ94Kw3dPnZw0TQGuG4LsbiL 87fwbew+H/u/htFIrtJRZ6iLyXm6paLVeS/oiI+t5qK23CulQRrukoPD9IOaF8/ttm8t4sZJ OOhF3CHYVxB0qXkwIzxWvTDes10FfUuFLTveRBTvSEPpqFvnrSFL/hGVSkL0YMkFulfOkN+0 axfOhs0ZUrAtbO6xaCVZfNCr5F2RCXrFNt3VnBI6xj8VK9jareaBqLA6JlfwSs6gd1IEbDGf c0FZDFzbRPGJRpSJlMQD5F4l+Ct7pX9W2QA9BTJ+uxqvS6Kk1UZPLvFabI5fvSjQ8lPk1nej WXB52njWTkRNcCFyCrD+XWp7gPKtXqjBdJIT+DprpaGhnWjmzENSxs0FmCn4vqgj27iRv5jG xc9r39GQa8asRbDosPGdxS8rXyNuBIGXJxOGuk+5QOK4qHQ5BuVQGMDS1ZpeNEg8cM7WzEu/ luIhM/yQyxitqWPTnCQ/avSqim9UQAKKUcSaClCShEKi+QPu6k2hxPLC91kSai8i4SsHSmqm m/T6i8jm78UkMgHkb2h+kzKiC6toZ6PSRMp4gLQXSSu6QYRiJOZWrFEIGPztZ5oRLt1hHHb1 JTYs6ByNNwzMKw=
  • Ironport-hdrordr: A9a23:+6kV56ja0/0zLGTxIX6vQxBUCnBQXhMji2hC6mlwRA09TyVXrb HXoB0+726KtN9xYgBdpTnkAsW9qBznhPlICOUqTNGftUrdyRiVxeJZnPbfKl/balfDH7VmpN ddmsFFYbWaZzUa/KOKhDVQeOxQu+VvnprY/Ns2iE0McehtUc4PnmQJaDqzIwlTTAlCBZ02UL +d/NcvnUvTRZ0OVLXLOpAaZZm8m+H2
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 26/04/2023 3:59 pm, Alejandro Vallejo wrote:
> 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@xxxxxxxxx>
> ---
> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> Cc: Wei Liu <wl@xxxxxxx>
> Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>
> ---
>  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];
> +

We prefer to reduce scope where possible, and in this case it's fine to
have this declared inside enum_domains().  Preferred style for that
would be:

static void enum_domains(void)
{
    /**
     * 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];

    int ret;
    struct domain *dom;


i.e. one blank line between the static and local variable declarations.

>  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);

This is a correct translation of the prior logic.

But it does highlight that xenconsoled currently depends on running in
dom0.  I bet this is going to be fun bug for someone down the line...

Also, while going for 32k entries is absolutely the right thing to do,
the entire buffer will be bounced twice to make it hypercall safe. 
Bordering on 4M of data, I think this is quickly going to become a
second improvement to work on.

~Andrew



 


Rackspace

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