From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>,
"George Dunlap" <george.dunlap@citrix.com>
Subject: [PATCH 08/12] x86/paging: deal with log-dirty stats overflow
Date: Fri, 25 Jun 2021 15:21:23 +0200 [thread overview]
Message-ID: <92968d22-f3e2-4eb2-59fe-b1f638c60133@suse.com> (raw)
In-Reply-To: <912fa390-f9e9-198a-9aee-39fdb9a28fcc@suse.com>
While the precise values are unlikely of interest once they exceed 4
billion (allowing us to leave alone the domctl struct), we still
shouldn't wrap or truncate the actual values. It is in particular
problematic if the truncated values were zero (causing libxenguest to
skip an iteration altogether) or a very small value (leading to
premature exiting of the pre-copy phase).
Change the internal fields to unsigned long, and suitably saturate for
copying to guest context.
Signed-off-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/mm/paging.c
+++ b/xen/arch/x86/mm/paging.c
@@ -446,14 +446,16 @@ static int paging_log_dirty_op(struct do
clean = (sc->op == XEN_DOMCTL_SHADOW_OP_CLEAN);
- PAGING_DEBUG(LOGDIRTY, "log-dirty %s: dom %u faults=%u dirty=%u\n",
+ PAGING_DEBUG(LOGDIRTY, "log-dirty %s: dom %u faults=%lu dirty=%lu\n",
(clean) ? "clean" : "peek",
d->domain_id,
d->arch.paging.log_dirty.fault_count,
d->arch.paging.log_dirty.dirty_count);
- sc->stats.fault_count = d->arch.paging.log_dirty.fault_count;
- sc->stats.dirty_count = d->arch.paging.log_dirty.dirty_count;
+ sc->stats.fault_count = min(d->arch.paging.log_dirty.fault_count,
+ UINT32_MAX + 0UL);
+ sc->stats.dirty_count = min(d->arch.paging.log_dirty.dirty_count,
+ UINT32_MAX + 0UL);
if ( guest_handle_is_null(sc->dirty_bitmap) )
/* caller may have wanted just to clean the state or access stats. */
--- a/xen/include/asm-x86/domain.h
+++ b/xen/include/asm-x86/domain.h
@@ -190,8 +190,8 @@ struct log_dirty_domain {
unsigned int failed_allocs;
/* log-dirty mode stats */
- unsigned int fault_count;
- unsigned int dirty_count;
+ unsigned long fault_count;
+ unsigned long dirty_count;
/* functions which are paging mode specific */
const struct log_dirty_ops {
next prev parent reply other threads:[~2021-06-25 13:21 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-25 13:15 [PATCH 00/12] x86: more or less log-dirty related improvements Jan Beulich
2021-06-25 13:17 ` [PATCH 01/12] libxc: split xc_logdirty_control() from xc_shadow_control() Jan Beulich
2021-06-25 14:51 ` Christian Lindig
2021-06-25 15:49 ` Andrew Cooper
2021-06-28 9:40 ` Jan Beulich
2021-06-25 13:18 ` [PATCH 02/12] libxenguest: deal with log-dirty op stats overflow Jan Beulich
2021-06-25 16:36 ` Andrew Cooper
2021-06-28 7:48 ` Jan Beulich
2021-06-28 11:10 ` Olaf Hering
2021-06-28 11:20 ` Jan Beulich
2021-06-28 11:30 ` Olaf Hering
2021-06-25 13:18 ` [PATCH 03/12] libxenguest: short-circuit "all-dirty" handling Jan Beulich
2021-06-25 17:02 ` Andrew Cooper
2021-06-28 8:26 ` Jan Beulich
2021-09-02 17:11 ` Ian Jackson
2021-06-25 13:19 ` [PATCH 04/12] libxenguest: avoid allocating unused deferred-pages bitmap Jan Beulich
2021-06-25 18:08 ` Andrew Cooper
2021-06-28 8:47 ` Jan Beulich
2021-09-02 17:17 ` Ian Jackson
2021-06-25 13:19 ` [PATCH 05/12] libxenguest: complete loops in xc_map_domain_meminfo() Jan Beulich
2021-06-25 18:30 ` Andrew Cooper
2021-06-28 8:53 ` Jan Beulich
2021-06-25 13:20 ` [PATCH 06/12] libxenguest: guard against overflow from too large p2m when checkpointing Jan Beulich
2021-06-25 19:00 ` Andrew Cooper
2021-06-28 9:05 ` Jan Beulich
2021-06-25 13:20 ` [PATCH 07/12] libxenguest: fix off-by-1 in colo-secondary-bitmap merging Jan Beulich
2021-06-25 19:06 ` Andrew Cooper
2021-06-25 13:21 ` Jan Beulich [this message]
2021-06-25 19:09 ` [PATCH 08/12] x86/paging: deal with log-dirty stats overflow Andrew Cooper
2021-06-25 13:21 ` [PATCH 09/12] x86/paging: supply more useful log-dirty page count Jan Beulich
2021-06-25 13:22 ` [PATCH 10/12] x86/mm: update log-dirty bitmap when manipulating P2M Jan Beulich
2021-06-25 13:22 ` [PATCH 11/12] x86/mm: pull a sanity check earlier in xenmem_add_to_physmap_one() Jan Beulich
2021-06-25 19:10 ` Andrew Cooper
2021-06-25 13:24 ` [PATCH 12/12] SUPPORT.md: write down restriction of 32-bit tool stacks Jan Beulich
2021-06-25 19:45 ` Andrew Cooper
2021-06-28 9:22 ` 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=92968d22-f3e2-4eb2-59fe-b1f638c60133@suse.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=george.dunlap@citrix.com \
--cc=roger.pau@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).