diff mbox

[RFC,V3,1/3] Xen: Increase hap/shadow page pool size to support more vcpus support

Message ID 1505278369-21605-2-git-send-email-tianyu.lan@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

lan,Tianyu Sept. 13, 2017, 4:52 a.m. UTC
This patch is to increase page pool size when max vcpu number is larger
than 128.

Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
 xen/arch/arm/domain.c    |  5 +++++
 xen/arch/x86/domain.c    | 25 +++++++++++++++++++++++++
 xen/common/domctl.c      |  3 +++
 xen/include/xen/domain.h |  2 ++
 4 files changed, 35 insertions(+)

Comments

Wei Liu Sept. 18, 2017, 1:06 p.m. UTC | #1
On Wed, Sep 13, 2017 at 12:52:47AM -0400, Lan Tianyu wrote:
> This patch is to increase page pool size when max vcpu number is larger
> than 128.
> 
> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
> ---
>  xen/arch/arm/domain.c    |  5 +++++
>  xen/arch/x86/domain.c    | 25 +++++++++++++++++++++++++
>  xen/common/domctl.c      |  3 +++
>  xen/include/xen/domain.h |  2 ++
>  4 files changed, 35 insertions(+)
> 
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index 6512f01..94cf70b 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -824,6 +824,11 @@ int arch_vcpu_reset(struct vcpu *v)
>      return 0;
>  }
>  
> +int arch_domain_set_max_vcpus(struct domain *d)
> +{
> +    return 0;
> +}
> +
>  static int relinquish_memory(struct domain *d, struct page_list_head *list)
>  {
>      struct page_info *page, *tmp;
> diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
> index dbddc53..0e230f9 100644
> --- a/xen/arch/x86/domain.c
> +++ b/xen/arch/x86/domain.c
> @@ -1161,6 +1161,31 @@ int arch_vcpu_reset(struct vcpu *v)
>      return 0;
>  }
>  
> +int arch_domain_set_max_vcpus(struct domain *d)

The name doesn't match what the function does.

> +{
> +    int ret;
> +
> +    /* Increase page pool in order to support more vcpus. */
> +    if ( d->max_vcpus > 128 )
> +    {
> +        unsigned long nr_pages;
> +
> +        if (hap_enabled(d))

Coding style.

> +            nr_pages = 1024;
> +        else
> +            nr_pages = 4096;
> +
> +        ret = paging_set_allocation(d, nr_pages, NULL);

Does this work on PV guests?

> +        if ( ret != 0 )
> +        {
> +            paging_set_allocation(d, 0, NULL);
> +            return ret;
> +        }
> +    }
> +
> +    return 0;
> +}
> +
>  long
>  arch_do_vcpu_op(
>      int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg)
> diff --git a/xen/common/domctl.c b/xen/common/domctl.c
> index 42658e5..64357a3 100644
> --- a/xen/common/domctl.c
> +++ b/xen/common/domctl.c
> @@ -631,6 +631,9 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
>              d->max_vcpus = max;
>          }
>  
> +        if ( arch_domain_set_max_vcpus(d) < 0)

!= 0 please.

> +            goto maxvcpu_out;
> +
>          for ( i = 0; i < max; i++ )
>          {
>              if ( d->vcpu[i] != NULL )
> diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h
> index 347f264..e1ece3a 100644
> --- a/xen/include/xen/domain.h
> +++ b/xen/include/xen/domain.h
> @@ -81,6 +81,8 @@ void arch_dump_domain_info(struct domain *d);
>  
>  int arch_vcpu_reset(struct vcpu *);
>  
> +int arch_domain_set_max_vcpus(struct domain *d);
> +
>  extern spinlock_t vcpu_alloc_lock;
>  bool_t domctl_lock_acquire(void);
>  void domctl_lock_release(void);
> -- 
> 1.8.3.1
>
lan,Tianyu Sept. 19, 2017, 3:06 a.m. UTC | #2
Hi Wei:

On 2017年09月18日 21:06, Wei Liu wrote:
> On Wed, Sep 13, 2017 at 12:52:47AM -0400, Lan Tianyu wrote:
>> This patch is to increase page pool size when max vcpu number is larger
>> than 128.
>>
>> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
>> ---
>>  xen/arch/arm/domain.c    |  5 +++++
>>  xen/arch/x86/domain.c    | 25 +++++++++++++++++++++++++
>>  xen/common/domctl.c      |  3 +++
>>  xen/include/xen/domain.h |  2 ++
>>  4 files changed, 35 insertions(+)
>>
>> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
>> index 6512f01..94cf70b 100644
>> --- a/xen/arch/arm/domain.c
>> +++ b/xen/arch/arm/domain.c
>> @@ -824,6 +824,11 @@ int arch_vcpu_reset(struct vcpu *v)
>>      return 0;
>>  }
>>  
>> +int arch_domain_set_max_vcpus(struct domain *d)
>> +{
>> +    return 0;
>> +}
>> +
>>  static int relinquish_memory(struct domain *d, struct page_list_head *list)
>>  {
>>      struct page_info *page, *tmp;
>> diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
>> index dbddc53..0e230f9 100644
>> --- a/xen/arch/x86/domain.c
>> +++ b/xen/arch/x86/domain.c
>> @@ -1161,6 +1161,31 @@ int arch_vcpu_reset(struct vcpu *v)
>>      return 0;
>>  }
>>  
>> +int arch_domain_set_max_vcpus(struct domain *d)
> 
> The name doesn't match what the function does.
> 

I originally hoped to introduce a hook for each arch when set max vcpus.
Each arch function can do customized thing and so named
"arch_domain_set_max_vcpus".

How about "arch_domain_setup_vcpus_resource"?


>> +{
>> +    int ret;
>> +
>> +    /* Increase page pool in order to support more vcpus. */
>> +    if ( d->max_vcpus > 128 )
>> +    {
>> +        unsigned long nr_pages;
>> +
>> +        if (hap_enabled(d))
> 
> Coding style.

Will update. Thanks.

> 
>> +            nr_pages = 1024;
>> +        else
>> +            nr_pages = 4096;
>> +
>> +        ret = paging_set_allocation(d, nr_pages, NULL);
> 
> Does this work on PV guests?


Sorry. This code should not run for PV guest. Will add a domain type
check here.

> 
>> +        if ( ret != 0 )
>> +        {
>> +            paging_set_allocation(d, 0, NULL);
>> +            return ret;
>> +        }
>> +    }
>> +
>> +    return 0;
>> +}
>> +
>>  long
>>  arch_do_vcpu_op(
>>      int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg)
>> diff --git a/xen/common/domctl.c b/xen/common/domctl.c
>> index 42658e5..64357a3 100644
>> --- a/xen/common/domctl.c
>> +++ b/xen/common/domctl.c
>> @@ -631,6 +631,9 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
>>              d->max_vcpus = max;
>>          }
>>  
>> +        if ( arch_domain_set_max_vcpus(d) < 0)
> 
> != 0 please.
> 

Sure.

>> +            goto maxvcpu_out;
>> +
>>          for ( i = 0; i < max; i++ )
>>          {
>>              if ( d->vcpu[i] != NULL )
>> diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h
>> index 347f264..e1ece3a 100644
>> --- a/xen/include/xen/domain.h
>> +++ b/xen/include/xen/domain.h
>> @@ -81,6 +81,8 @@ void arch_dump_domain_info(struct domain *d);
>>  
>>  int arch_vcpu_reset(struct vcpu *);
>>  
>> +int arch_domain_set_max_vcpus(struct domain *d);
>> +
>>  extern spinlock_t vcpu_alloc_lock;
>>  bool_t domctl_lock_acquire(void);
>>  void domctl_lock_release(void);
>> -- 
>> 1.8.3.1
>>
Wei Liu Sept. 20, 2017, 3:13 p.m. UTC | #3
On Tue, Sep 19, 2017 at 11:06:26AM +0800, Lan Tianyu wrote:
> Hi Wei:
> 
> On 2017年09月18日 21:06, Wei Liu wrote:
> > On Wed, Sep 13, 2017 at 12:52:47AM -0400, Lan Tianyu wrote:
> >> This patch is to increase page pool size when max vcpu number is larger
> >> than 128.
> >>
> >> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
> >> ---
> >>  xen/arch/arm/domain.c    |  5 +++++
> >>  xen/arch/x86/domain.c    | 25 +++++++++++++++++++++++++
> >>  xen/common/domctl.c      |  3 +++
> >>  xen/include/xen/domain.h |  2 ++
> >>  4 files changed, 35 insertions(+)
> >>
> >> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> >> index 6512f01..94cf70b 100644
> >> --- a/xen/arch/arm/domain.c
> >> +++ b/xen/arch/arm/domain.c
> >> @@ -824,6 +824,11 @@ int arch_vcpu_reset(struct vcpu *v)
> >>      return 0;
> >>  }
> >>  
> >> +int arch_domain_set_max_vcpus(struct domain *d)
> >> +{
> >> +    return 0;
> >> +}
> >> +
> >>  static int relinquish_memory(struct domain *d, struct page_list_head *list)
> >>  {
> >>      struct page_info *page, *tmp;
> >> diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
> >> index dbddc53..0e230f9 100644
> >> --- a/xen/arch/x86/domain.c
> >> +++ b/xen/arch/x86/domain.c
> >> @@ -1161,6 +1161,31 @@ int arch_vcpu_reset(struct vcpu *v)
> >>      return 0;
> >>  }
> >>  
> >> +int arch_domain_set_max_vcpus(struct domain *d)
> > 
> > The name doesn't match what the function does.
> > 
> 
> I originally hoped to introduce a hook for each arch when set max vcpus.
> Each arch function can do customized thing and so named
> "arch_domain_set_max_vcpus".
> 
> How about "arch_domain_setup_vcpus_resource"?

Before you go away and do a lot of work, please let us think about if
this is the right approach first.

We are close to freeze, with the amount of patches we receive everyday
RFC patch like this one is low on my (can't speak for others) priority
list. I am not sure when I will be able to get back to this, but do ping
us if you want to know where things stand.
lan,Tianyu Sept. 21, 2017, 8:50 a.m. UTC | #4
On 2017年09月20日 23:13, Wei Liu wrote:
> On Tue, Sep 19, 2017 at 11:06:26AM +0800, Lan Tianyu wrote:
>> Hi Wei:
>>
>> On 2017年09月18日 21:06, Wei Liu wrote:
>>> On Wed, Sep 13, 2017 at 12:52:47AM -0400, Lan Tianyu wrote:
>>>> This patch is to increase page pool size when max vcpu number is larger
>>>> than 128.
>>>>
>>>> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
>>>> ---
>>>>  xen/arch/arm/domain.c    |  5 +++++
>>>>  xen/arch/x86/domain.c    | 25 +++++++++++++++++++++++++
>>>>  xen/common/domctl.c      |  3 +++
>>>>  xen/include/xen/domain.h |  2 ++
>>>>  4 files changed, 35 insertions(+)
>>>>
>>>> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
>>>> index 6512f01..94cf70b 100644
>>>> --- a/xen/arch/arm/domain.c
>>>> +++ b/xen/arch/arm/domain.c
>>>> @@ -824,6 +824,11 @@ int arch_vcpu_reset(struct vcpu *v)
>>>>      return 0;
>>>>  }
>>>>  
>>>> +int arch_domain_set_max_vcpus(struct domain *d)
>>>> +{
>>>> +    return 0;
>>>> +}
>>>> +
>>>>  static int relinquish_memory(struct domain *d, struct page_list_head *list)
>>>>  {
>>>>      struct page_info *page, *tmp;
>>>> diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
>>>> index dbddc53..0e230f9 100644
>>>> --- a/xen/arch/x86/domain.c
>>>> +++ b/xen/arch/x86/domain.c
>>>> @@ -1161,6 +1161,31 @@ int arch_vcpu_reset(struct vcpu *v)
>>>>      return 0;
>>>>  }
>>>>  
>>>> +int arch_domain_set_max_vcpus(struct domain *d)
>>>
>>> The name doesn't match what the function does.
>>>
>>
>> I originally hoped to introduce a hook for each arch when set max vcpus.
>> Each arch function can do customized thing and so named
>> "arch_domain_set_max_vcpus".
>>
>> How about "arch_domain_setup_vcpus_resource"?
> 
> Before you go away and do a lot of work, please let us think about if
> this is the right approach first.

Sure. This idea that increase page pool when set max vcpu is from Jan.
Jan, Could you help to check whether current patch is right approach?
Thanks.

> 
> We are close to freeze, with the amount of patches we receive everyday
> RFC patch like this one is low on my (can't speak for others) priority
> list. I am not sure when I will be able to get back to this, but do ping
> us if you want to know where things stand.
>
Jan Beulich Sept. 21, 2017, 11:27 a.m. UTC | #5
>>> On 21.09.17 at 10:50, <tianyu.lan@intel.com> wrote:
> On 2017年09月20日 23:13, Wei Liu wrote:
>> On Tue, Sep 19, 2017 at 11:06:26AM +0800, Lan Tianyu wrote:
>>> Hi Wei:
>>>
>>> On 2017年09月18日 21:06, Wei Liu wrote:
>>>> On Wed, Sep 13, 2017 at 12:52:47AM -0400, Lan Tianyu wrote:
>>>>> This patch is to increase page pool size when max vcpu number is larger
>>>>> than 128.
>>>>>
>>>>> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
>>>>> ---
>>>>>  xen/arch/arm/domain.c    |  5 +++++
>>>>>  xen/arch/x86/domain.c    | 25 +++++++++++++++++++++++++
>>>>>  xen/common/domctl.c      |  3 +++
>>>>>  xen/include/xen/domain.h |  2 ++
>>>>>  4 files changed, 35 insertions(+)
>>>>>
>>>>> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
>>>>> index 6512f01..94cf70b 100644
>>>>> --- a/xen/arch/arm/domain.c
>>>>> +++ b/xen/arch/arm/domain.c
>>>>> @@ -824,6 +824,11 @@ int arch_vcpu_reset(struct vcpu *v)
>>>>>      return 0;
>>>>>  }
>>>>>  
>>>>> +int arch_domain_set_max_vcpus(struct domain *d)
>>>>> +{
>>>>> +    return 0;
>>>>> +}
>>>>> +
>>>>>  static int relinquish_memory(struct domain *d, struct page_list_head *list)
>>>>>  {
>>>>>      struct page_info *page, *tmp;
>>>>> diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
>>>>> index dbddc53..0e230f9 100644
>>>>> --- a/xen/arch/x86/domain.c
>>>>> +++ b/xen/arch/x86/domain.c
>>>>> @@ -1161,6 +1161,31 @@ int arch_vcpu_reset(struct vcpu *v)
>>>>>      return 0;
>>>>>  }
>>>>>  
>>>>> +int arch_domain_set_max_vcpus(struct domain *d)
>>>>
>>>> The name doesn't match what the function does.
>>>>
>>>
>>> I originally hoped to introduce a hook for each arch when set max vcpus.
>>> Each arch function can do customized thing and so named
>>> "arch_domain_set_max_vcpus".
>>>
>>> How about "arch_domain_setup_vcpus_resource"?
>> 
>> Before you go away and do a lot of work, please let us think about if
>> this is the right approach first.
> 
> Sure. This idea that increase page pool when set max vcpu is from Jan.
> Jan, Could you help to check whether current patch is right approach?

Whenever I get to it, sure. What I can say right away is that I
agree with the comment about the name of the function.

Jan
diff mbox

Patch

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 6512f01..94cf70b 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -824,6 +824,11 @@  int arch_vcpu_reset(struct vcpu *v)
     return 0;
 }
 
+int arch_domain_set_max_vcpus(struct domain *d)
+{
+    return 0;
+}
+
 static int relinquish_memory(struct domain *d, struct page_list_head *list)
 {
     struct page_info *page, *tmp;
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index dbddc53..0e230f9 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -1161,6 +1161,31 @@  int arch_vcpu_reset(struct vcpu *v)
     return 0;
 }
 
+int arch_domain_set_max_vcpus(struct domain *d)
+{
+    int ret;
+
+    /* Increase page pool in order to support more vcpus. */
+    if ( d->max_vcpus > 128 )
+    {
+        unsigned long nr_pages;
+
+        if (hap_enabled(d))
+            nr_pages = 1024;
+        else
+            nr_pages = 4096;
+
+        ret = paging_set_allocation(d, nr_pages, NULL);
+        if ( ret != 0 )
+        {
+            paging_set_allocation(d, 0, NULL);
+            return ret;
+        }
+    }
+
+    return 0;
+}
+
 long
 arch_do_vcpu_op(
     int cmd, struct vcpu *v, XEN_GUEST_HANDLE_PARAM(void) arg)
diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index 42658e5..64357a3 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -631,6 +631,9 @@  long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
             d->max_vcpus = max;
         }
 
+        if ( arch_domain_set_max_vcpus(d) < 0)
+            goto maxvcpu_out;
+
         for ( i = 0; i < max; i++ )
         {
             if ( d->vcpu[i] != NULL )
diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h
index 347f264..e1ece3a 100644
--- a/xen/include/xen/domain.h
+++ b/xen/include/xen/domain.h
@@ -81,6 +81,8 @@  void arch_dump_domain_info(struct domain *d);
 
 int arch_vcpu_reset(struct vcpu *);
 
+int arch_domain_set_max_vcpus(struct domain *d);
+
 extern spinlock_t vcpu_alloc_lock;
 bool_t domctl_lock_acquire(void);
 void domctl_lock_release(void);