xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] xen/x86: support setting dom0_mem depending on host size
@ 2018-12-06  8:06 Juergen Gross
  2018-12-06  8:06 ` [PATCH v2 1/3] xen: introduce parse_size_and_unit_or_int Juergen Gross
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Juergen Gross @ 2018-12-06  8:06 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, Stefano Stabellini, Wei Liu,
	Konrad Rzeszutek Wilk, George Dunlap, Andrew Cooper, Ian Jackson,
	Tim Deegan, Julien Grall, Jan Beulich, Roger Pau Monné

Setting the memory size of dom0 on a server for the non autoballooning
case requires always specification of a boot parameter today. The value
to set will depend mostly on the host memory size.

In order to support that scenario add the possibility to set dom0_mem
depending on the amount of physical memory by allowing to specify a
percentage of host memory (e.g. 10%) with an offset (like 1G+10%).

To make it easy for a distributor to use such a setting as the default
make the standard setting for dom0_mem configurable via Kconfig.

Changes since V1:
- replaced old patch 1 by new one
- rewritten patch 2 according to remarks by Jan Beulich
- changed patch 3 to allow config item on arm, too

Juergen Gross (3):
  xen: introduce parse_size_and_unit_or_int
  xen/x86: add dom0 memory sizing variants
  xen: add CONFIG item for default dom0 memory size

 docs/misc/xen-command-line.markdown |  19 ++++--
 xen/arch/arm/domain_build.c         |   7 +++
 xen/arch/x86/dom0_build.c           | 112 +++++++++++++++++++++++++++---------
 xen/common/Kconfig                  |  13 +++++
 xen/common/lib.c                    |  11 +++-
 xen/include/xen/lib.h               |   2 +
 6 files changed, 130 insertions(+), 34 deletions(-)

-- 
2.16.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: [PATCH v2 2/3] xen/x86: add dom0 memory sizing variants
@ 2018-12-06 11:34 Juergen Gross
  0 siblings, 0 replies; 12+ messages in thread
From: Juergen Gross @ 2018-12-06 11:34 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan,
	Julien Grall, xen-devel, Roger Pau Monne

On 06/12/2018 12:28, Jan Beulich wrote:
>>>> On 06.12.18 at 12:20, <jgross@suse.com> wrote:
>> On 06/12/2018 12:08, Jan Beulich wrote:
>>>>>> On 06.12.18 at 09:06, <jgross@suse.com> wrote:
>>>> Today the memory size of dom0 can be specified only in terms of bytes
>>>> (either an absolute value or "host-mem - value"). When dom0 shouldn't
>>>> be auto-ballooned this requires nearly always a manual adaption of the
>>>> Xen boot parameters to reflect the actual host memory size.
>>>>
>>>> Add more possibilities to specify memory sizes. Today we have:
>>>>
>>>> dom0_mem= List of ( min:<size> | max:<size> | <size> )
>>>>
>>>> with <size> being a positive or negative size value (e.g. 1G).
>>>>
>>>> Modify that to:
>>>>
>>>> dom0_mem= List of ( min:<sz> | max:<sz> | <sz> )
>>>> <sz>: <size> | [<size>+]<frac>%
>>>> <frac>: integer value < 100
>>>>
>>>> With the following semantics:
>>>>
>>>> <frac>% specifies a fraction of host memory size in percent.
>>>> <sz> is a percentage of host memory plus an offset.
>>>>
>>>> So <sz> being 1G+25% on a 256G host would result in 65G.
>>>>
>>>> Signed-off-by: Juergen Gross <jgross@suse.com>
>>>
>>> Reviewed-by: Jan Beulich <jbeulich@suse.com>
>>>
>>> I notice though that ...
>>>
>>>> -static long __init parse_amt(const char *s, const char **ps)
>>>> +static int __init parse_amt(const char *s, const char **ps, struct memsize *sz)
>>>>  {
>>>> -    long pages = parse_size_and_unit((*s == '-') ? s+1 : s, ps) >> PAGE_SHIFT;
>>>> -    return (*s == '-') ? -pages : pages;
>>>> +    unsigned long val;
>>>> +    struct memsize tmp = { };
>>>> +
>>>> +    tmp.minus = (*s == '-');
>>>> +    if ( tmp.minus )
>>>> +        s++;
>>>> +
>>>> +    /* Avoid accessing s[-1] in case value starts with '%'. */
>>>> +    if ( *s == '%' )
>>>> +        return -EINVAL;
>>>> +
>>>> +    while ( isdigit(*s) )
>>>> +    {
>>>> +        val = parse_size_and_unit_or_int(s, ps, '%');
>>>> +        s = *ps;
>>>> +        if ( *s == '%' )
>>>> +        {
>>>> +            if ( !isdigit(s[-1]) || val >= 100 )
>>>> +                return -EINVAL;
>>>> +            tmp.percent = val;
>>>> +            s++;
>>>> +        }
>>>> +        else
>>>> +            tmp.nr_pages = val >> PAGE_SHIFT;
>>>> +        if ( *s == '+' )
>>>> +            s++;
>>>> +    }
>>>
>>> ... you allow more flexibility here than you document (i.e. also
>>> <percentage>+<basesize>). You may want to consider
>>> refusing something like 1G+10%+10%, though.
>>
>> Okay, should be fairly easy.
>>
>> Can I keep your R-b: with adding something like:
>>
>> +    bool percent = false;
>> ...
>> -    while ( isdigit(*s) )
>> +    while ( isdigit(*s) && !percent )
>> ...
>>          if ( *s == '%' )
>>          {
>> +            percent = true;
>> ...
> 
> Something like this, yes. The double percent value was just an
> example though, "1G+10%+1G" then too would better either work
> as written, or be refused.

Okay, I'll modify the patch accordingly and drop your R-b.


Juergen

> 
> Jan
> 


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

end of thread, other threads:[~2018-12-06 11:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-06  8:06 [PATCH v2 0/3] xen/x86: support setting dom0_mem depending on host size Juergen Gross
2018-12-06  8:06 ` [PATCH v2 1/3] xen: introduce parse_size_and_unit_or_int Juergen Gross
2018-12-06  9:50   ` Jan Beulich
     [not found]   ` <5C08F0CE0200007800203751@suse.com>
2018-12-06 10:01     ` Juergen Gross
2018-12-06 10:15       ` Jan Beulich
2018-12-06  8:06 ` [PATCH v2 2/3] xen/x86: add dom0 memory sizing variants Juergen Gross
2018-12-06 11:08   ` Jan Beulich
     [not found]   ` <5C09031502000078002039F0@suse.com>
2018-12-06 11:20     ` Juergen Gross
2018-12-06 11:28       ` Jan Beulich
2018-12-06  8:06 ` [PATCH v2 3/3] xen: add CONFIG item for default dom0 memory size Juergen Gross
2018-12-06 11:09   ` Jan Beulich
2018-12-06 11:34 [PATCH v2 2/3] xen/x86: add dom0 memory sizing variants Juergen Gross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).