You are not logged in.

#1 2021-01-29 16:16:09

foki
Member
Registered: 2012-03-22
Posts: 31

Kernel to kill the program that tries to use the whole RAM

I have a bunch of data sets and I run the same computation on each data set. I want to measure the runtime of each executed task (computation on a given data set).

When a task tries to use more memory than is available in RAM, I would like the kernel to kill it with an out of memory error, and to start the execution of the next task.

My first idea to achieve this was to turn swap off, so the process cannot use more memory than available in RAM.

However, what happens is that when the memory-hungry task exceeds the memory limit, my system crashes, reboots, and runs `systemd-coredump` to restore the crashed process. It then continues running the memory-hungry process.

I would like to achieve the following:
1. The memory-hungry process should not crash the system, the system should kill the process.
2. I don't want to let the process use swap space.
3. I don't want to impose a strict time limit on the execution of any task (I don't know how long they can run).

What would be your ideas?

Offline

#2 2021-01-29 16:29:34

loqs
Member
Registered: 2014-03-06
Posts: 19,155

Re: Kernel to kill the program that tries to use the whole RAM

Please post the system journal showing the crash,  reboot and systemd-coredump.

Offline

#3 2021-01-29 18:25:25

foki
Member
Registered: 2012-03-22
Posts: 31

Re: Kernel to kill the program that tries to use the whole RAM

What are you interested in, in particular?

Can you please elaborate a bit more.

Offline

#4 2021-01-29 18:28:56

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Kernel to kill the program that tries to use the whole RAM

foki wrote:

What are you interested in, in particular?

All of it....
https://bbs.archlinux.org/viewtopic.php?id=57855


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#5 2021-01-29 18:31:37

loqs
Member
Registered: 2014-03-06
Posts: 19,155

Re: Kernel to kill the program that tries to use the whole RAM

Why the system crashes,  what after the reboot starts the task again,  what the systemd-coredump was for.

Offline

#6 2021-01-29 20:30:46

ugjka
Member
From: Latvia
Registered: 2014-04-01
Posts: 1,962
Website

Re: Kernel to kill the program that tries to use the whole RAM

You can try fencing the processes with cgroups https://wiki.archlinux.org/index.php/cgroups

Offline

#7 2021-01-29 21:06:19

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: Kernel to kill the program that tries to use the whole RAM


Jin, Jîyan, Azadî

Offline

#8 2021-01-29 21:53:29

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 79,086

Re: Kernel to kill the program that tries to use the whole RAM

Or jail it in a https://wiki.archlinux.org/index.php/Cg … urce_usage

However

my system crashes, reboots, and runs `systemd-coredump` to restore the crashed process. It then continues running the memory-hungry process.

sounds fairly exotic and not like something that "just happens"…

Online

#9 2021-02-03 11:16:16

fistrosan
Member
Registered: 2020-04-01
Posts: 172

Re: Kernel to kill the program that tries to use the whole RAM

Why are you counting on the kernel  to kill your process ? Why not check if you have enough memory available within your computation and if you don't make a clean exit. For instance, using plain F90:

INTEGER :: STATUS
ALLOCATE(ARRAY(DIM1,DIM2,...),STAT=STATUS)

IF (STATUS > 0) THEN
   !! Do this
ELSE
   !! Do that
ENDIF

Last edited by fistrosan (2021-02-03 11:16:41)

Offline

Board footer

Powered by FluxBB