All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philipp Rudo <prudo@redhat.com>
To: kexec@lists.infradead.org
Subject: running into OOM killer with kexec loading large ramdisk
Date: Fri, 25 Mar 2022 13:26:11 +0100	[thread overview]
Message-ID: <20220325132611.5b394142@rhtmp> (raw)
In-Reply-To: <CAHfPjO8XBp5C_kTaifPjLVJxS3Z7W5V+qHEm6-zh2_Jv8Ydyew@mail.gmail.com>

Hi Tobias,

On Wed, 23 Mar 2022 12:14:59 +0100
Tobias Powalowski <tobias.powalowski@googlemail.com> wrote:

> Hi,
> again me,
> I try to load a 900MB ramdisk on a ramfs rootfs  with kexec and a 10MB kernel.
> With 2800MB RAM assigned to qemu.
> Memory free by /proc/memstat: 2.2GB
> It keeps on OOM killed while executing:
> kexec -l kernel --initrd=initrd.img
> I can safely unpack the initrd in the ramfs without getting OOM killed.
> What is kexec doing wrong here?

I don't think that kexec is doing anything wrong here.

The kexec_load syscall is designed in a way that user space prepares
everything in a huge buffer and passes a pointer to it to the system
call. The systemcall then needs to copy everything from the user buffer
to a kernel buffer. So there are three copies of the initrd in memory
(including the one in ramfs). Together they take up 3 * 900MB = 2.7GB.
So basically all the memory of your guest.

You can try using the kexec_file_load systemcall. That at least
eliminates the copy in the user buffer so there are only two copies
left. 400MB of free memory is still quite scarce, though.

Thanks
Philipp



  reply	other threads:[~2022-03-25 12:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-23 11:14 running into OOM killer with kexec loading large ramdisk Tobias Powalowski
2022-03-25 12:26 ` Philipp Rudo [this message]
2022-03-25 13:04   ` Tobias Powalowski

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=20220325132611.5b394142@rhtmp \
    --to=prudo@redhat.com \
    --cc=kexec@lists.infradead.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.