[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen staging-4.10] mm/page_alloc: correct first_dirty calculations during block merging



commit bc1289f1e7ac7427072cd9674176074afc2d324c
Author:     Sergey Dyasli <sergey.dyasli@xxxxxxxxxx>
AuthorDate: Mon Jul 30 11:36:21 2018 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Jul 30 11:36:21 2018 +0200

    mm/page_alloc: correct first_dirty calculations during block merging
    
    Currently it's possible to hit an assertion in alloc_heap_pages():
    
    Assertion 'first_dirty != INVALID_DIRTY_IDX || !(pg[i].count_info & 
PGC_need_scrub)' failed at page_alloc.c:988
    
    This can happen because a piece of logic to calculate first_dirty
    during block merging in free_heap_pages() is missing for the following
    scenario:
    
    1. Current block's first_dirty equals to INVALID_DIRTY_IDX
    2. Successor block is free but its first_dirty != INVALID_DIRTY_IDX
    3. The successor is merged into current block
    4. Current block's first_dirty still equals to INVALID_DIRTY_IDX
    
    This will trigger the assertion during allocation of such block in
    alloc_heap_pages() because there will be pages with PGC_need_scrub
    bit set despite the claim of first_dirty that the block is scrubbed.
    
    Add the missing piece of logic and slightly update the comment for
    the predecessor case to better capture the code's intent.
    
    Fixes 1a37f33ea613 ("mm: Place unscrubbed pages at the end of pagelist")
    
    Signed-off-by: Sergey Dyasli <sergey.dyasli@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
    master commit: 1e2df9608857b5355f2ec3b1a34b87a2007dcd16
    master date: 2018-07-12 10:45:11 +0200
---
 xen/common/page_alloc.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index 49b2a91751..6d6f2a0628 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -1424,7 +1424,7 @@ static void free_heap_pages(
 
             page_list_del(predecessor, &heap(node, zone, order));
 
-            /* Keep predecessor's first_dirty if it is already set. */
+            /* Update predecessor's first_dirty if necessary. */
             if ( predecessor->u.free.first_dirty == INVALID_DIRTY_IDX &&
                  pg->u.free.first_dirty != INVALID_DIRTY_IDX )
                 predecessor->u.free.first_dirty = (1U << order) +
@@ -1445,6 +1445,12 @@ static void free_heap_pages(
 
             check_and_stop_scrub(successor);
 
+            /* Update pg's first_dirty if necessary. */
+            if ( pg->u.free.first_dirty == INVALID_DIRTY_IDX &&
+                 successor->u.free.first_dirty != INVALID_DIRTY_IDX )
+                pg->u.free.first_dirty = (1U << order) +
+                                         successor->u.free.first_dirty;
+
             page_list_del(successor, &heap(node, zone, order));
         }
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.10

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.