Skip to contentSkip to conversation

Killing/balancing processes when overcommited

DISCUSSION Jim Sibley 4 participants 11 messages Sep 13, 2002 – Sep 16, 2002

lore
Share & tools
lore

Jim Sibley

author
#0 lore raw
Quoted 3 lines · Tim

There is another solution. And that is never >allocate memory unless
you have swap space. Yes, the issue is that you >need to have lots of disk allocated to swap but on a big machine you >will have that space.

How do you predict if a program is going to ask for more memory? Maybe it only needs additional memory for a short time and is a good citizen and gives it back?

How much disk needs to be allocated for swap? In 32 bit, each logged in user is limited to 2 GB, so do we need 2 GB for each logged on user? 250 users, 500 GB of disk?

In a 64 bit system, how much swap would you reserve?

Actually, another OS took this approach in the early 70's and this was quickly junked when they found out how much disk they really had to keep in reserve for paging.

Quoted 4 lines

This way the offending process that asks for >more memory will be
the one that gets killed. Even if the 1st couple >of ones aren't the misbehaving process eventually it will ask for >more memory and suffer process execution.

It may not be the "offending process" that is asking for more memory. How do you judge "offending?"

#1 lore raw
Quoted 11 lines · Jim Sibley
Quoted 3 lines · Tim

There is another solution. And that is never >allocate memory unless
you have swap space. Yes, the issue is that you >need to have lots of disk allocated to swap but on a big machine you >will have that space.

How do you predict if a program is going to ask for more memory? Maybe it only needs additional memory for a short time and is a good citizen and gives it back?

Well its been a bit so the details are fuzzy but you have a pointer
to how much space you have left in you allocated swap and when you get memory you decrement space and when you release memory in increment it so that it indicates how much you have left. If you try and malloc more than you free then you go and reserve another chunk of swap.

Quoted 4 lines

How much disk needs to be allocated for swap? In 32 bit, each logged in user is limited to 2 GB, so do we need 2 GB for each logged on user? 250 users, 500 GB of disk?

It turns out that for the high load database machines this is about
3 to 4 times the actual physical memory.

Quoted 2 lines

In a 64 bit system, how much swap would you reserve?

Same as 32 bit machines doesn't apply.

Quoted 4 lines

Actually, another OS took this approach in the early 70's and this was quickly junked when they found out how much disk they really had to keep in reserve for paging.

But there are many current OS's that do this and are quite successful.

Quoted 8 lines
Quoted 4 lines

This way the offending process that asks for >more memory will be
the one that gets killed. Even if the 1st couple >of ones aren't the misbehaving process eventually it will ask for >more memory and suffer process execution.

It may not be the "offending process" that is asking for more memory. How do you judge "offending?"

In this case the offense is asking for more memory. So it is the
process that asks for more memory that goes away. Again sometimes it will be an innocent bystander but hopefully it will eventually be the process that is causing the problem.

Many databases program for this condition. The stuff that absolutely
must be up and running preallocates all of the memory that it needs at startup. Any new memory requests that are denied might cause a transaction to fail but they won't bring down the whole database.

Tim

Quoted 4 lines
Signature · 5 lines
Timothy D. Witham - Lab Director - [email protected]
Open Source Development Lab Inc - A non-profit corporation
15275 SW Koll Parkway - Suite H - Beaverton OR, 97006
(503)-626-2455 x11 (office)    (503)-702-2871     (cell)
(503)-626-2436     (fax)
#2 lore raw
Quoted 9 lines · Timothy D. Witham
Quoted 7 lines · Jim Sibley
Quoted 3 lines · Tim

There is another solution. And that is never >allocate memory unless
you have swap space. Yes, the issue is that you >need to have lots of disk allocated to swap but on a big machine you >will have that space.

Quoted 6 lines
Quoted 4 lines

How do you predict if a program is going to ask for more memory? Maybe it only needs additional memory for a short time and is a good citizen and gives it back?

Well its been a bit so the details are fuzzy but you have a pointer

Counter, I meant to say "a counter as to " instead of "a pointer to".

:-)

Quoted 63 lines

to how much space you have left in you allocated swap and when you get memory you decrement space and when you release memory in increment it so that it indicates how much you have left. If you try and malloc more than you free then you go and reserve another chunk of swap.

Quoted 4 lines

How much disk needs to be allocated for swap? In 32 bit, each logged in user is limited to 2 GB, so do we need 2 GB for each logged on user? 250 users, 500 GB of disk?

It turns out that for the high load database machines this is about
3 to 4 times the actual physical memory.

Quoted 2 lines

In a 64 bit system, how much swap would you reserve?

Same as 32 bit machines doesn't apply.

Quoted 4 lines

Actually, another OS took this approach in the early 70's and this was quickly junked when they found out how much disk they really had to keep in reserve for paging.

But there are many current OS's that do this and are quite successful.

Quoted 8 lines
Quoted 4 lines

This way the offending process that asks for >more memory will be
the one that gets killed. Even if the 1st couple >of ones aren't the misbehaving process eventually it will ask for >more memory and suffer process execution.

It may not be the "offending process" that is asking for more memory. How do you judge "offending?"

In this case the offense is asking for more memory. So it is the
process that asks for more memory that goes away. Again sometimes it will be an innocent bystander but hopefully it will eventually be the process that is causing the problem.

Many databases program for this condition. The stuff that absolutely
must be up and running preallocates all of the memory that it needs at startup. Any new memory requests that are denied might cause a transaction to fail but they won't bring down the whole database.

Tim

Quoted 4 lines
Signature · 11 lines
Timothy D. Witham - Lab Director - [email protected]
Open Source Development Lab Inc - A non-profit corporation
15275 SW Koll Parkway - Suite H - Beaverton OR, 97006
(503)-626-2455 x11 (office)    (503)-702-2871     (cell)
(503)-626-2436     (fax)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Signature · 5 lines
Timothy D. Witham - Lab Director - [email protected]
Open Source Development Lab Inc - A non-profit corporation
15275 SW Koll Parkway - Suite H - Beaverton OR, 97006
(503)-626-2455 x11 (office)    (503)-702-2871     (cell)
(503)-626-2436     (fax)
#3 lore raw
In reply to Timothy D. Witham
Quoted 4 lines · Timothy D. Witham

In this case the offense is asking for more memory. So it is the
process that asks for more memory that goes away. Again sometimes it will be an innocent bystander but hopefully it will eventually be the process that is causing the problem.

If you kill the process that requests memory, the sequence often goes as follows:

1) memory is exhausted

2) the network driver can't allocate memory and
spits out a message

3) syslogd and/or klogd get killed

Clearly you want to be a bit smarter about which process to kill.

regards,

Rik

Signature · 5 lines
Bravely reimplemented by the knights who say "NIH".

http://www.surriel.com/		http://distro.conectiva.com/

Spamtraps of the month:  [email protected] [email protected]
#4 lore raw
Quoted 10 lines · Rik van Riel
Quoted 4 lines · Timothy D. Witham

In this case the offense is asking for more memory. So it is the
process that asks for more memory that goes away. Again sometimes it will be an innocent bystander but hopefully it will eventually be the process that is causing the problem.

If you kill the process that requests memory, the sequence often goes as follows:

Quoted 9 lines

1) memory is exhausted

2) the network driver can't allocate memory and
spits out a message

3) syslogd and/or klogd get killed

Clearly you want to be a bit smarter about which process to kill.

Right, you need to have a hold back for the kernel/root items to ensure that this sort of thing doesn't happen.

Quoted 15 lines

regards,

Rik

Signature · 11 lines
Bravely reimplemented by the knights who say "NIH".

http://www.surriel.com/		http://distro.conectiva.com/

Spamtraps of the month:  [email protected] [email protected]

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Signature · 5 lines
Timothy D. Witham - Lab Director - [email protected]
Open Source Development Lab Inc - A non-profit corporation
15275 SW Koll Parkway - Suite H - Beaverton OR, 97006
(503)-626-2455 x11 (office)    (503)-702-2871     (cell)
(503)-626-2436     (fax)
#5 lore raw
In reply to Rik van Riel
Quoted 11 lines · Rik van Riel

If you kill the process that requests memory, the sequence often goes as follows:

1) memory is exhausted

2) the network driver can't allocate memory and
spits out a message

3) syslogd and/or klogd get killed

Clearly you want to be a bit smarter about which process to kill.

Ill-implemented klogd/syslogd. Pre-allocating a little memory is one way to go, or drop messages until allocation becomes possible again. Then log a complaint about messages missing due to a temporary OOM.

Helge Hafting

#6 lore raw
Quoted 7 lines · Helge Hafting
Quoted 5 lines · Rik van Riel

1) memory is exhausted
2) the network driver can't allocate memory and
spits out a message
3) syslogd and/or klogd get killed

Quoted 6 lines
Quoted 1 line

Clearly you want to be a bit smarter about which process to kill.

Ill-implemented klogd/syslogd. Pre-allocating a little memory is one way to go, or drop messages until allocation becomes possible again. Then log a complaint about messages missing due to a temporary OOM.

No. This has absolutely nothing to do with it.

In this case, "allocating memory" simply means that klogd/syslogd page faults on something it already allocated, say a piece of the executable or a swapped-out buffer.

Simple page faults like this can also trigger an OOM-killing.

Rik

Signature · 5 lines
Bravely reimplemented by the knights who say "NIH".

http://www.surriel.com/		http://distro.conectiva.com/

Spamtraps of the month:  [email protected] [email protected]
#7 lore raw
Quoted 15 lines · Rik van Riel
Quoted 7 lines · Helge Hafting
Quoted 5 lines · Rik van Riel

1) memory is exhausted
2) the network driver can't allocate memory and
spits out a message
3) syslogd and/or klogd get killed

Quoted 6 lines
Quoted 1 line

Clearly you want to be a bit smarter about which process to kill.

Ill-implemented klogd/syslogd. Pre-allocating a little memory is one way to go, or drop messages until allocation becomes possible again. Then log a complaint about messages missing due to a temporary OOM.

Quoted 8 lines

No. This has absolutely nothing to do with it.

In this case, "allocating memory" simply means that klogd/syslogd page faults on something it already allocated, say a piece of the executable or a swapped-out buffer.

Simple page faults like this can also trigger an OOM-killing.

Not in what I had described. Unless the page fault was for a
new page (just malloc'ed) it wouldn't result in the killing of the process.

Tim

Quoted 13 lines

Rik

Signature · 11 lines
Bravely reimplemented by the knights who say "NIH".

http://www.surriel.com/		http://distro.conectiva.com/

Spamtraps of the month:  [email protected] [email protected]

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Signature · 5 lines
Timothy D. Witham - Lab Director - [email protected]
Open Source Development Lab Inc - A non-profit corporation
15275 SW Koll Parkway - Suite H - Beaverton OR, 97006
(503)-626-2455 x11 (office)    (503)-702-2871     (cell)
(503)-626-2436     (fax)
#8 lore raw
Quoted 9 lines · Timothy D. Witham
Quoted 4 lines · Rik van Riel
Quoted 4 lines
Quoted 4 lines

1) memory is exhausted
2) the network driver can't allocate memory and
spits out a message
3) syslogd and/or klogd get killed

Not in what I had described. Unless the page fault was for a new page
(just malloc'ed) it wouldn't result in the killing of the process.

Unfortunately they do. Reality doesn't quite match your description.

Rik

Signature · 5 lines
Bravely reimplemented by the knights who say "NIH".

http://www.surriel.com/		http://distro.conectiva.com/

Spamtraps of the month:  [email protected] [email protected]
#9 lore raw
Quoted 8 lines · Rik van Riel
Quoted 6 lines · Timothy D. Witham
Quoted 4 lines · Rik van Riel
Quoted 4 lines
Quoted 4 lines

1) memory is exhausted
2) the network driver can't allocate memory and
spits out a message
3) syslogd and/or klogd get killed

Quoted 6 lines
Quoted 2 lines

Not in what I had described. Unless the page fault was for a new page
(just malloc'ed) it wouldn't result in the killing of the process.

Unfortunately they do. Reality doesn't quite match your description.

I wasn't talking about the current situation I was talking about
the pre-allocation method.

Tim

Quoted 7 lines

Rik

Signature · 5 lines
Bravely reimplemented by the knights who say "NIH".

http://www.surriel.com/		http://distro.conectiva.com/

Spamtraps of the month:  [email protected] [email protected]
Signature · 5 lines
Timothy D. Witham - Lab Director - [email protected]
Open Source Development Lab Inc - A non-profit corporation
15275 SW Koll Parkway - Suite H - Beaverton OR, 97006
(503)-626-2455 x11 (office)    (503)-702-2871     (cell)
(503)-626-2436     (fax)
author
#10 lore raw
In reply to Timothy D. Witham

Actually, the "offense is not asking for memory". The issue is gracefully responding to an exhausted resource in some kind of predetermined way - memory being just one example, but the that started this thread.

Any algorithm that bases the solution on the developer's notion of "niceness" and "offense" may not solve the problem the user installation is trying to solve - gracefully shutting down work (or ungracefully if necessary) based on the installations priorities and needs rather than randomly killing. Hopefully, the system can survive past the peak that aggravating the problem or at least let someone add the resources needed. In the particular case of "out of memory", add swap spaces.

I'd rather be able to choose to lose the online cafeteria menu before I lose the emergency dispatch system. I'd much rather take action well before any of the critical system functions are sacrificed. To me, logging on by the wheel is going to fix the problem is quite high on my priority list. But with Tim's definition, he is the offended because he would be asking for memory.

I have to beg off this discussion for a week as I'll me out of country. I shall return.