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

Re: [Xen-devel] [PATCH] mm/page_alloc: correct first_dirty calculations during block merging


  • To: Jan Beulich <JBeulich@xxxxxxxx>, Sergey Dyasli <sergey.dyasli@xxxxxxxxxx>
  • From: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
  • Date: Tue, 10 Jul 2018 11:34:14 -0400
  • Autocrypt: addr=boris.ostrovsky@xxxxxxxxxx; prefer-encrypt=mutual; keydata= xsFNBFH8CgsBEAC0KiOi9siOvlXatK2xX99e/J3OvApoYWjieVQ9232Eb7GzCWrItCzP8FUV PQg8rMsSd0OzIvvjbEAvaWLlbs8wa3MtVLysHY/DfqRK9Zvr/RgrsYC6ukOB7igy2PGqZd+M MDnSmVzik0sPvB6xPV7QyFsykEgpnHbvdZAUy/vyys8xgT0PVYR5hyvhyf6VIfGuvqIsvJw5 C8+P71CHI+U/IhsKrLrsiYHpAhQkw+Zvyeml6XSi5w4LXDbF+3oholKYCkPwxmGdK8MUIdkM d7iYdKqiP4W6FKQou/lC3jvOceGupEoDV9botSWEIIlKdtm6C4GfL45RD8V4B9iy24JHPlom woVWc0xBZboQguhauQqrBFooHO3roEeM1pxXjLUbDtH4t3SAI3gt4dpSyT3EvzhyNQVVIxj2 FXnIChrYxR6S0ijSqUKO0cAduenhBrpYbz9qFcB/GyxD+ZWY7OgQKHUZMWapx5bHGQ8bUZz2 SfjZwK+GETGhfkvNMf6zXbZkDq4kKB/ywaKvVPodS1Poa44+B9sxbUp1jMfFtlOJ3AYB0WDS Op3d7F2ry20CIf1Ifh0nIxkQPkTX7aX5rI92oZeu5u038dHUu/dO2EcuCjl1eDMGm5PLHDSP 0QUw5xzk1Y8MG1JQ56PtqReO33inBXG63yTIikJmUXFTw6lLJwARAQABzTNCb3JpcyBPc3Ry b3Zza3kgKFdvcmspIDxib3Jpcy5vc3Ryb3Zza3lAb3JhY2xlLmNvbT7CwXgEEwECACIFAlH8 CgsCGwMGCwkIBwM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d01z+a+oL
  • Cc: George Dunlap <George.Dunlap@xxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Julien Grall <julien.grall@xxxxxxx>, Wei Liu <wei.liu2@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxx
  • Delivery-date: Tue, 10 Jul 2018 15:34:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Openpgp: preference=signencrypt

On 07/10/2018 11:15 AM, Jan Beulich wrote:
>>>> On 10.07.18 at 16:49, <sergey.dyasli@xxxxxxxxxx> wrote:
>> 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>
>> ---
>> CC: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
>> CC: George Dunlap <George.Dunlap@xxxxxxxxxxxxx>
>> CC: Jan Beulich <jbeulich@xxxxxxxx>
>> CC: Julien Grall <julien.grall@xxxxxxx>
>> CC: Wei Liu <wei.liu2@xxxxxxxxxx>
>> CC: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
>> ---
>>  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 20ee1e4897..aa911f2dc5 100644
>> --- a/xen/common/page_alloc.c
>> +++ b/xen/common/page_alloc.c
>> @@ -1426,7 +1426,7 @@ static void free_heap_pages(
>>  
>>              page_list_del(predecessor, &heap(node, zone, order));
>>  
>> -            /* Keep predecessor's first_dirty if it is already set. */
>> +            /* Keep block's first_dirty if the predecessor doesn't have one 
>> */
>>              if ( predecessor->u.free.first_dirty == INVALID_DIRTY_IDX &&
>>                   pg->u.free.first_dirty != INVALID_DIRTY_IDX )
>>                  predecessor->u.free.first_dirty = (1U << order) +
> How about "Convert pg's first_dirty if predecessor doesn't already have
> one"? "Keep" isn't describing well enough what's being done here imo.

"Keep" was used here for the (not provided) "else" clause. But I can see
how it can be confusing.

"Update predecessor's first_dirty if necessary"? Or maybe even drop it.


> Also, despite both styles being okay, I'd prefer to retain the full stop.
>
>> @@ -1447,6 +1447,12 @@ static void free_heap_pages(
>>  
>>              check_and_stop_scrub(successor);
>>  
>> +            /* Keep successor's first_dirty if the block doesn't have one */
>> +            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;
> Same then accordingly here (and both doable while committing,
> provided you agree) and then
> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>


Reviewed-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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