From: Bob Liu Subject: [PATCH 1/2] xen: introduce a no lock version function of free_heap_pages Date: Tue, 10 Jun 2014 20:18:36 +0800 Message-ID: <1402402717-26736-1-git-send-email-bob.liu@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WuL0s-0007iK-AK for xen-devel@lists.xenproject.org; Tue, 10 Jun 2014 12:18:50 +0000 Received: by mail-pd0-f177.google.com with SMTP id g10so6017184pdj.22 for ; Tue, 10 Jun 2014 05:18:45 -0700 (PDT) List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: keir@xen.org, ian.campbell@citrix.com, andrew.cooper3@citrix.com, jbeulich@suse.com List-Id: xen-devel@lists.xenproject.org Function free_heap_pages() needs to get the heap_lock every time. This lock may become a problem when there are many CPUs trying to free pages in parallel. This patch introduces a no lock version function __free_heap_pages(), it can be used to free a batch of pages after grabbing the heap_lock. Signed-off-by: Bob Liu --- xen/common/page_alloc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 601319c..56826b4 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -808,8 +808,8 @@ static int reserve_offlined_page(struct page_info *head) return count; } -/* Free 2^@order set of pages. */ -static void free_heap_pages( +/* No lock version, the caller must hold heap_lock */ +static void __free_heap_pages( struct page_info *pg, unsigned int order) { unsigned long mask, mfn = page_to_mfn(pg); @@ -819,8 +819,6 @@ static void free_heap_pages( ASSERT(order <= MAX_ORDER); ASSERT(node >= 0); - spin_lock(&heap_lock); - for ( i = 0; i < (1 << order); i++ ) { /* @@ -894,7 +892,14 @@ static void free_heap_pages( if ( tainted ) reserve_offlined_page(pg); +} +/* Free 2^@order set of pages. */ +static void free_heap_pages( + struct page_info *pg, unsigned int order) +{ + spin_lock(&heap_lock); + __free_heap_pages(pg, order); spin_unlock(&heap_lock); } -- 1.7.10.4