All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Ross Lagerwall <ross.lagerwall@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	xen-devel@lists.xen.org
Subject: Re: [PATCH v1 5/7] tools/livepatch: Remove pointless retry loop
Date: Mon, 12 Dec 2016 17:03:05 +0000	[thread overview]
Message-ID: <20161212170305.GK25175@citrix.com> (raw)
In-Reply-To: <1481559490-13844-6-git-send-email-ross.lagerwall@citrix.com>

On Mon, Dec 12, 2016 at 04:18:08PM +0000, Ross Lagerwall wrote:
> The default timeout in the hypervisor for a livepatch operation is 30 ms,
> but xen-livepatch currently waits for up to 30 seconds for the operation
> to complete. Instead, remove the retry loop and simply wait for 2 * 30 ms
> for the operation to complete. The extra period is to account for the
> time to actually start the operation.
> 
> Furthermore, have xen-livepatch set the hypervisor timeout rather than
> relying on the hypervisor default since the tool doesn't know how long
> it will be. Use nanosleep rather than usleep since usleep has been
> removed from POSIX.1-2008.
> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
> ---
>  tools/misc/xen-livepatch.c | 102 ++++++++++++++++++++++-----------------------
>  1 file changed, 51 insertions(+), 51 deletions(-)
> 
> diff --git a/tools/misc/xen-livepatch.c b/tools/misc/xen-livepatch.c
> index afd8c48..d683860 100644
> --- a/tools/misc/xen-livepatch.c
> +++ b/tools/misc/xen-livepatch.c
> @@ -7,6 +7,7 @@
>  #include <stdio.h>
>  #include <stdlib.h>
>  #include <string.h>
> +#include <time.h>
>  #include <sys/mman.h>
>  #include <sys/stat.h>
>  #include <unistd.h>

Please order the inclusion in alphabetic order.

> @@ -265,17 +266,31 @@ struct {
>      },
>  };
>  
> -/* Go around 300 * 0.1 seconds = 30 seconds. */
> -#define RETRIES 300
> -/* aka 0.1 second */
> -#define DELAY 100000
> +/* The hypervisor timeout for the live patching operation is 30 msec,
> + * but it could take some time for the operation to start, so wait twice
> + * that period. */
> +#define HYPERVISOR_TIMEOUT 30000000 /* in ns */

Use HYPERVISOR_TIMEOUT_NS and remove the comment?

> +#define DELAY (2 * HYPERVISOR_TIMEOUT)
> +
> +static void nanosleep_retry(long ns)
> +{
> +    struct timespec req, rem;
> +    int rc;
> +
> +    rem.tv_sec = 0;
> +    rem.tv_nsec = ns;
> +
> +    do {
> +        req = rem;
> +        rc = nanosleep(&req, &rem);
> +    } while (rc != -1 && errno == EINTR);

Coding style.

And shouldn't it be ( rc == -1 && errno == EINTR ) ?

I don't really have more comment on this approach.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2016-12-12 17:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-12 16:18 [PATCH v1 0/7] xen-livepatch misc fixes/changes Ross Lagerwall
2016-12-12 16:18 ` [PATCH v1 1/7] tools/livepatch: Show the correct expected state before action Ross Lagerwall
2016-12-12 17:02   ` Wei Liu
2016-12-12 16:18 ` [PATCH v1 2/7] tools/livepatch: Set stdout and stderr unbuffered Ross Lagerwall
2016-12-12 17:02   ` Wei Liu
2016-12-14  6:44     ` Ross Lagerwall
2016-12-14  7:43       ` Wei Liu
2016-12-12 16:18 ` [PATCH v1 3/7] tools/livepatch: Improve output Ross Lagerwall
2016-12-12 17:02   ` Wei Liu
2016-12-12 17:11     ` Konrad Rzeszutek Wilk
2016-12-12 16:18 ` [PATCH v1 4/7] livepatch: Set timeout unit to nanoseconds Ross Lagerwall
2016-12-12 17:02   ` Wei Liu
2016-12-12 17:13     ` Konrad Rzeszutek Wilk
2016-12-12 16:18 ` [PATCH v1 5/7] tools/livepatch: Remove pointless retry loop Ross Lagerwall
2016-12-12 17:03   ` Wei Liu [this message]
2016-12-12 16:18 ` [PATCH v1 6/7] tools/livepatch: Remove unused struct member Ross Lagerwall
2016-12-12 17:03   ` Wei Liu
2016-12-12 17:13   ` Konrad Rzeszutek Wilk
2016-12-12 16:18 ` [PATCH v1 7/7] tools/livepatch: Exit with 2 if a timeout occurs Ross Lagerwall
2016-12-12 17:02   ` Wei Liu

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=20161212170305.GK25175@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=ross.lagerwall@citrix.com \
    --cc=xen-devel@lists.xen.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.