From: Olaf Hering <olaf@aepfle.de>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
Ian Jackson <iwj@xenproject.org>, Wei Liu <wl@xen.org>,
Juergen Gross <jgross@suse.com>, Jan Beulich <JBeulich@suse.com>
Subject: Re: [PATCH 2/2] tools/migration: Fix potential overflow in send_checkpoint_dirty_pfn_list()
Date: Tue, 6 Jul 2021 14:58:04 +0200 [thread overview]
Message-ID: <20210706145804.1ab98f16.olaf@aepfle.de> (raw)
In-Reply-To: <20210706112332.31753-3-andrew.cooper3@citrix.com>
[-- Attachment #1.1: Type: text/plain, Size: 883 bytes --]
Am Tue, 6 Jul 2021 12:23:32 +0100
schrieb Andrew Cooper <andrew.cooper3@citrix.com>:
> + count = stats.dirty_count;
Is this accurate?
I remember the reporting is broken since a while, and testing a busy domU indicates it is still the case.
# xen-logdirty `xl domid domU`
0: faults= 0 dirty= 258050
1: faults= 0 dirty= 257817
2: faults= 0 dirty= 253713
3: faults= 0 dirty= 253197
4: faults= 0 dirty= 255154
5: faults= 0 dirty= 260876
6: faults= 0 dirty= 259083
7: faults= 0 dirty= 253163
8: faults= 0 dirty= 258349
9: faults= 0 dirty= 260330
10: faults= 0 dirty= 259754
11: faults= 0 dirty= 257273
12: faults= 0 dirty= 255756
13: faults= 0 dirty= 258209
14: faults= 0 dirty= 257847
15: faults= 0 dirty= 59639
16: faults= 0 dirty= 81
17: faults= 0 dirty= 86
18: faults= 0 dirty= 111
19: faults= 0 dirty= 81
20: faults= 0 dirty= 80
....
Olaf
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: logdirty.c --]
[-- Type: text/x-c++src, Size: 3186 bytes --]
/* gcc -Wall -o logdirty -O -lxenctrl logdirty.c */
#include <unistd.h>
#include <errno.h>
#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <xenctrl.h>
#include <signal.h>
#define PAGE_SHIFT XC_PAGE_SHIFT
#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
#define NRPAGES(x) (ROUNDUP(x, PAGE_SHIFT) >> PAGE_SHIFT)
#define BITS_PER_LONG (sizeof(unsigned long) * 8)
#define ORDER_LONG (sizeof(unsigned long) == 4 ? 5 : 6)
static unsigned int domid = 0;
static xc_interface *xch;
static unsigned long xdmg(xc_interface *c, unsigned int d)
{
unsigned long r;
#if XEN_DOMCTL_INTERFACE_VERSION < 0x0b
r = xc_domain_maximum_gpfn(c, d);
#else
xen_pfn_t gpfns = 0;
r = xc_domain_maximum_gpfn(c, d, &gpfns);
#endif
return r + 1;
}
static void sigint_handler(int sig)
{
int rc;
fprintf(stderr, "User aborted\n");
rc = xc_shadow_control(xch, domid, XEN_DOMCTL_SHADOW_OP_OFF, NULL, 0, NULL, 0, NULL);
if (rc < 0)
perror("XEN_DOMCTL_SHADOW_OP_OFF hypercall failed\n");
exit(1);
}
static inline int bitmap_size(int nr_bits)
{
int nr_long, nr_bytes;
nr_long = (nr_bits + BITS_PER_LONG - 1) >> ORDER_LONG;
nr_bytes = nr_long * sizeof(unsigned long);
return nr_bytes;
}
int main(int argc, char *argv[])
{
int rc, ret = 1, i, runs = 42;
unsigned int lflags;
xentoollog_level lvl;
xentoollog_logger *l;
DECLARE_HYPERCALL_BUFFER(unsigned long, to_skip);
unsigned long p2m_size;
xc_shadow_op_stats_t stats;
errno = EINVAL;
if (argc > 1)
domid = atoi(argv[1]);
if (!domid)
goto out;
if (argc > 2)
runs = atoi(argv[2]);
if (!runs)
goto out;
errno = 0;
lvl = XTL_DEBUG;
lflags = XTL_STDIOSTREAM_SHOW_PID | XTL_STDIOSTREAM_HIDE_PROGRESS;
l = (xentoollog_logger *) xtl_createlogger_stdiostream(stderr, lvl, lflags);
if (!l)
goto out;
xch = xc_interface_open(l, 0, 0);
if (!xch)
goto out;
p2m_size = xdmg(xch, domid);
if (!p2m_size)
goto out;
to_skip = xc_hypercall_buffer_alloc_pages(xch, to_skip, NRPAGES(bitmap_size(p2m_size)));
if (!to_skip)
goto out;
signal(SIGINT, sigint_handler);
rc = xc_shadow_control(xch, domid, XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY, NULL, 0, NULL, 0, NULL);
if (rc < 0) {
rc = xc_shadow_control(xch, domid, XEN_DOMCTL_SHADOW_OP_OFF, NULL, 0, NULL, 0, NULL);
if (rc < 0)
goto out;
rc = xc_shadow_control(xch, domid, XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY, NULL, 0, NULL, 0, NULL);
if (rc < 0)
goto out;
}
rc = xc_shadow_control(xch, domid, XEN_DOMCTL_SHADOW_OP_CLEAN, NULL, 0, NULL, 0, NULL);
if (rc < 0)
goto out;
for (i = 0; i < runs; i++) {
sleep(1);
if (1)
rc = xc_shadow_control(xch, domid, XEN_DOMCTL_SHADOW_OP_CLEAN, HYPERCALL_BUFFER(to_skip), p2m_size, NULL, 0, &stats);
if (rc < 0)
goto out;
printf("%d: faults= %" PRIu32 " dirty= %" PRIu32 "\n", i, stats.fault_count, stats.dirty_count);
}
rc = xc_shadow_control(xch, domid, XEN_DOMCTL_SHADOW_OP_OFF, NULL, 0, NULL, 0, NULL);
if (rc < 0)
goto out;
errno = ret = 0;
out:
perror(argv[0]);
return ret;
}
[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2021-07-06 12:58 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-06 11:23 [PATCH 0/2] tools/migration: Fixes in send_checkpoint_dirty_pfn_list() Andrew Cooper
2021-07-06 11:23 ` [PATCH 1/2] tools/migration: Fix iovec handling " Andrew Cooper
2021-07-06 11:54 ` Jan Beulich
2021-07-06 12:20 ` Olaf Hering
2021-07-06 11:23 ` [PATCH 2/2] tools/migration: Fix potential overflow " Andrew Cooper
2021-07-06 12:03 ` Jan Beulich
2021-07-06 13:34 ` Andrew Cooper
2021-07-06 14:00 ` Jan Beulich
2021-07-06 12:58 ` Olaf Hering [this message]
2021-07-06 13:19 ` Andrew Cooper
2021-07-06 13:22 ` Andrew Cooper
2021-07-06 13:39 ` Olaf Hering
2021-07-06 13:43 ` Andrew Cooper
2021-07-06 13:28 ` Olaf Hering
2021-07-06 13:56 ` Jan Beulich
2021-07-06 14:11 ` Olaf Hering
2021-07-06 15:13 ` Jan Beulich
2021-07-06 15:22 ` Jan Beulich
2021-07-06 16:08 ` Andrew Cooper
2021-07-06 12:07 ` [PATCH 0/2] tools/migration: Fixes " Jan Beulich
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=20210706145804.1ab98f16.olaf@aepfle.de \
--to=olaf@aepfle.de \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=iwj@xenproject.org \
--cc=jgross@suse.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.