All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: xen-devel@lists.xen.org
Cc: sstabellini@kernel.org, wei.liu2@citrix.com,
	George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com,
	ian.jackson@eu.citrix.com, tim@xen.org, jbeulich@suse.com,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>
Subject: [PATCH 4/4] mm: Don't hold heap lock in alloc_heap_pages() longer than necessary
Date: Mon, 28 Aug 2017 16:40:29 -0400	[thread overview]
Message-ID: <1503952829-11065-5-git-send-email-boris.ostrovsky@oracle.com> (raw)
In-Reply-To: <1503952829-11065-1-git-send-email-boris.ostrovsky@oracle.com>

Once pages are removed from the heap we don't need to hold the heap
lock. It is especially useful to drop it for an unscrubbed buddy since
we will be scrubbing it.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
---
 xen/common/page_alloc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index b93dae9..1ec788e 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -858,6 +858,7 @@ static struct page_info *alloc_heap_pages(
     struct page_info *pg;
     bool need_tlbflush = false;
     uint32_t tlbflush_timestamp = 0;
+    unsigned int dirty_cnt = 0;
 
     /* Make sure there are enough bits in memflags for nodeID. */
     BUILD_BUG_ON((_MEMF_bits - _MEMF_node) < (8 * sizeof(nodeid_t)));
@@ -943,6 +944,8 @@ static struct page_info *alloc_heap_pages(
 
     check_low_mem_virq();
 
+    spin_unlock(&heap_lock);
+
     if ( d != NULL )
         d->last_alloc_node = node;
 
@@ -955,7 +958,7 @@ static struct page_info *alloc_heap_pages(
         {
             if ( !(memflags & MEMF_no_scrub) )
                 scrub_one_page(&pg[i]);
-            node_need_scrub[node]--;
+            dirty_cnt++;
         }
 
         pg[i].count_info = PGC_state_inuse;
@@ -977,6 +980,8 @@ static struct page_info *alloc_heap_pages(
             check_one_page(&pg[i]);
     }
 
+    spin_lock(&heap_lock);
+    node_need_scrub[node] -= dirty_cnt;
     spin_unlock(&heap_lock);
 
     if ( need_tlbflush )
-- 
1.8.3.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-08-28 20:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28 20:40 [PATCH 0/4] Scrubbing updates Boris Ostrovsky
2017-08-28 20:40 ` [PATCH 1/4] mm: Initialize lowmem virq when boot-time scrubbing is disabled Boris Ostrovsky
2017-08-29 11:51   ` Wei Liu
2017-08-29 13:12     ` Boris Ostrovsky
2017-08-29 13:20       ` Jan Beulich
2017-08-29 13:19     ` Jan Beulich
2017-08-28 20:40 ` [PATCH 2/4] mm: Don't poison a page if boot-time scrubbing is off Boris Ostrovsky
2017-08-29 11:52   ` Wei Liu
2017-08-28 20:40 ` [PATCH 3/4] mm: Don't request scrubbing until dom0 is running Boris Ostrovsky
2017-08-29 11:56   ` Wei Liu
2017-08-29 13:22     ` Jan Beulich
2017-08-29 13:27       ` Boris Ostrovsky
2017-08-29 13:34         ` Jan Beulich
2017-08-29 14:20           ` Boris Ostrovsky
2017-08-29 14:25             ` Jan Beulich
2017-08-29 13:26   ` Jan Beulich
2017-08-29 13:31     ` Wei Liu
2017-08-28 20:40 ` Boris Ostrovsky [this message]
2017-08-29 12:16   ` [PATCH 4/4] mm: Don't hold heap lock in alloc_heap_pages() longer than necessary Wei Liu
2017-08-29 13:33   ` Jan Beulich

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=1503952829-11065-5-git-send-email-boris.ostrovsky@oracle.com \
    --to=boris.ostrovsky@oracle.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.