qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
	Peter Xu <peterx@redhat.com>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>,
	Bin Meng <bmeng.cn@gmail.com>
Subject: Re: [PATCH] softmmu/physmem: Improve guest memory allocation failure error message
Date: Mon, 23 Aug 2021 12:24:16 +0200	[thread overview]
Message-ID: <628a7ee5-b88d-c043-2e67-67e791532c18@redhat.com> (raw)
In-Reply-To: <1a63c2d2-7420-5fc1-1023-0504a67dc40b@redhat.com>

On 23.08.21 12:12, Philippe Mathieu-Daudé wrote:
> On 8/23/21 11:29 AM, David Hildenbrand wrote:
>> On 23.08.21 11:23, Peter Maydell wrote:
>>> On Mon, 23 Aug 2021 at 09:40, David Hildenbrand <david@redhat.com> wrote:
>>>> Not opposed to printing the size, although I doubt that it will really
>>>> stop similar questions/problems getting raised.
>>>
>>> The case that triggered this was somebody thinking
>>> -m took a byte count, so very likely that an error message
>>> saying "you tried to allocate 38TB" would have made their
>>> mistake clear in a way that just "allocation failed" did not.
>>> It also means that if a future user asks us for help then
>>> we can look at the error message and immediately tell them
>>> the problem, rather than going "hmm, what are all the possible
>>> ways that allocation might have failed" and going off down
>>> rabbitholes like VM overcommit settings...
>>
>> We've had similar issues recently where Linux memory overcommit handling
>> rejected the allocation -- and the user was well aware about the actual
>> size. You won't be able to catch such reports, because people don't
>> understand how Linux memory overcommit handling works or was configured.
>>
>> "I have 3 GiB of free memory, why can't I create a 3 GiB VM". "I have 3
>> GiB of RAM, why can't I create a 3 GiB VM even if it won't make use of
>> all 3 GiB of memory".
>>
>> Thus my comment, it will only stop very basic usage issues. And I agree
>> that looking at the error *might* help. It didn't help for the cases I
>> just described, because we need much more system information to make a
>> guess what the user error actually is.
> 
> Is it possible to get the maximal overcommitable amount on Linux?

Not reliably I think.

In the "always" mode, there is none.

In the "guess"/"estimate" mode, the kernel takes a guess (currently 
implemented as checking if the mmap size <= total RAM + total SWAP).
	Committable = MemTotal + SwapTotal

In the "never" mode:
	Committable = CommitLimit - Committed_AS
However, the value gets further reduced for !root applications by 
/proc/sys/vm/admin_reserve_kbytes.

Replicating these calculations in user space would be suboptimal IMHO.

-- 
Thanks,

David / dhildenb



  reply	other threads:[~2021-08-23 10:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-20 15:52 [PATCH] softmmu/physmem: Improve guest memory allocation failure error message Philippe Mathieu-Daudé
2021-08-20 15:53 ` David Hildenbrand
2021-08-20 16:00   ` Philippe Mathieu-Daudé
2021-08-20 16:40     ` Igor Mammedov
2021-08-20 16:59       ` Philippe Mathieu-Daudé
2021-08-20 17:13         ` Peter Maydell
2021-08-23  8:38     ` David Hildenbrand
2021-08-23  9:23       ` Peter Maydell
2021-08-23  9:29         ` David Hildenbrand
2021-08-23 10:12           ` Philippe Mathieu-Daudé
2021-08-23 10:24             ` David Hildenbrand [this message]
2021-08-23 10:34               ` Philippe Mathieu-Daudé
2021-08-23 19:27                 ` David Hildenbrand
2021-08-24  8:37                   ` Dr. David Alan Gilbert
2021-08-24  8:53                     ` David Hildenbrand
2021-08-24 11:42                     ` Igor Mammedov
2021-08-20 20:31 ` Peter Xu
2021-08-21 10:01 ` Bin Meng
2021-08-21 10:41   ` Peter Maydell
2021-08-21 13:32   ` Philippe Mathieu-Daudé

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=628a7ee5-b88d-c043-2e67-67e791532c18@redhat.com \
    --to=david@redhat.com \
    --cc=bmeng.cn@gmail.com \
    --cc=dgilbert@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=peterx@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.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 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).