From: "Jan Beulich" Subject: [PATCH 2/5] allow domain heap allocations to specify more than one NUMA node Date: Thu, 26 Feb 2015 13:53:48 +0000 Message-ID: <54EF337C0200007800064140@mail.emea.novell.com> References: <54EF315902000078000640FF@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part8ABF3C7C.2__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YQysw-0005LP-Ck for xen-devel@lists.xenproject.org; Thu, 26 Feb 2015 13:53:50 +0000 In-Reply-To: <54EF315902000078000640FF@mail.emea.novell.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: xen-devel Cc: Ian Campbell , Keir Fraser , Dario Faggioli , Ian Jackson , Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part8ABF3C7C.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline ... using struct domain as a container for passing the respective affinity mask: Quite a number of allocations are domain specific, yet not to be accounted for that domain. Introduce a flag suppressing the accounting altogether (i.e. going beyond MEMF_no_refcount) and use it right away in common code (x86 and IOMMU code will get adjusted subsequently). Signed-off-by: Jan Beulich --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -1657,7 +1657,8 @@ gnttab_transfer( struct page_info *new_page; void *sp, *dp; =20 - new_page =3D alloc_domheap_page(NULL, MEMF_bits(max_bitsize));= + new_page =3D alloc_domheap_page(e, MEMF_no_owner | + MEMF_bits(max_bitsize)); if ( new_page =3D=3D NULL ) { gop.status =3D GNTST_address_too_big; --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -462,7 +462,8 @@ static long memory_exchange(XEN_GUEST_HA /* Allocate a chunk's worth of anonymous output pages. */ for ( j =3D 0; j < (1UL << out_chunk_order); j++ ) { - page =3D alloc_domheap_pages(NULL, exch.out.extent_order, = memflags); + page =3D alloc_domheap_pages(d, exch.out.extent_order, + MEMF_no_owner | memflags); if ( unlikely(page =3D=3D NULL) ) { rc =3D -ENOMEM; --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1685,10 +1685,14 @@ struct page_info *alloc_domheap_pages( =20 ASSERT(!in_irq()); =20 - bits =3D domain_clamp_alloc_bitsize(d, bits ? : (BITS_PER_LONG+PAGE_SH= IFT)); + bits =3D domain_clamp_alloc_bitsize(memflags & MEMF_no_owner ? NULL : = d, + bits ? : (BITS_PER_LONG+PAGE_SHIFT))= ; if ( (zone_hi =3D min_t(unsigned int, bits_to_zone(bits), zone_hi)) = =3D=3D 0 ) return NULL; =20 + if ( memflags & MEMF_no_owner ) + memflags |=3D MEMF_no_refcount; + if ( dma_bitsize && ((dma_zone =3D bits_to_zone(dma_bitsize)) < = zone_hi) ) pg =3D alloc_heap_pages(dma_zone + 1, zone_hi, order, memflags, = d); =20 @@ -1698,7 +1702,8 @@ struct page_info *alloc_domheap_pages( memflags, d)) =3D=3D NULL)) ) return NULL; =20 - if ( (d !=3D NULL) && assign_pages(d, pg, order, memflags) ) + if ( d && !(memflags & MEMF_no_owner) && + assign_pages(d, pg, order, memflags) ) { free_heap_pages(pg, order); return NULL; --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -120,6 +120,8 @@ struct npfec { #define MEMF_no_dma (1U<<_MEMF_no_dma) #define _MEMF_exact_node 4 #define MEMF_exact_node (1U<<_MEMF_exact_node) +#define _MEMF_no_owner 5 +#define MEMF_no_owner (1U<<_MEMF_no_owner) #define _MEMF_node 8 #define MEMF_node_mask ((1U << (8 * sizeof(nodeid_t))) - 1) #define MEMF_node(n) ((((n) + 1) & MEMF_node_mask) << _MEMF_node) --=__Part8ABF3C7C.2__= Content-Type: text/plain; name="heap-alloc-for-domain.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="heap-alloc-for-domain.patch" allow domain heap allocations to specify more than one NUMA node=0A=0A... = using struct domain as a container for passing the respective=0Aaffinity = mask: Quite a number of allocations are domain specific, yet=0Anot to be = accounted for that domain. Introduce a flag suppressing the=0Aaccounting = altogether (i.e. going beyond MEMF_no_refcount) and use it=0Aright away in = common code (x86 and IOMMU code will get adjusted=0Asubsequently).=0A=0ASig= ned-off-by: Jan Beulich =0A=0A--- a/xen/common/grant_tab= le.c=0A+++ b/xen/common/grant_table.c=0A@@ -1657,7 +1657,8 @@ gnttab_transf= er(=0A struct page_info *new_page;=0A void *sp, = *dp;=0A =0A- new_page =3D alloc_domheap_page(NULL, MEMF_bits(max= _bitsize));=0A+ new_page =3D alloc_domheap_page(e, MEMF_no_owner= |=0A+ MEMF_bits(max_bitsize));= =0A if ( new_page =3D=3D NULL )=0A {=0A = gop.status =3D GNTST_address_too_big;=0A--- a/xen/common/memory.c=0A++= + b/xen/common/memory.c=0A@@ -462,7 +462,8 @@ static long memory_exchange(X= EN_GUEST_HA=0A /* Allocate a chunk's worth of anonymous output = pages. */=0A for ( j =3D 0; j < (1UL << out_chunk_order); j++ )=0A = {=0A- page =3D alloc_domheap_pages(NULL, exch.out.extent= _order, memflags);=0A+ page =3D alloc_domheap_pages(d, = exch.out.extent_order,=0A+ MEMF_no_ow= ner | memflags);=0A if ( unlikely(page =3D=3D NULL) )=0A = {=0A rc =3D -ENOMEM;=0A--- a/xen/common/page_alloc.c= =0A+++ b/xen/common/page_alloc.c=0A@@ -1685,10 +1685,14 @@ struct = page_info *alloc_domheap_pages(=0A =0A ASSERT(!in_irq());=0A =0A- = bits =3D domain_clamp_alloc_bitsize(d, bits ? : (BITS_PER_LONG+PAGE_SHIFT))= ;=0A+ bits =3D domain_clamp_alloc_bitsize(memflags & MEMF_no_owner ? = NULL : d,=0A+ bits ? : (BITS_PER_LONG+= PAGE_SHIFT));=0A if ( (zone_hi =3D min_t(unsigned int, bits_to_zone(bit= s), zone_hi)) =3D=3D 0 )=0A return NULL;=0A =0A+ if ( memflags = & MEMF_no_owner )=0A+ memflags |=3D MEMF_no_refcount;=0A+=0A if = ( dma_bitsize && ((dma_zone =3D bits_to_zone(dma_bitsize)) < zone_hi) )=0A = pg =3D alloc_heap_pages(dma_zone + 1, zone_hi, order, memflags, = d);=0A =0A@@ -1698,7 +1702,8 @@ struct page_info *alloc_domheap_pages(=0A = memflags, d)) =3D=3D NULL)) )=0A = return NULL;=0A =0A- if ( (d !=3D NULL) && assign_pages(d, pg, order, = memflags) )=0A+ if ( d && !(memflags & MEMF_no_owner) &&=0A+ = assign_pages(d, pg, order, memflags) )=0A {=0A free_heap_pages(= pg, order);=0A return NULL;=0A--- a/xen/include/xen/mm.h=0A+++ = b/xen/include/xen/mm.h=0A@@ -120,6 +120,8 @@ struct npfec {=0A #define = MEMF_no_dma (1U<<_MEMF_no_dma)=0A #define _MEMF_exact_node 4=0A = #define MEMF_exact_node (1U<<_MEMF_exact_node)=0A+#define _MEMF_no_owner = 5=0A+#define MEMF_no_owner (1U<<_MEMF_no_owner)=0A #define = _MEMF_node 8=0A #define MEMF_node_mask ((1U << (8 * sizeof(nodeid= _t))) - 1)=0A #define MEMF_node(n) ((((n) + 1) & MEMF_node_mask) << = _MEMF_node)=0A --=__Part8ABF3C7C.2__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part8ABF3C7C.2__=--