All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim Fehlig <jfehlig@suse.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: wei.liu2@citrix.com, xen-devel@lists.xensource.com,
	Ian.Jackson@eu.citrix.com, mlatimer@suse.com,
	Ian.Campbell@citrix.com
Subject: Re: [PATCH 2/4] libxl_wait_for_memory_target: wait as long	as dom0 is making progress
Date: Fri, 06 Mar 2015 11:10:12 -0700	[thread overview]
Message-ID: <54F9ED84.6030906@suse.com> (raw)
In-Reply-To: <1425380927-10734-2-git-send-email-stefano.stabellini@eu.citrix.com>

Stefano Stabellini wrote:
> Decrement wait_secs only if dom0 is making no progress toward reaching
> the balloon target, otherwise loop again for free.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Tested-by: Mike Latimer <mlatimer@suse.com>
> ---
>  tools/libxl/libxl.c      |   29 ++++++++++++++++++++++-------
>  tools/libxl/xl_cmdimpl.c |    4 ++--
>  2 files changed, 24 insertions(+), 9 deletions(-)
>
> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
> index 088786e..648a227 100644
> --- a/tools/libxl/libxl.c
> +++ b/tools/libxl/libxl.c
> @@ -4959,26 +4959,41 @@ int libxl_wait_for_memory_target(libxl_ctx *ctx, uint32_t domid, int wait_secs)
>   

Would be nice to have a comment clarifying the semantics of wait_secs,
otherwise callers might assume it is the wait time to reach the memory
target vs the wait time if no ballooning progress is being made.

Regards,
Jim

>  {
>      int rc = 0;
>      uint32_t target_memkb = 0;
> +    uint64_t current_memkb, prev_memkb;
>      libxl_dominfo info;
>  
> +    rc = libxl_get_memory_target(ctx, domid, &target_memkb);
> +    if (rc < 0)
> +        return rc;
> +
>      libxl_dominfo_init(&info);
> +    prev_memkb = UINT64_MAX;
>  
>      do {
> -        wait_secs--;
>          sleep(1);
>  
> -        rc = libxl_get_memory_target(ctx, domid, &target_memkb);
> -        if (rc < 0)
> -            goto out;
> -
>          libxl_dominfo_dispose(&info);
>          libxl_dominfo_init(&info);
>          rc = libxl_domain_info(ctx, &info, domid);
>          if (rc < 0)
>              goto out;
> -    } while (wait_secs > 0 && (info.current_memkb + info.outstanding_memkb) > target_memkb);
>  
> -    if ((info.current_memkb + info.outstanding_memkb) <= target_memkb)
> +        current_memkb = info.current_memkb + info.outstanding_memkb;
> +
> +        if (current_memkb > prev_memkb)
> +        {
> +            rc = ERROR_FAIL;
> +            goto out;
> +        }
> +        else if (current_memkb == prev_memkb)
> +            wait_secs--;
> +        /* if current_memkb < prev_memkb loop for free as progress has
> +         * been made */
> +
> +        prev_memkb = current_memkb;
> +    } while (wait_secs > 0 && current_memkb > target_memkb);
> +
> +    if (current_memkb <= target_memkb)
>          rc = 0;
>      else
>          rc = ERROR_FAIL;
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> index f4c4122..2dc7574 100644
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -2226,8 +2226,8 @@ static int freemem(uint32_t domid, libxl_domain_build_info *b_info)
>          else if (rc != ERROR_NOMEM)
>              return rc;
>  
> -        /* the memory target has been reached but the free memory is still
> -         * not enough: loop over again */
> +        /* wait until dom0 reaches its target, as long as we are making
> +         * progress */
>          rc = libxl_wait_for_memory_target(ctx, 0, 1);
>          if (rc < 0)
>              return rc;
>   

  reply	other threads:[~2015-03-06 18:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-03 11:08 [PATCH 0/4] fix freemem loop Stefano Stabellini
2015-03-03 11:08 ` [PATCH 1/4] Revert "libxl: Wait for ballooning if free memory is increasing" Stefano Stabellini
2015-03-03 11:08 ` [PATCH 2/4] libxl_wait_for_memory_target: wait as long as dom0 is making progress Stefano Stabellini
2015-03-06 18:10   ` Jim Fehlig [this message]
2015-03-03 11:08 ` [PATCH 3/4] freemem: remove call to libxl_wait_for_free_memory Stefano Stabellini
2015-03-03 11:08 ` [PATCH 4/4] libxl_wait_for_memory_target: wait for 2 sec at a time Stefano Stabellini
2015-03-03 21:54 ` [PATCH 0/4] fix freemem loop Mike Latimer
2015-03-04 23:55   ` Mike Latimer
2015-03-05 17:49 ` Ian Campbell
2015-03-06  4:08   ` Mike Latimer
2015-03-06  9:46     ` Ian Campbell
2015-03-06  9:52       ` Stefano Stabellini
2015-03-06 10:13         ` Ian Campbell
2015-03-06 10:22           ` Stefano Stabellini
2015-03-06 10:45             ` Ian Campbell
2015-03-06 17:58             ` Jim Fehlig
2015-03-06  9:48   ` Stefano Stabellini
2015-03-06  9:59     ` Ian Campbell

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=54F9ED84.6030906@suse.com \
    --to=jfehlig@suse.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=mlatimer@suse.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /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.