All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Streetman <dan.streetman@canonical.com>
To: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>,
	xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org
Subject: Re: maybe revert commit c275a57f5ec3 "xen/balloon: Set balloon's initial state to number of existing RAM pages"
Date: Mon, 27 Mar 2017 15:57:31 -0400	[thread overview]
Message-ID: <CAOZ2QJMkqY556qXkdgFpFpir381dJTuPKex+SjdnH43sspkkWw__29293.9762388871$1490644766$gmane$org@mail.gmail.com> (raw)
In-Reply-To: <c7cbd3c7-5785-a3cc-ca28-a289ebe1cb4f@oracle.com>

On Fri, Mar 24, 2017 at 9:33 PM, Boris Ostrovsky
<boris.ostrovsky@oracle.com> wrote:
>
>>
>> I think we can all agree that the *ideal* situation would be, for the
>> balloon driver to not immediately hotplug memory so it can add 11 more
>> pages, so maybe I just need to figure out why the balloon driver
>> thinks it needs 11 more pages, and fix that.
>
>
>
> How does the new memory appear in the guest? Via online_pages()?
>
> Or is ballooning triggered from watch_target()?

yes, it's triggered from watch_target() which then calls
online_pages() with the new memory.  I added some debug (all numbers
are in hex):

[    0.500080] xen:balloon: Initialising balloon driver
[    0.503027] xen:balloon: balloon_init: current/target pages 1fff9d
[    0.504044] xen_balloon: Initialising balloon driver
[    0.508046] xen_balloon: watch_target: new target 800000 kb
[    0.508046] xen:balloon: balloon_set_new_target: target 200000
[    0.524024] xen:balloon: current_credit: target pages 200000
current pages 1fff9d credit 63
[    0.567055] xen:balloon: balloon_process: current_credit 63
[    0.568005] xen:balloon: reserve_additional_memory: adding memory
resource for 8000 pages
[    3.694443] online_pages: pfn 210000 nr_pages 8000 type 0
[    3.701072] xen:balloon: current_credit: target pages 200000
current pages 1fff9d credit 63
[    3.701074] xen:balloon: balloon_process: current_credit 63
[    3.701075] xen:balloon: increase_reservation: nr_pages 63
[    3.701170] xen:balloon: increase_reservation: done, current_pages 1fffa8
[    3.701172] xen:balloon: current_credit: target pages 200000
current pages 1fffa8 credit 58
[    3.701173] xen:balloon: balloon_process: current_credit 58
[    3.701173] xen:balloon: increase_reservation: nr_pages 58
[    3.701180] xen:balloon: increase_reservation: XENMEM_populate_physmap err 0
[    5.708085] xen:balloon: current_credit: target pages 200000
current pages 1fffa8 credit 58
[    5.708088] xen:balloon: balloon_process: current_credit 58
[    5.708089] xen:balloon: increase_reservation: nr_pages 58
[    5.708106] xen:balloon: increase_reservation: XENMEM_populate_physmap err 0
[    9.716065] xen:balloon: current_credit: target pages 200000
current pages 1fffa8 credit 58
[    9.716068] xen:balloon: balloon_process: current_credit 58
[    9.716069] xen:balloon: increase_reservation: nr_pages 58
[    9.716087] xen:balloon: increase_reservation: XENMEM_populate_physmap err 0


and that continues forever at the max interval (32), since
max_retry_count is unlimited.  So I think I understand things now;
first, the current_pages is set properly based on the e820 map:

$ dmesg|grep -i e820
[    0.000000] e820: BIOS-provided physical RAM map:
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009dfff] usable
[    0.000000] BIOS-e820: [mem 0x000000000009e000-0x000000000009ffff] reserved
[    0.000000] BIOS-e820: [mem 0x00000000000e0000-0x00000000000fffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000000100000-0x00000000efffffff] usable
[    0.000000] BIOS-e820: [mem 0x00000000fc000000-0x00000000ffffffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x000000020fffffff] usable
[    0.000000] e820: update [mem 0x00000000-0x00000fff] usable ==> reserved
[    0.000000] e820: remove [mem 0x000a0000-0x000fffff] usable
[    0.000000] e820: last_pfn = 0x210000 max_arch_pfn = 0x400000000
[    0.000000] e820: last_pfn = 0xf0000 max_arch_pfn = 0x400000000
[    0.000000] e820: [mem 0xf0000000-0xfbffffff] available for PCI devices
[    0.528007] e820: reserve RAM buffer [mem 0x0009e000-0x0009ffff]
ubuntu@ip-172-31-60-112:~$ printf "%x\n" $[ 0x210000 - 0x100000 +
0xf0000 - 0x100 + 0x9e - 1 ]
1fff9d


then, the xen balloon notices its target has been set to 200000 by the
hypervisor.  That target does account for the hole at 0xf0000 to
0x100000, but it doesn't account for the hole at 0xe0 to 0x100 ( 0x20
pages), nor the hole at 0x9e to 0xa0 ( 2 pages ), nor the unlisted
hole (that the kernel removes) at 0xa0 to 0xe0 ( 0x40 pages).  That's
0x62 pages, plus the 1-page hole at addr 0 that the kernel always
reserves, is 0x63 pages of holes, which aren't accounted for in the
hypervisor's target.

so the balloon driver hotplugs the memory, and tries to increase its
reservation to provide the needed pages to get the current_pages up to
the target.  However, when it calls the hypervisor to populate the
physmap, the hypervisor only allows 11 (0xb) pages to be populated;
all calls after that get back 0 from the hypervisor.

Do you think the hypervisor's balloon target should account for the
e820 holes (and for the kernel's added hole at addr 0)?
Alternately/additionally, if the hypervisor doesn't want to support
ballooning, should it just return error from the call to populate the
physmap, and not allow those 11 pages?

At this point, it doesn't seem to me like the kernel is doing anything
wrong, correct?

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

  parent reply	other threads:[~2017-03-27 19:58 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-22 21:16 maybe revert commit c275a57f5ec3 "xen/balloon: Set balloon's initial state to number of existing RAM pages" Dan Streetman
2017-03-23  2:13 ` Boris Ostrovsky
2017-03-23  7:56   ` Juergen Gross
2017-03-23  7:56   ` Juergen Gross
2017-03-24 20:30     ` Dan Streetman
2017-03-24 20:30     ` Dan Streetman
2017-03-24 20:34   ` Dan Streetman
2017-03-24 20:34   ` Dan Streetman
2017-03-24 21:10     ` Konrad Rzeszutek Wilk
2017-03-24 21:10     ` Konrad Rzeszutek Wilk
2017-03-24 21:26       ` Dan Streetman
2017-03-24 21:26       ` Dan Streetman
2017-03-25  1:33         ` Boris Ostrovsky
2017-03-25  1:33           ` Boris Ostrovsky
2017-03-27 19:57           ` Dan Streetman
2017-03-28  1:57             ` Boris Ostrovsky
2017-03-28  8:08               ` [Xen-devel] " Jan Beulich
2017-03-28  8:08                 ` Jan Beulich
2017-03-28 14:27                 ` Boris Ostrovsky
2017-03-28 14:27                 ` [Xen-devel] " Boris Ostrovsky
2017-03-28 15:04                   ` Jan Beulich
2017-03-28 15:04                     ` Jan Beulich
2017-03-28 15:30                   ` [Xen-devel] " Juergen Gross
2017-03-28 15:30                     ` Juergen Gross
2017-03-28 16:32                     ` Boris Ostrovsky
2017-03-28 16:32                     ` [Xen-devel] " Boris Ostrovsky
2017-03-29  4:36                       ` Juergen Gross
2017-03-29  4:36                       ` [Xen-devel] " Juergen Gross
2017-07-08  0:59                     ` Konrad Rzeszutek Wilk
2017-07-08  0:59                     ` [Xen-devel] " Konrad Rzeszutek Wilk
2017-07-09 13:16                       ` Juergen Gross
2017-07-09 13:16                       ` Juergen Gross
2017-03-28  1:57             ` Boris Ostrovsky
2017-03-27 19:57           ` Dan Streetman [this message]
2017-03-23  2:13 ` Boris Ostrovsky
  -- strict thread matches above, loose matches on Subject: below --
2017-03-22 21:16 Dan Streetman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOZ2QJMkqY556qXkdgFpFpir381dJTuPKex+SjdnH43sspkkWw__29293.9762388871$1490644766$gmane$org@mail.gmail.com' \
    --to=dan.streetman@canonical.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.