From: Haggai Eran <haggaie@mellanox.com>
To: Jiri Slaby <jslaby@suse.cz>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
linux-mm@kvack.org, Shachar Raindel <raindel@mellanox.com>,
Haggai Eran <haggaie@mellanox.com>, Avi Kivity <avi@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] mm: call invalidate_range_end in do_wp_page even for zero pages
Date: Wed, 19 Sep 2012 17:18:37 +0300 [thread overview]
Message-ID: <1348064317-9943-1-git-send-email-haggaie@mellanox.com> (raw)
In-Reply-To: <5058CE2F.7030302@suse.cz>
The previous patch "mm: wrap calls to set_pte_at_notify with
invalidate_range_start and invalidate_range_end" only called the
invalidate_range_end mmu notifier function in do_wp_page when the new_page
variable wasn't NULL. This was done in order to only call invalidate_range_end
after invalidate_range_start was called. Unfortunately, there are situations
where new_page is NULL and invalidate_range_start is called. This caused
invalidate_range_start to be called without a matching invalidate_range_end,
causing kvm to loop indefinitely on the first page fault.
This patch adds a flag variable to do_wp_page that marks whether the
invalidate_range_start notifier was called. invalidate_range_end is then
called if the flag is true.
Reported-by: Jiri Slaby <jslaby@suse.cz>
Cc: Avi Kivity <avi@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Haggai Eran <haggaie@mellanox.com>
---
I tested this patch against yesterday's linux-next (next-20120918), and it
seems to solve the problem with kvm. I used the same command line you reported:
qemu-kvm -k en-us -usbdevice tablet -balloon virtio -hda IMAGE -smp 2 \
-m 1000M -net user -net nic,model=e1000 -usb -serial pty
I was hoping you could also test it yourself, and see that it also works for
you, if you don't mind.
mm/memory.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/mm/memory.c b/mm/memory.c
index 1a92d87..76ec199 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2529,6 +2529,7 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct *vma,
struct page *dirty_page = NULL;
unsigned long mmun_start; /* For mmu_notifiers */
unsigned long mmun_end; /* For mmu_notifiers */
+ bool mmun_called = false; /* For mmu_notifiers */
old_page = vm_normal_page(vma, address, orig_pte);
if (!old_page) {
@@ -2706,8 +2707,9 @@ gotten:
if (mem_cgroup_newpage_charge(new_page, mm, GFP_KERNEL))
goto oom_free_new;
- mmun_start = address & PAGE_MASK;
- mmun_end = (address & PAGE_MASK) + PAGE_SIZE;
+ mmun_start = address & PAGE_MASK;
+ mmun_end = (address & PAGE_MASK) + PAGE_SIZE;
+ mmun_called = true;
mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end);
/*
@@ -2776,8 +2778,7 @@ gotten:
page_cache_release(new_page);
unlock:
pte_unmap_unlock(page_table, ptl);
- if (new_page)
- /* Only call the end notifier if the begin was called. */
+ if (mmun_called)
mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end);
if (old_page) {
/*
--
1.7.11.2
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2012-09-19 14:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <504F7ED8.1030702@suse.cz>
[not found] ` <20120911190303.GA3626@amt.cnet>
[not found] ` <504F93F1.2060005@suse.cz>
[not found] ` <50504299.2050205@redhat.com>
[not found] ` <50504439.3050700@suse.cz>
[not found] ` <5050453B.6040702@redhat.com>
[not found] ` <5050D048.4010704@suse.cz>
[not found] ` <5051AE8B.7090904@redhat.com>
2012-09-18 19:40 ` qemu-kvm loops after kernel udpate Jiri Slaby
2012-09-18 19:46 ` Andrew Morton
2012-09-19 0:00 ` Stephen Rothwell
2012-09-19 0:20 ` Andrew Morton
2012-09-19 1:36 ` Stephen Rothwell
2012-09-19 14:18 ` Haggai Eran [this message]
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=1348064317-9943-1-git-send-email-haggaie@mellanox.com \
--to=haggaie@mellanox.com \
--cc=akpm@linux-foundation.org \
--cc=avi@redhat.com \
--cc=jslaby@suse.cz \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=raindel@mellanox.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