]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
xen/page_alloc: Don't hold the heap_lock when clearing PGC_need_scrub
authorJulien Grall <jgrall@amazon.com>
Thu, 21 Jan 2021 11:12:00 +0000 (11:12 +0000)
committerJulien Grall <jgrall@amazon.com>
Wed, 7 Apr 2021 18:30:55 +0000 (19:30 +0100)
Currently, the heap_lock is held when clearing PGC_need_scrub in
alloc_heap_pages(). However, this is unnecessary because the only caller
(mark_page_offline()) that can concurrently modify the count_info is
using cmpxchg() in a loop.

Therefore, rework the code to avoid holding the heap_lock and use
test_and_clear_bit() instead.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/common/page_alloc.c

index 1744e6faa5c4fcd2c4c3be3f58d7c8e084aab6d1..ace6333c18ea598ed2614abc34d8b7a97109f378 100644 (file)
@@ -1032,16 +1032,12 @@ static struct page_info *alloc_heap_pages(
     {
         for ( i = 0; i < (1U << order); i++ )
         {
-            if ( test_bit(_PGC_need_scrub, &pg[i].count_info) )
+            if ( test_and_clear_bit(_PGC_need_scrub, &pg[i].count_info) )
             {
                 if ( !(memflags & MEMF_no_scrub) )
                     scrub_one_page(&pg[i]);
 
                 dirty_cnt++;
-
-                spin_lock(&heap_lock);
-                pg[i].count_info &= ~PGC_need_scrub;
-                spin_unlock(&heap_lock);
             }
             else if ( !(memflags & MEMF_no_scrub) )
                 check_one_page(&pg[i]);