All of lore.kernel.org
 help / color / mirror / Atom feed
* running into OOM killer with kexec loading large ramdisk
@ 2022-03-23 11:14 Tobias Powalowski
  2022-03-25 12:26 ` Philipp Rudo
  0 siblings, 1 reply; 3+ messages in thread
From: Tobias Powalowski @ 2022-03-23 11:14 UTC (permalink / raw)
  To: kexec

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?
greetings
tpowa


-- 
Tobias Powalowski
Arch Linux Developer & Package Maintainer (tpowa)
https://www.archlinux.org
tpowa at archlinux.org

St. Martin-Apotheke
Herzog-Georg-Str. 25
89415 Lauingen
https://www.st-martin-apo.de
info at st-martin-apo.de


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

* running into OOM killer with kexec loading large ramdisk
  2022-03-23 11:14 running into OOM killer with kexec loading large ramdisk Tobias Powalowski
@ 2022-03-25 12:26 ` Philipp Rudo
  2022-03-25 13:04   ` Tobias Powalowski
  0 siblings, 1 reply; 3+ messages in thread
From: Philipp Rudo @ 2022-03-25 12:26 UTC (permalink / raw)
  To: kexec

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



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

* running into OOM killer with kexec loading large ramdisk
  2022-03-25 12:26 ` Philipp Rudo
@ 2022-03-25 13:04   ` Tobias Powalowski
  0 siblings, 0 replies; 3+ messages in thread
From: Tobias Powalowski @ 2022-03-25 13:04 UTC (permalink / raw)
  To: kexec

Hi, thanks for the explanation,
I got it now working, with running the kexec call in the background
and deleting the initramfs in the foreground after sleep 1.
I still think kexec should handle this with less memory needed.
greetings
tpowa

Am Fr., 25. M?rz 2022 um 13:26 Uhr schrieb Philipp Rudo <prudo@redhat.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
>


-- 
Tobias Powalowski
Arch Linux Developer & Package Maintainer (tpowa)
https://www.archlinux.org
tpowa at archlinux.org

St. Martin-Apotheke
Herzog-Georg-Str. 25
89415 Lauingen
https://www.st-martin-apo.de
info at st-martin-apo.de


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

end of thread, other threads:[~2022-03-25 13:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-23 11:14 running into OOM killer with kexec loading large ramdisk Tobias Powalowski
2022-03-25 12:26 ` Philipp Rudo
2022-03-25 13:04   ` Tobias Powalowski

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.