OOM when compiling the kernel while swap usage is 0

I’ve been trying to compile the kernel (as some sort of benchmark of my system’s performance) but then stumbled upon an strange behavior: the system insists on not touching and using swap at all, and dying with OOM.

But a small cpp binary which simply leaks memory by allocating in a loop without a call to delete, eventually forces the system to use the swap. It’s just the make -j in kernel directory that doesn’t like the swap. Yet, for the cpp binary, even though I set the swappiness to 99, the system doesn’t go to swap until the ram is 99% full.

Do you know what am I doing wrong?

Here are the relevant configurations:

/etc/fstab:

...
UUID=THE_UUID none swap defaults 0 0

uname -a:

Linux myhostname 5.17.0-1-MANJARO #1 SMP PREEMPT Mon Mar 7 08:29:54 UTC 2022 x86_64 GNU/Linux

Other things I’ve tried, out of despair, so some might sound silly:

  • Install a fresh Manjaro, using ext4.
  • Install a fresh Manjaro, using btrfs.
  • Use swap in a dedicated partition.
  • Use swap in a swap file on ext4.
  • Use swap in a swap file on btrfs.
  • Use dd to allocate the swap file instead of fallocate.
  • Let Manjaro installer create the swap file.
  • Let Manjaro installer create the swap partition.
  • Set swappiness to 30, 60, 99, 100.
  • Use LTS kernel.
  • Use latest experimental kernel.
  • Use a very old kernel.
  • Disable encryption on home drive.

is your designated swap partition recognized and actually used?

free

executed as a command
in a terminal

for instance

will tell

Sorry forgot to include free. Yes it’s recognized and used by the mentioned cpp binary, but not at all by make -j.

Here you can see the bin after running and being killed, has pushed some of my ram usage to swap:

               total        used        free      shared  buff/cache   available
Mem:            62Gi       2.4Gi        58Gi       753Mi       1.4Gi        58Gi
Swap:          192Gi       994Mi       191Gi

Crazy amount of swap because I recently was experimenting with adding a new swap partition and forgot to delete the old one.

Well, I don’t know what that really might means.

Fact is - in Manjaro and Arch
/etc/makepkg.conf
contains the relevant details

search/ grep for:
MAKEFLAGS
in that file

What actually is it that you are trying to do?
And how are you trying to do it - giving you these problems?

I’m trying to compile the kernel, as a measure of my new systems performance compared to old one. (I’m not interested in the result of compilation per se). I am now a bit side tracked though: there might be other ways of benchmarking, but now I’m curious about why I can’t compile the kernel!

I’m simply following this guide: Kernel/Traditional compilation - ArchWiki (except that I’m compiling the latest kernel from kernel.org).

But now that you have mentioned makepkg, I’ll try to compile the kernel the Arch/Manjaro way! see if it makes any difference.

make
by default
just uses one thread/core

the -j option tells it to use … what you tell it to be present

Perhaps start your kernel compilation with giving that make flag (-j)

If you do it via the ABS or otherwise utilizing makepkg
the setting in /etc/makepkg.conf
will be used.

I had the same issue with make -j 4 yesterday (or no -j at all, using one core).

Then today following your advise I started building the Manjaro’s provided kernel, with makepkg (which interestingly, uses nproc+1 according to makepkg.conf) and the issue is gone! the memory usage stays around 4GB all the time, and it’s utilizing all the 24 cores. nice!

I think now this is better asked in kernel mailing list, it’s rather not related to Manjaro why mainline kernel is behaving crazy. (or perhaps I should study the Manjaro patches + build / makepkg files see what’s the difference).

I’ll mark this post as solved.
Thanks for the support!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.