From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH 1/2] xen: introduce a no lock version function of free_heap_pages Date: Tue, 10 Jun 2014 13:32:48 +0100 Message-ID: <5396FAF0.3070907@citrix.com> References: <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.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WuLES-0000cf-MK for xen-devel@lists.xenproject.org; Tue, 10 Jun 2014 12:32:52 +0000 In-Reply-To: <1402402717-26736-1-git-send-email-bob.liu@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Bob Liu Cc: keir@xen.org, ian.campbell@citrix.com, jbeulich@suse.com, xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org On 10/06/14 13:18, Bob Liu wrote: > 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); Probably best to insert an ASSERT(spin_is_locked(&heap_lock)) here. ~Andrew > > - 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); > } >