All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Two PV vNUMA patches
@ 2015-07-06 13:17 Wei Liu
  2015-07-06 13:17 ` [PATCH 1/2] libxc: remove trailing newline in xc_dom_panic format string Wei Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Wei Liu @ 2015-07-06 13:17 UTC (permalink / raw)
  To: Xen-devel; +Cc: Dario Faggioli, Wei Liu

The first one is just cosmetic change. The second patch fixes a bug.

Wei Liu (2):
  libxc: remove trailing newline in xc_dom_panic format string
  libxc: fix PV vNUMA guest memory allocation

 tools/libxc/xc_dom_x86.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/2] libxc: remove trailing newline in xc_dom_panic format string
  2015-07-06 13:17 [PATCH 0/2] Two PV vNUMA patches Wei Liu
@ 2015-07-06 13:17 ` Wei Liu
  2015-07-06 15:38   ` Dario Faggioli
  2015-07-06 13:17 ` [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation Wei Liu
  2015-07-07 15:19 ` [PATCH 0/2] Two PV vNUMA patches Ian Campbell
  2 siblings, 1 reply; 13+ messages in thread
From: Wei Liu @ 2015-07-06 13:17 UTC (permalink / raw)
  To: Xen-devel; +Cc: Dario Faggioli, Wei Liu

xc_dom_panic prints more information after user supplied strings, so
don't print a newline.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxc/xc_dom_x86.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
index 920fe42..acd7b3f 100644
--- a/tools/libxc/xc_dom_x86.c
+++ b/tools/libxc/xc_dom_x86.c
@@ -863,7 +863,7 @@ int arch_setup_meminit(struct xc_dom_image *dom)
         if ( total != dom->total_pages )
         {
             xc_dom_panic(dom->xch, XC_INTERNAL_ERROR,
-                         "%s: vNUMA page count mismatch (0x%"PRIpfn" != 0x%"PRIpfn")\n",
+                         "%s: vNUMA page count mismatch (0x%"PRIpfn" != 0x%"PRIpfn")",
                          __func__, total, dom->total_pages);
             return -EINVAL;
         }
@@ -936,11 +936,11 @@ int arch_setup_meminit(struct xc_dom_image *dom)
                 {
                     if ( pnode != XC_NUMA_NO_NODE )
                         xc_dom_panic(dom->xch, XC_INTERNAL_ERROR,
-                                     "%s: failed to allocate 0x%"PRIx64" pages (v=%d, p=%d)\n",
+                                     "%s: failed to allocate 0x%"PRIx64" pages (v=%d, p=%d)",
                                      __func__, pages, i, pnode);
                     else
                         xc_dom_panic(dom->xch, XC_INTERNAL_ERROR,
-                                     "%s: failed to allocate 0x%"PRIx64" pages\n",
+                                     "%s: failed to allocate 0x%"PRIx64" pages",
                                      __func__, pages);
                     return rc;
                 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation
  2015-07-06 13:17 [PATCH 0/2] Two PV vNUMA patches Wei Liu
  2015-07-06 13:17 ` [PATCH 1/2] libxc: remove trailing newline in xc_dom_panic format string Wei Liu
@ 2015-07-06 13:17 ` Wei Liu
  2015-07-06 13:22   ` Ross Lagerwall
                     ` (3 more replies)
  2015-07-07 15:19 ` [PATCH 0/2] Two PV vNUMA patches Ian Campbell
  2 siblings, 4 replies; 13+ messages in thread
From: Wei Liu @ 2015-07-06 13:17 UTC (permalink / raw)
  To: Xen-devel; +Cc: Ross Lagerwall, Dario Faggioli, Wei Liu

In 415b58c1 (tools/libxc: Batch memory allocations for PV guests) the
number of super pages is calculated with the number of total pages. That
is wrong. It breaks PV guest vNUMA. The correct number of super pages
should be derived from the number of pages within that virtual NUMA
node.

Also change the name and type of super page variable to match the naming
convention and type of normal page variable. Make the necessary
adjustment to make code compile.

Reported-by: Dario Faggioli <dario.faggioli@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 tools/libxc/xc_dom_x86.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
index acd7b3f..faabe96 100644
--- a/tools/libxc/xc_dom_x86.c
+++ b/tools/libxc/xc_dom_x86.c
@@ -879,9 +879,8 @@ int arch_setup_meminit(struct xc_dom_image *dom)
         for ( i = 0; i < nr_vmemranges; i++ )
         {
             unsigned int memflags;
-            uint64_t pages;
+            uint64_t pages, super_pages;
             unsigned int pnode = vnode_to_pnode[vmemranges[i].nid];
-            int nr_spages = dom->total_pages >> SUPERPAGE_PFN_SHIFT;
             xen_pfn_t extents[SUPERPAGE_BATCH_SIZE];
             xen_pfn_t pfn_base_idx;
 
@@ -891,15 +890,16 @@ int arch_setup_meminit(struct xc_dom_image *dom)
 
             pages = (vmemranges[i].end - vmemranges[i].start)
                 >> PAGE_SHIFT;
+            super_pages = pages >> SUPERPAGE_PFN_SHIFT;
             pfn_base = vmemranges[i].start >> PAGE_SHIFT;
 
             for ( pfn = pfn_base; pfn < pfn_base+pages; pfn++ )
                 dom->p2m_host[pfn] = pfn;
 
             pfn_base_idx = pfn_base;
-            while (nr_spages) {
-                int count = min(nr_spages, SUPERPAGE_BATCH_SIZE);
-                nr_spages -= count;
+            while (super_pages) {
+                int count = min_t(uint64_t, super_pages, SUPERPAGE_BATCH_SIZE);
+                super_pages -= count;
 
                 for ( pfn = pfn_base_idx, j = 0;
                       pfn < pfn_base_idx + (count << SUPERPAGE_PFN_SHIFT);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation
  2015-07-06 13:17 ` [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation Wei Liu
@ 2015-07-06 13:22   ` Ross Lagerwall
  2015-07-06 13:26   ` Andrew Cooper
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: Ross Lagerwall @ 2015-07-06 13:22 UTC (permalink / raw)
  To: Wei Liu, Xen-devel; +Cc: Dario Faggioli

On 07/06/2015 02:17 PM, Wei Liu wrote:
> In 415b58c1 (tools/libxc: Batch memory allocations for PV guests) the
> number of super pages is calculated with the number of total pages. That
> is wrong. It breaks PV guest vNUMA. The correct number of super pages
> should be derived from the number of pages within that virtual NUMA
> node.
>
> Also change the name and type of super page variable to match the naming
> convention and type of normal page variable. Make the necessary
> adjustment to make code compile.
>
> Reported-by: Dario Faggioli <dario.faggioli@citrix.com>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> ---
> Cc: Ross Lagerwall <ross.lagerwall@citrix.com>
> ---
>   tools/libxc/xc_dom_x86.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
> index acd7b3f..faabe96 100644
> --- a/tools/libxc/xc_dom_x86.c
> +++ b/tools/libxc/xc_dom_x86.c
> @@ -879,9 +879,8 @@ int arch_setup_meminit(struct xc_dom_image *dom)
>           for ( i = 0; i < nr_vmemranges; i++ )
>           {
>               unsigned int memflags;
> -            uint64_t pages;
> +            uint64_t pages, super_pages;
>               unsigned int pnode = vnode_to_pnode[vmemranges[i].nid];
> -            int nr_spages = dom->total_pages >> SUPERPAGE_PFN_SHIFT;
>               xen_pfn_t extents[SUPERPAGE_BATCH_SIZE];
>               xen_pfn_t pfn_base_idx;
>
> @@ -891,15 +890,16 @@ int arch_setup_meminit(struct xc_dom_image *dom)
>
>               pages = (vmemranges[i].end - vmemranges[i].start)
>                   >> PAGE_SHIFT;
> +            super_pages = pages >> SUPERPAGE_PFN_SHIFT;
>               pfn_base = vmemranges[i].start >> PAGE_SHIFT;
>
>               for ( pfn = pfn_base; pfn < pfn_base+pages; pfn++ )
>                   dom->p2m_host[pfn] = pfn;
>
>               pfn_base_idx = pfn_base;
> -            while (nr_spages) {
> -                int count = min(nr_spages, SUPERPAGE_BATCH_SIZE);
> -                nr_spages -= count;
> +            while (super_pages) {
> +                int count = min_t(uint64_t, super_pages, SUPERPAGE_BATCH_SIZE);
> +                super_pages -= count;
>
>                   for ( pfn = pfn_base_idx, j = 0;
>                         pfn < pfn_base_idx + (count << SUPERPAGE_PFN_SHIFT);
>

Ah yes I forward-ported the patch from 4.5 and didn't test it with vNUMA.

Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>

-- 
Ross Lagerwall

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation
  2015-07-06 13:17 ` [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation Wei Liu
  2015-07-06 13:22   ` Ross Lagerwall
@ 2015-07-06 13:26   ` Andrew Cooper
  2015-07-06 13:30     ` Wei Liu
  2015-07-06 13:47   ` [PATCH v2] " Wei Liu
  2015-07-06 13:53   ` [PATCH 2/2] " Dario Faggioli
  3 siblings, 1 reply; 13+ messages in thread
From: Andrew Cooper @ 2015-07-06 13:26 UTC (permalink / raw)
  To: Wei Liu, Xen-devel; +Cc: Ross Lagerwall, Dario Faggioli

On 06/07/15 14:17, Wei Liu wrote:
> In 415b58c1 (tools/libxc: Batch memory allocations for PV guests) the
> number of super pages is calculated with the number of total pages. That
> is wrong. It breaks PV guest vNUMA. The correct number of super pages
> should be derived from the number of pages within that virtual NUMA
> node.
>
> Also change the name and type of super page variable to match the naming
> convention and type of normal page variable. Make the necessary
> adjustment to make code compile.
>
> Reported-by: Dario Faggioli <dario.faggioli@citrix.com>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> ---
> Cc: Ross Lagerwall <ross.lagerwall@citrix.com>
> ---
>  tools/libxc/xc_dom_x86.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
> index acd7b3f..faabe96 100644
> --- a/tools/libxc/xc_dom_x86.c
> +++ b/tools/libxc/xc_dom_x86.c
> @@ -879,9 +879,8 @@ int arch_setup_meminit(struct xc_dom_image *dom)
>          for ( i = 0; i < nr_vmemranges; i++ )
>          {
>              unsigned int memflags;
> -            uint64_t pages;
> +            uint64_t pages, super_pages;
>              unsigned int pnode = vnode_to_pnode[vmemranges[i].nid];
> -            int nr_spages = dom->total_pages >> SUPERPAGE_PFN_SHIFT;
>              xen_pfn_t extents[SUPERPAGE_BATCH_SIZE];
>              xen_pfn_t pfn_base_idx;
>  
> @@ -891,15 +890,16 @@ int arch_setup_meminit(struct xc_dom_image *dom)
>  
>              pages = (vmemranges[i].end - vmemranges[i].start)
>                  >> PAGE_SHIFT;
> +            super_pages = pages >> SUPERPAGE_PFN_SHIFT;
>              pfn_base = vmemranges[i].start >> PAGE_SHIFT;
>  
>              for ( pfn = pfn_base; pfn < pfn_base+pages; pfn++ )
>                  dom->p2m_host[pfn] = pfn;
>  
>              pfn_base_idx = pfn_base;
> -            while (nr_spages) {
> -                int count = min(nr_spages, SUPERPAGE_BATCH_SIZE);
> -                nr_spages -= count;
> +            while (super_pages) {
> +                int count = min_t(uint64_t, super_pages, SUPERPAGE_BATCH_SIZE);

This line alone indicates that int is not an appropriate type for
count.  unsigned int as as an absolute minimum, as it will be bounded to
SUPERPAGE_BATCH_SIZE.

~Andrew

> +                super_pages -= count;
>  
>                  for ( pfn = pfn_base_idx, j = 0;
>                        pfn < pfn_base_idx + (count << SUPERPAGE_PFN_SHIFT);

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation
  2015-07-06 13:26   ` Andrew Cooper
@ 2015-07-06 13:30     ` Wei Liu
  2015-07-06 13:33       ` Ross Lagerwall
  0 siblings, 1 reply; 13+ messages in thread
From: Wei Liu @ 2015-07-06 13:30 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Xen-devel, Dario Faggioli, Wei Liu, Ross Lagerwall

On Mon, Jul 06, 2015 at 02:26:37PM +0100, Andrew Cooper wrote:
> On 06/07/15 14:17, Wei Liu wrote:
> > In 415b58c1 (tools/libxc: Batch memory allocations for PV guests) the
> > number of super pages is calculated with the number of total pages. That
> > is wrong. It breaks PV guest vNUMA. The correct number of super pages
> > should be derived from the number of pages within that virtual NUMA
> > node.
> >
> > Also change the name and type of super page variable to match the naming
> > convention and type of normal page variable. Make the necessary
> > adjustment to make code compile.
> >
> > Reported-by: Dario Faggioli <dario.faggioli@citrix.com>
> > Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> > ---
> > Cc: Ross Lagerwall <ross.lagerwall@citrix.com>
> > ---
> >  tools/libxc/xc_dom_x86.c | 10 +++++-----
> >  1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
> > index acd7b3f..faabe96 100644
> > --- a/tools/libxc/xc_dom_x86.c
> > +++ b/tools/libxc/xc_dom_x86.c
> > @@ -879,9 +879,8 @@ int arch_setup_meminit(struct xc_dom_image *dom)
> >          for ( i = 0; i < nr_vmemranges; i++ )
> >          {
> >              unsigned int memflags;
> > -            uint64_t pages;
> > +            uint64_t pages, super_pages;
> >              unsigned int pnode = vnode_to_pnode[vmemranges[i].nid];
> > -            int nr_spages = dom->total_pages >> SUPERPAGE_PFN_SHIFT;
> >              xen_pfn_t extents[SUPERPAGE_BATCH_SIZE];
> >              xen_pfn_t pfn_base_idx;
> >  
> > @@ -891,15 +890,16 @@ int arch_setup_meminit(struct xc_dom_image *dom)
> >  
> >              pages = (vmemranges[i].end - vmemranges[i].start)
> >                  >> PAGE_SHIFT;
> > +            super_pages = pages >> SUPERPAGE_PFN_SHIFT;
> >              pfn_base = vmemranges[i].start >> PAGE_SHIFT;
> >  
> >              for ( pfn = pfn_base; pfn < pfn_base+pages; pfn++ )
> >                  dom->p2m_host[pfn] = pfn;
> >  
> >              pfn_base_idx = pfn_base;
> > -            while (nr_spages) {
> > -                int count = min(nr_spages, SUPERPAGE_BATCH_SIZE);
> > -                nr_spages -= count;
> > +            while (super_pages) {
> > +                int count = min_t(uint64_t, super_pages, SUPERPAGE_BATCH_SIZE);
> 
> This line alone indicates that int is not an appropriate type for
> count.  unsigned int as as an absolute minimum, as it will be bounded to
> SUPERPAGE_BATCH_SIZE.
> 

Yes, I also need to make count uint64_t.

Wei.

> ~Andrew
> 
> > +                super_pages -= count;
> >  
> >                  for ( pfn = pfn_base_idx, j = 0;
> >                        pfn < pfn_base_idx + (count << SUPERPAGE_PFN_SHIFT);

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation
  2015-07-06 13:30     ` Wei Liu
@ 2015-07-06 13:33       ` Ross Lagerwall
  2015-07-06 13:39         ` Wei Liu
  0 siblings, 1 reply; 13+ messages in thread
From: Ross Lagerwall @ 2015-07-06 13:33 UTC (permalink / raw)
  To: Wei Liu, Andrew Cooper; +Cc: Xen-devel, Dario Faggioli

On 07/06/2015 02:30 PM, Wei Liu wrote:
> On Mon, Jul 06, 2015 at 02:26:37PM +0100, Andrew Cooper wrote:
>> On 06/07/15 14:17, Wei Liu wrote:
>>> In 415b58c1 (tools/libxc: Batch memory allocations for PV guests) the
>>> number of super pages is calculated with the number of total pages. That
>>> is wrong. It breaks PV guest vNUMA. The correct number of super pages
>>> should be derived from the number of pages within that virtual NUMA
>>> node.
>>>
>>> Also change the name and type of super page variable to match the naming
>>> convention and type of normal page variable. Make the necessary
>>> adjustment to make code compile.
>>>
>>> Reported-by: Dario Faggioli <dario.faggioli@citrix.com>
>>> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
>>> ---
>>> Cc: Ross Lagerwall <ross.lagerwall@citrix.com>
>>> ---
>>>   tools/libxc/xc_dom_x86.c | 10 +++++-----
>>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
>>> index acd7b3f..faabe96 100644
>>> --- a/tools/libxc/xc_dom_x86.c
>>> +++ b/tools/libxc/xc_dom_x86.c
>>> @@ -879,9 +879,8 @@ int arch_setup_meminit(struct xc_dom_image *dom)
>>>           for ( i = 0; i < nr_vmemranges; i++ )
>>>           {
>>>               unsigned int memflags;
>>> -            uint64_t pages;
>>> +            uint64_t pages, super_pages;
>>>               unsigned int pnode = vnode_to_pnode[vmemranges[i].nid];
>>> -            int nr_spages = dom->total_pages >> SUPERPAGE_PFN_SHIFT;
>>>               xen_pfn_t extents[SUPERPAGE_BATCH_SIZE];
>>>               xen_pfn_t pfn_base_idx;
>>>
>>> @@ -891,15 +890,16 @@ int arch_setup_meminit(struct xc_dom_image *dom)
>>>
>>>               pages = (vmemranges[i].end - vmemranges[i].start)
>>>                   >> PAGE_SHIFT;
>>> +            super_pages = pages >> SUPERPAGE_PFN_SHIFT;
>>>               pfn_base = vmemranges[i].start >> PAGE_SHIFT;
>>>
>>>               for ( pfn = pfn_base; pfn < pfn_base+pages; pfn++ )
>>>                   dom->p2m_host[pfn] = pfn;
>>>
>>>               pfn_base_idx = pfn_base;
>>> -            while (nr_spages) {
>>> -                int count = min(nr_spages, SUPERPAGE_BATCH_SIZE);
>>> -                nr_spages -= count;
>>> +            while (super_pages) {
>>> +                int count = min_t(uint64_t, super_pages, SUPERPAGE_BATCH_SIZE);
>>
>> This line alone indicates that int is not an appropriate type for
>> count.  unsigned int as as an absolute minimum, as it will be bounded to
>> SUPERPAGE_BATCH_SIZE.
>>
>
> Yes, I also need to make count uint64_t.
>

Is this needed? count should never be larger than 512 (aka 
SUPERPAGE_BATCH_SIZE).

-- 
Ross Lagerwall

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation
  2015-07-06 13:33       ` Ross Lagerwall
@ 2015-07-06 13:39         ` Wei Liu
  0 siblings, 0 replies; 13+ messages in thread
From: Wei Liu @ 2015-07-06 13:39 UTC (permalink / raw)
  To: Ross Lagerwall; +Cc: Andrew Cooper, Dario Faggioli, Wei Liu, Xen-devel

On Mon, Jul 06, 2015 at 02:33:35PM +0100, Ross Lagerwall wrote:
> On 07/06/2015 02:30 PM, Wei Liu wrote:
> >On Mon, Jul 06, 2015 at 02:26:37PM +0100, Andrew Cooper wrote:
> >>On 06/07/15 14:17, Wei Liu wrote:
> >>>In 415b58c1 (tools/libxc: Batch memory allocations for PV guests) the
> >>>number of super pages is calculated with the number of total pages. That
> >>>is wrong. It breaks PV guest vNUMA. The correct number of super pages
> >>>should be derived from the number of pages within that virtual NUMA
> >>>node.
> >>>
> >>>Also change the name and type of super page variable to match the naming
> >>>convention and type of normal page variable. Make the necessary
> >>>adjustment to make code compile.
> >>>
> >>>Reported-by: Dario Faggioli <dario.faggioli@citrix.com>
> >>>Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> >>>---
> >>>Cc: Ross Lagerwall <ross.lagerwall@citrix.com>
> >>>---
> >>>  tools/libxc/xc_dom_x86.c | 10 +++++-----
> >>>  1 file changed, 5 insertions(+), 5 deletions(-)
> >>>
> >>>diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
> >>>index acd7b3f..faabe96 100644
> >>>--- a/tools/libxc/xc_dom_x86.c
> >>>+++ b/tools/libxc/xc_dom_x86.c
> >>>@@ -879,9 +879,8 @@ int arch_setup_meminit(struct xc_dom_image *dom)
> >>>          for ( i = 0; i < nr_vmemranges; i++ )
> >>>          {
> >>>              unsigned int memflags;
> >>>-            uint64_t pages;
> >>>+            uint64_t pages, super_pages;
> >>>              unsigned int pnode = vnode_to_pnode[vmemranges[i].nid];
> >>>-            int nr_spages = dom->total_pages >> SUPERPAGE_PFN_SHIFT;
> >>>              xen_pfn_t extents[SUPERPAGE_BATCH_SIZE];
> >>>              xen_pfn_t pfn_base_idx;
> >>>
> >>>@@ -891,15 +890,16 @@ int arch_setup_meminit(struct xc_dom_image *dom)
> >>>
> >>>              pages = (vmemranges[i].end - vmemranges[i].start)
> >>>                  >> PAGE_SHIFT;
> >>>+            super_pages = pages >> SUPERPAGE_PFN_SHIFT;
> >>>              pfn_base = vmemranges[i].start >> PAGE_SHIFT;
> >>>
> >>>              for ( pfn = pfn_base; pfn < pfn_base+pages; pfn++ )
> >>>                  dom->p2m_host[pfn] = pfn;
> >>>
> >>>              pfn_base_idx = pfn_base;
> >>>-            while (nr_spages) {
> >>>-                int count = min(nr_spages, SUPERPAGE_BATCH_SIZE);
> >>>-                nr_spages -= count;
> >>>+            while (super_pages) {
> >>>+                int count = min_t(uint64_t, super_pages, SUPERPAGE_BATCH_SIZE);
> >>
> >>This line alone indicates that int is not an appropriate type for
> >>count.  unsigned int as as an absolute minimum, as it will be bounded to
> >>SUPERPAGE_BATCH_SIZE.
> >>
> >
> >Yes, I also need to make count uint64_t.
> >
> 
> Is this needed? count should never be larger than 512 (aka
> SUPERPAGE_BATCH_SIZE).
> 

Maybe uint64_t is overkill but I want to be as consistent as possible.

Wei.

> -- 
> Ross Lagerwall

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH v2] libxc: fix PV vNUMA guest memory allocation
  2015-07-06 13:17 ` [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation Wei Liu
  2015-07-06 13:22   ` Ross Lagerwall
  2015-07-06 13:26   ` Andrew Cooper
@ 2015-07-06 13:47   ` Wei Liu
  2015-07-06 16:11     ` Dario Faggioli
  2015-07-06 13:53   ` [PATCH 2/2] " Dario Faggioli
  3 siblings, 1 reply; 13+ messages in thread
From: Wei Liu @ 2015-07-06 13:47 UTC (permalink / raw)
  To: Xen-devel; +Cc: Wei Liu, Ian Jackson, Ian Campbell

In 415b58c1 (tools/libxc: Batch memory allocations for PV guests) the
number of super pages is calculated with the number of total pages. That
is wrong. It breaks PV guest vNUMA. The correct number of super pages
should be derived from the number of pages within that virtual NUMA
node.

Also change the name and type of super page variable to match the naming
convention and type of normal page variable. Make the necessary
adjustment to make code compile.

Reported-by: Dario Faggioli <dario.faggioli@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
v2: uint64_t for count variable for consistency, no functional changes wrt v1
    so I retain the Reviewed-by tag.
---
 tools/libxc/xc_dom_x86.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
index acd7b3f..6a04399 100644
--- a/tools/libxc/xc_dom_x86.c
+++ b/tools/libxc/xc_dom_x86.c
@@ -879,9 +879,8 @@ int arch_setup_meminit(struct xc_dom_image *dom)
         for ( i = 0; i < nr_vmemranges; i++ )
         {
             unsigned int memflags;
-            uint64_t pages;
+            uint64_t pages, super_pages;
             unsigned int pnode = vnode_to_pnode[vmemranges[i].nid];
-            int nr_spages = dom->total_pages >> SUPERPAGE_PFN_SHIFT;
             xen_pfn_t extents[SUPERPAGE_BATCH_SIZE];
             xen_pfn_t pfn_base_idx;
 
@@ -891,15 +890,17 @@ int arch_setup_meminit(struct xc_dom_image *dom)
 
             pages = (vmemranges[i].end - vmemranges[i].start)
                 >> PAGE_SHIFT;
+            super_pages = pages >> SUPERPAGE_PFN_SHIFT;
             pfn_base = vmemranges[i].start >> PAGE_SHIFT;
 
             for ( pfn = pfn_base; pfn < pfn_base+pages; pfn++ )
                 dom->p2m_host[pfn] = pfn;
 
             pfn_base_idx = pfn_base;
-            while (nr_spages) {
-                int count = min(nr_spages, SUPERPAGE_BATCH_SIZE);
-                nr_spages -= count;
+            while (super_pages) {
+                uint64_t count =
+                    min_t(uint64_t, super_pages,SUPERPAGE_BATCH_SIZE);
+                super_pages -= count;
 
                 for ( pfn = pfn_base_idx, j = 0;
                       pfn < pfn_base_idx + (count << SUPERPAGE_PFN_SHIFT);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation
  2015-07-06 13:17 ` [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation Wei Liu
                     ` (2 preceding siblings ...)
  2015-07-06 13:47   ` [PATCH v2] " Wei Liu
@ 2015-07-06 13:53   ` Dario Faggioli
  3 siblings, 0 replies; 13+ messages in thread
From: Dario Faggioli @ 2015-07-06 13:53 UTC (permalink / raw)
  To: Wei Liu; +Cc: Xen-devel, Ross Lagerwall


[-- Attachment #1.1: Type: text/plain, Size: 1047 bytes --]

On Mon, 2015-07-06 at 14:17 +0100, Wei Liu wrote:
> In 415b58c1 (tools/libxc: Batch memory allocations for PV guests) the
> number of super pages is calculated with the number of total pages. That
> is wrong. It breaks PV guest vNUMA. The correct number of super pages
> should be derived from the number of pages within that virtual NUMA
> node.
> 
> Also change the name and type of super page variable to match the naming
> convention and type of normal page variable. Make the necessary
> adjustment to make code compile.
> 
> Reported-by: Dario Faggioli <dario.faggioli@citrix.com>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
>
Thanks for looking at this so quickly.

I think I've understood that you're sending a v2, so I'll test that one.

Regards,
Dario

-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] libxc: remove trailing newline in xc_dom_panic format string
  2015-07-06 13:17 ` [PATCH 1/2] libxc: remove trailing newline in xc_dom_panic format string Wei Liu
@ 2015-07-06 15:38   ` Dario Faggioli
  0 siblings, 0 replies; 13+ messages in thread
From: Dario Faggioli @ 2015-07-06 15:38 UTC (permalink / raw)
  To: Wei Liu; +Cc: Xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 530 bytes --]

On Mon, 2015-07-06 at 14:17 +0100, Wei Liu wrote:
> xc_dom_panic prints more information after user supplied strings, so
> don't print a newline.
> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
>
Reviewed by: Dario Faggioli <dario.faggioli@citrix.com>

Dario
-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH v2] libxc: fix PV vNUMA guest memory allocation
  2015-07-06 13:47   ` [PATCH v2] " Wei Liu
@ 2015-07-06 16:11     ` Dario Faggioli
  0 siblings, 0 replies; 13+ messages in thread
From: Dario Faggioli @ 2015-07-06 16:11 UTC (permalink / raw)
  To: Wei Liu; +Cc: Xen-devel, Ian Jackson, Ian Campbell


[-- Attachment #1.1: Type: text/plain, Size: 1193 bytes --]

On Mon, 2015-07-06 at 14:47 +0100, Wei Liu wrote:
> In 415b58c1 (tools/libxc: Batch memory allocations for PV guests) the
> number of super pages is calculated with the number of total pages. That
> is wrong. It breaks PV guest vNUMA. The correct number of super pages
> should be derived from the number of pages within that virtual NUMA
> node.
> 
> Also change the name and type of super page variable to match the naming
> convention and type of normal page variable. Make the necessary
> adjustment to make code compile.
> 
> Reported-by: Dario Faggioli <dario.faggioli@citrix.com>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
> ---
> v2: uint64_t for count variable for consistency, no functional changes wrt v1
>     so I retain the Reviewed-by tag.
> ---
>
Reviewed-and-Tested-by: Dario Faggioli <dario.faggioli@citrix.com>

Regards,
Dario

-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/2] Two PV vNUMA patches
  2015-07-06 13:17 [PATCH 0/2] Two PV vNUMA patches Wei Liu
  2015-07-06 13:17 ` [PATCH 1/2] libxc: remove trailing newline in xc_dom_panic format string Wei Liu
  2015-07-06 13:17 ` [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation Wei Liu
@ 2015-07-07 15:19 ` Ian Campbell
  2 siblings, 0 replies; 13+ messages in thread
From: Ian Campbell @ 2015-07-07 15:19 UTC (permalink / raw)
  To: Wei Liu; +Cc: Xen-devel, Dario Faggioli

On Mon, 2015-07-06 at 14:17 +0100, Wei Liu wrote:
> The first one is just cosmetic change. The second patch fixes a bug.
> 
> Wei Liu (2):
>   libxc: remove trailing newline in xc_dom_panic format string
>   libxc: fix PV vNUMA guest memory allocation

Acked + applied (the v2 of the latter patch).

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-07-07 15:20 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-06 13:17 [PATCH 0/2] Two PV vNUMA patches Wei Liu
2015-07-06 13:17 ` [PATCH 1/2] libxc: remove trailing newline in xc_dom_panic format string Wei Liu
2015-07-06 15:38   ` Dario Faggioli
2015-07-06 13:17 ` [PATCH 2/2] libxc: fix PV vNUMA guest memory allocation Wei Liu
2015-07-06 13:22   ` Ross Lagerwall
2015-07-06 13:26   ` Andrew Cooper
2015-07-06 13:30     ` Wei Liu
2015-07-06 13:33       ` Ross Lagerwall
2015-07-06 13:39         ` Wei Liu
2015-07-06 13:47   ` [PATCH v2] " Wei Liu
2015-07-06 16:11     ` Dario Faggioli
2015-07-06 13:53   ` [PATCH 2/2] " Dario Faggioli
2015-07-07 15:19 ` [PATCH 0/2] Two PV vNUMA patches Ian Campbell

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.