Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1390643

Re: [BUG] vfio device assignment regression with THP ref counting redesign

From Andrea Arcangeli <aarcange@redhat.com>
Newsgroups linux.kernel
Subject Re: [BUG] vfio device assignment regression with THP ref counting redesign
Date 2016-04-29 01:30 +0200
Message-ID <rt3xE-46v-7@gated-at.bofh.it> (permalink)
References <rsWZd-6O9-21@gated-at.bofh.it> <rsYHE-8rs-3@gated-at.bofh.it> <rsZkn-mr-29@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hello Alex and Kirill,

On Thu, Apr 28, 2016 at 12:58:08PM -0600, Alex Williamson wrote:
> > > specific fix to this code is not applicable.  It also still occurs on
> > > kernels as recent as v4.6-rc5, so the issue hasn't been silently fixed
> > > yet.  I'm able to reproduce this fairly quickly with the above test,
> > > but it's not hard to imagine a test w/o any iommu dependencies which
> > > simply does a user directed get_user_pages_fast() on a set of userspace
> > > addresses, retains the reference, and at some point later rechecks that
> > > a new get_user_pages_fast() results in the same page address.  It

Can you try to "git revert 1f25fe20a76af0d960172fb104d4b13697cafa84"
and then apply the below patch on top of the revert?

Totally untested... if I missed something and it isn't correct, I hope
this brings us in the right direction faster at least.

Overall the problem I think is that we need to restore full accuracy
and we can't deal with false positive COWs (which aren't entirely
cheap either... reading 512 cachelines should be much faster than
copying 2MB and using 4MB of CPU cache). 32k vs 4MB. The problem of
course is when we really need a COW, we'll waste an additional 32k,
but then it doesn't matter that much as we'd be forced to load 4MB of
cache anyway in such case. There's room for optimizations but even the
simple below patch would be ok for now.

From 09e3d1ff10b49fb9c3ab77f0b96a862848e30067 Mon Sep 17 00:00:00 2001
From: Andrea Arcangeli <aarcange@redhat.com>
Date: Fri, 29 Apr 2016 01:05:06 +0200
Subject: [PATCH 1/1] mm: thp: calculate page_mapcount() correctly for THP
 pages

This allows to revert commit 1f25fe20a76af0d960172fb104d4b13697cafa84
and it provides fully accuracy with wrprotect faults so page pinning
will stop causing false positive copy-on-writes.

Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
---
 mm/util.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/util.c b/mm/util.c
index 6cc81e7..a0b9f63 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -383,9 +383,10 @@ struct address_space *page_mapping(struct page *page)
 /* Slow path of page_mapcount() for compound pages */
 int __page_mapcount(struct page *page)
 {
-	int ret;
+	int ret = 0, i;
 
-	ret = atomic_read(&page->_mapcount) + 1;
+	for (i = 0; i < HPAGE_PMD_NR; i++)
+		ret = max(ret, atomic_read(&page->_mapcount) + 1);
 	page = compound_head(page);
 	ret += atomic_read(compound_mapcount_ptr(page)) + 1;
 	if (PageDoubleMap(page))

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[BUG] vfio device assignment regression with THP ref counting  redesign Alex Williamson <alex.williamson@redhat.com> - 2016-04-28 18:30 +0200
  Re: [BUG] vfio device assignment regression with THP ref counting  redesign "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-04-28 20:20 +0200
    Re: [BUG] vfio device assignment regression with THP ref counting  redesign Alex Williamson <alex.williamson@redhat.com> - 2016-04-28 21:00 +0200
      Re: [BUG] vfio device assignment regression with THP ref counting  redesign Andrea Arcangeli <aarcange@redhat.com> - 2016-04-29 01:30 +0200
        Re: [BUG] vfio device assignment regression with THP ref counting  redesign Alex Williamson <alex.williamson@redhat.com> - 2016-04-29 02:50 +0200
        Re: [BUG] vfio device assignment regression with THP ref counting  redesign "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-04-29 03:00 +0200
          Re: [BUG] vfio device assignment regression with THP ref counting  redesign Alex Williamson <alex.williamson@redhat.com> - 2016-04-29 04:50 +0200
            Re: [BUG] vfio device assignment regression with THP ref counting  redesign "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-04-29 09:10 +0200
              Re: [BUG] vfio device assignment regression with THP ref counting  redesign Alex Williamson <alex.williamson@redhat.com> - 2016-04-29 17:20 +0200
              Re: [BUG] vfio device assignment regression with THP ref counting  redesign Andrea Arcangeli <aarcange@redhat.com> - 2016-04-29 18:40 +0200
                Re: [BUG] vfio device assignment regression with THP ref counting  redesign Alex Williamson <alex.williamson@redhat.com> - 2016-04-30 00:40 +0200
                Re: [BUG] vfio device assignment regression with THP ref counting  redesign "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-05-02 12:50 +0200
                Re: [BUG] vfio device assignment regression with THP ref counting  redesign Jerome Glisse <j.glisse@gmail.com> - 2016-05-02 13:20 +0200
                GUP guarantees wrt to userspace mappings redesign "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-05-02 14:20 +0200
                Re: GUP guarantees wrt to userspace mappings redesign Jerome Glisse <j.glisse@gmail.com> - 2016-05-02 15:40 +0200
                Re: GUP guarantees wrt to userspace mappings "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-05-02 17:10 +0200
                Re: GUP guarantees wrt to userspace mappings Jerome Glisse <j.glisse@gmail.com> - 2016-05-02 17:30 +0200
                Re: GUP guarantees wrt to userspace mappings "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-05-02 18:20 +0200
                Re: GUP guarantees wrt to userspace mappings Andrea Arcangeli <aarcange@redhat.com> - 2016-05-02 21:20 +0200
                Re: GUP guarantees wrt to userspace mappings Andrea Arcangeli <aarcange@redhat.com> - 2016-05-02 21:20 +0200
                Re: GUP guarantees wrt to userspace mappings Andrea Arcangeli <aarcange@redhat.com> - 2016-05-02 21:10 +0200
                Re: GUP guarantees wrt to userspace mappings redesign Oleg Nesterov <oleg@redhat.com> - 2016-05-02 17:20 +0200
                Re: GUP guarantees wrt to userspace mappings redesign "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-05-02 18:30 +0200
                Re: GUP guarantees wrt to userspace mappings redesign Oleg Nesterov <oleg@redhat.com> - 2016-05-02 19:30 +0200
                Re: GUP guarantees wrt to userspace mappings redesign "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-05-02 20:10 +0200
                Re: GUP guarantees wrt to userspace mappings redesign Oleg Nesterov <oleg@redhat.com> - 2016-05-02 20:50 +0200
                Re: GUP guarantees wrt to userspace mappings redesign Andrea Arcangeli <aarcange@redhat.com> - 2016-05-02 21:00 +0200
                Re: [BUG] vfio device assignment regression with THP ref counting  redesign Andrea Arcangeli <aarcange@redhat.com> - 2016-05-02 17:30 +0200
                Re: [BUG] vfio device assignment regression with THP ref counting  redesign "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-05-02 18:10 +0200
                Re: [BUG] vfio device assignment regression with THP ref counting  redesign Andrea Arcangeli <aarcange@redhat.com> - 2016-05-02 20:10 +0200
                Re: [BUG] vfio device assignment regression with THP ref counting  redesign Alex Williamson <alex.williamson@redhat.com> - 2016-05-05 03:20 +0200
                Re: [BUG] vfio device assignment regression with THP ref counting  redesign Andrea Arcangeli <aarcange@redhat.com> - 2016-05-05 16:40 +0200
                Re: [BUG] vfio device assignment regression with THP ref counting  redesign Andrea Arcangeli <aarcange@redhat.com> - 2016-05-05 17:10 +0200
                Re: [BUG] vfio device assignment regression with THP ref counting  redesign "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-05-05 17:20 +0200
                Re: [BUG] vfio device assignment regression with THP ref counting  redesign Andrea Arcangeli <aarcange@redhat.com> - 2016-05-05 17:30 +0200
                Re: [BUG] vfio device assignment regression with THP ref counting  redesign "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-05-06 09:30 +0200

csiph-web