All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael Kelley (LINUX)" <mikelley@microsoft.com>
To: "Florian Müller" <max06.net@outlook.com>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	vkuznets <vkuznets@redhat.com>
Subject: RE: hv_balloon: Only works in ubuntu
Date: Mon, 13 Jun 2022 00:56:02 +0000	[thread overview]
Message-ID: <BY3PR21MB3033FBB3CF2011B1D0DA2978D7AB9@BY3PR21MB3033.namprd21.prod.outlook.com> (raw)
In-Reply-To: <DB3PR0602MB36740EE00B8BA3B897BCB7C0FFA99@DB3PR0602MB3674.eurprd06.prod.outlook.com>

From: Florian Müller <max06.net@outlook.com> Sent: Saturday, June 11, 2022 12:45 PM
> 
> > > > >
> > > > > Issues showed up when I set up a Kali Linux Guest. I missed the
> > > > > memory configuration before booting up the instance, so it started
> > > > > with 1GB of memory, and ballooning active between 512MB and
> > > > > several TB of memory. Hyper-V started to allocate more and more
> > > > > memory to this guest since the reported memory requirements also
> > > > > increased. The guest kernel didn't see any of that allocated memory, as 
> > > > > far as I can tell.
> > > >
> > > > Hot-adding new memory is done partially by the hv_balloon driver,
> > > > but it also requires user space action.  The user space action is provided
> > > > by udev rules.
> > > > In your Ubuntu Server 20.04 guest, there's a file
> > > > /lib/udev/rules.d/40-vm- hotadd.rules.
> > > > This file contains udev rules for hot-adding memory and CPUs.  You
> > > > should be able to copy this file with the udev rules onto your Kali
> > > > system, and then the memory hot-add should work correctly.
> > > >
> > > > I'm not sure why Kali doesn't already have such udev rules.  You
> > > > might grep through all the files in /lib/udev/rules.d and if there
> > > > are any rules for SUBSYSTEM==memory.
> > > > Sometimes there are rules present, but commented out.
> > > >
> > > Thanks, I'll check these ones out!
> > >
> > > In the meantime, I was able to get it working, by compiling a kernel
> > > with CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE=y
> > > Which was previously unset. It's enabled in ubuntu and it seems to
> > > make hv_balloon work properly.
> > > This seems to be the same case with Debian.
> > >
> >
> > Yes, that looks like a good solution.  I didn't remember that there is a kernel
> > config option to automatically do the onlining.  With this kernel option
> > enabled, using a udev rule obviously isn't needed.  The kernel option was
> > added in Linux kernel version 4.7, which might be after the last time I looked
> > at Hyper-V memory hot-add in detail.
> >
> > Michael
> >
> 
> Awesome!
> 
> Last question: Since not having the kernel option by default and also not having the
> udev rule in some distributions causes the Hyper-V host to eat up all the memory up to
> the defined limit (and to die eventually), should this be considered as a bug? And if the
> answer is no, how can I (or anyone) forward the requirement to the publishers to be
> solved at the source?
> 
> Thank you!
> 

It's unclear whether this should be treated as a bug.  We certainly want the
"right" thing to happen as seamlessly as possible, but there are tradeoffs.  Back
when Vitaly Kuznetsov added CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE,
I can see there was some debate about whether this option should be enabled
by default. There was reluctance to do so because of potential backwards
compatibility problems with other environments.  When hot-adding real
physical memory to a bare-metal server, apparently you don't want to 
automatically online the added memory.

The Ubuntu image you were testing is specifically an image configured for use
in an Azure VM, so it makes sense to have memory automatically onlined by
the kernel.  So I looked at a generic Ubuntu 18.04 system, and it also has
this kernel option set by default.  But as another data point, RHEL/CentOS 8.4
does *not* have the kernel option set.  So each distro evidently makes their
own decision about this.  But both generic Ubuntu 18.04 and RHEL/CentOS 8.4
have the udev rules.  The RHEL/CentOS 8.4 udev rule is more sophisticated
in that it does not online the added memory when running on System/390
and PowerPC.

I could envision changing the Linux kernel config rules to automatically set
CONFIG_MEMORY_HOTPLUG_DEFAULT_ONLINE whenever 
CONFIG_HYPERV_BALLOON is selected.  Alternatively, the Kali Linux folks
could consider adding the appropriate udev rule.  My team at Microsoft
has direct engineering-to-engineer contacts with the most prevalent
distros for production server usage, such as in Azure.  But Kali is not one of
those, so I don't necessarily have a better way to contact them than you
do.

I've included Vitaly on the "To:" line of this email thread in case he has
any further thoughts.

Michael




  reply	other threads:[~2022-06-13  0:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-11 15:40 hv_balloon: Only works in ubuntu Florian Müller
2022-06-11 17:36 ` Michael Kelley (LINUX)
2022-06-11 17:58   ` AW: " Florian Müller
2022-06-11 19:30     ` Michael Kelley (LINUX)
2022-06-11 19:44       ` AW: " Florian Müller
2022-06-13  0:56         ` Michael Kelley (LINUX) [this message]
2022-06-13  7:58           ` Vitaly Kuznetsov
2022-06-13  8:47             ` David Hildenbrand
2022-06-13  8:53             ` AW: " Florian M?ller
2022-06-13  9:29               ` David Hildenbrand
2022-06-13 14:04               ` Michael Kelley (LINUX)
2022-06-13 14:45                 ` AW: " Florian M?ller
2022-06-14 17:01                   ` Michael Kelley (LINUX)

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=BY3PR21MB3033FBB3CF2011B1D0DA2978D7AB9@BY3PR21MB3033.namprd21.prod.outlook.com \
    --to=mikelley@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=max06.net@outlook.com \
    --cc=vkuznets@redhat.com \
    /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.