From: David Hildenbrand <david@redhat.com>
To: qemu-devel@nongnu.org
Cc: David Hildenbrand <david@redhat.com>,
Juan Quintela <quintela@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Peter Xu <peterx@redhat.com>,
Andrey Gruzdev <andrey.gruzdev@virtuozzo.com>
Subject: [PATCH v1 3/5] migration/ram: Don't explicitly unprotect when unregistering uffd-wp
Date: Thu, 5 Jan 2023 13:45:26 +0100 [thread overview]
Message-ID: <20230105124528.93813-4-david@redhat.com> (raw)
In-Reply-To: <20230105124528.93813-1-david@redhat.com>
When unregistering uffd-wp, older kernels before commit f369b07c86143
("mm/uffd:reset write protection when unregister with wp-mode") won't
clear the uffd-wp PTE bit. When re-registering uffd-wp, the previous
uffd-wp PTE bits would trigger again. With above commit, the kernel will
clear the uffd-wp PTE bits when unregistering itself.
Consequently, we'll clear the uffd-wp PTE bits now twice -- whereby we
don't care about clearing them at all: a new background snapshot will
re-register uffd-wp and re-protect all memory either way.
So let's skip the manual clearing of uffd-wp. If ever relevant, we
could clear conditionally in uffd_unregister_memory() -- we just need a
way to figure out more recent kernels.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
migration/ram.c | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/migration/ram.c b/migration/ram.c
index 6e4e41952a..6a3dbee2c3 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1918,12 +1918,6 @@ fail:
if ((block->flags & RAM_UF_WRITEPROTECT) == 0) {
continue;
}
- /*
- * In case some memory block failed to be write-protected
- * remove protection and unregister all succeeded RAM blocks
- */
- uffd_change_protection(rs->uffdio_fd, block->host, block->max_length,
- false, false);
uffd_unregister_memory(rs->uffdio_fd, block->host, block->max_length);
/* Cleanup flags and remove reference */
block->flags &= ~RAM_UF_WRITEPROTECT;
@@ -1949,9 +1943,6 @@ void ram_write_tracking_stop(void)
if ((block->flags & RAM_UF_WRITEPROTECT) == 0) {
continue;
}
- /* Remove protection and unregister all affected RAM blocks */
- uffd_change_protection(rs->uffdio_fd, block->host, block->max_length,
- false, false);
uffd_unregister_memory(rs->uffdio_fd, block->host, block->max_length);
trace_ram_write_tracking_ramblock_stop(block->idstr, block->page_size,
--
2.39.0
next prev parent reply other threads:[~2023-01-05 12:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-05 12:45 [PATCH v1 0/5] migration/ram: background snapshot fixes and optimiations David Hildenbrand
2023-01-05 12:45 ` [PATCH v1 1/5] migration/ram: Fix populate_read_range() David Hildenbrand
2023-02-02 11:15 ` Juan Quintela
2023-01-05 12:45 ` [PATCH v1 2/5] migration/ram: Fix error handling in ram_write_tracking_start() David Hildenbrand
2023-02-02 11:16 ` Juan Quintela
2023-01-05 12:45 ` David Hildenbrand [this message]
2023-02-02 11:17 ` [PATCH v1 3/5] migration/ram: Don't explicitly unprotect when unregistering uffd-wp Juan Quintela
2023-01-05 12:45 ` [PATCH v1 4/5] migration/ram: Rely on used_length for uffd_change_protection() David Hildenbrand
2023-02-02 11:18 ` Juan Quintela
2023-01-05 12:45 ` [PATCH v1 5/5] migration/ram: Optimize ram_write_tracking_start() for RamDiscardManager David Hildenbrand
2023-02-02 11:20 ` Juan Quintela
2023-01-05 21:11 ` [PATCH v1 0/5] migration/ram: background snapshot fixes and optimiations Peter Xu
2023-01-09 8:37 ` David Hildenbrand
2023-01-23 14:27 ` David Hildenbrand
2023-02-02 11:21 ` Juan Quintela
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=20230105124528.93813-4-david@redhat.com \
--to=david@redhat.com \
--cc=andrey.gruzdev@virtuozzo.com \
--cc=dgilbert@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.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 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).