Skip to contentSkip to conversation

oom: create a resource limit for oom_adj

PATCH Bodo Eggert 3 participants 6 messages Nov 11, 2010 – Nov 23, 2010 8 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw
Quoted 13 lines · David Rientjes
Quoted 10 lines · Mandeep Singh Baines
Quoted 3 lines

What is the anticipated use case for this? We know that you want to lower oom_adj without CAP_SYS_RESOURCE, but what's the expected behavior when an app moves from foreground to background? I assume it's something like

The focus here is the web browser's tabs. In our case, each is a process. If OOM is going to kill a process, you'd rather it kill the tab you looked at hours ago instead of the one you're looking at now. So you'd like to have a policy where the LRU tab gets killed first. We'd like to use oom_score_adj as the mechanism to implement an LRU policy like this.

Quoted 5 lines

Hmm, at first glance that seems potentially dangerous if the current tab generates a burt of memory allocations and it ends up killing all other tabs before finally targeting the culprit whereas currently the heuristic should do a good job of finding this problematic tab and killing it instantly.

The original oom_adj design would e.g. adjust all background tabs to seem twice as bad as the current tab, so a ever-growing current tab would only be able to get one or two tabs killed in the worst case:

System is near OOM while the current tab starts using a normal amount of mem and grows beyond limits. After it easily killed the first bg tab by allocating one byte, it needs to grow to twice the normal tab memsize to start the OOM killer again. By then, it's score will be equal to normal background tabs (half size, double score), and killing the second tab will be luck. Killing the third tab should be impossible.

(If you adjust the bg tabs to be four times as killable, you'll get what
you asked for.)

I don't know the current oom_score_adj, it should be able to do something similar? Or should there be a oom_score_mul?

Quoted 9 lines
Quoted 8 lines
Quoted 2 lines

What do you anticipate will be writing to oom_score_adj with this patch, the app itself?

A process in the browser session will do the adusting. We'd rather not give it CAP_SYS_RESOURCE. It should only be allowed to change oom_score_adj up and down within the bounds set by the administrator. Analagous to renice() which we also do using a similar policy.

Quoted 3 lines

So as more and more tabs get used, the least recently used tab gets its oom_score_adj raised higher and higher until it is reused itself and then it gets reset back to 0 for the current tab?

As far as I understand, a background tab should get a higher score if it rests untouched for some time, and if it gets used again, it will jump to neutral oom_adj.

Quoted 2 lines

Is there a reason you don't want to give the underlying browser session process CAP_SYS_RESOURCE?

I should not have control over a CAP_SYS_RESOURCE process while being a user, but I should be able to tell the system which process to kill. When I designed the oom_adj, I did not think about one-process-per-tab, so I did not suggest a soft/hard limit.

I think the concept of using an rlimit is the right thing to do, I did not yet look/think about the mapping. Glancing at oom_score_adj does suggest a different range ...

#5 lore raw
Quoted 11 lines · Bodo Eggert

The original oom_adj design would e.g. adjust all background tabs to seem twice as bad as the current tab, so a ever-growing current tab would only be able to get one or two tabs killed in the worst case:

System is near OOM while the current tab starts using a normal amount of mem and grows beyond limits. After it easily killed the first bg tab by allocating one byte, it needs to grow to twice the normal tab memsize to start the OOM killer again. By then, it's score will be equal to normal background tabs (half size, double score), and killing the second tab will be luck. Killing the third tab should be impossible.

Quoted 7 lines

(If you adjust the bg tabs to be four times as killable, you'll get what
you asked for.)

I don't know the current oom_score_adj, it should be able to do something similar? Or should there be a oom_score_mul?

oom_score_adj is done on a linear scale instead of exponential so instead of increasing oom_adj by 1 for each hop to the current tab, you would need to double it.

#6 lore raw
In reply to Bodo Eggert
Quoted 17 lines
Quoted 5 lines

Hmm, at first glance that seems potentially dangerous if the current tab generates a burt of memory allocations and it ends up killing all other tabs before finally targeting the culprit whereas currently the heuristic should do a good job of finding this problematic tab and killing it instantly.

The original oom_adj design would e.g. adjust all background tabs to seem twice as bad as the current tab, so a ever-growing current tab would only be able to get one or two tabs killed in the worst case:

System is near OOM while the current tab starts using a normal amount of mem and grows beyond limits. After it easily killed the first bg tab by allocating one byte, it needs to grow to twice the normal tab memsize to start the OOM killer again. By then, it's score will be equal to normal background tabs (half size, double score), and killing the second tab will be luck. Killing the third tab should be impossible.

Quoted 2 lines

(If you adjust the bg tabs to be four times as killable, you'll get what
you asked for.)

Sorry for the delay.

I've sent revert patch to linus. We DON'T want to break any userland seriously. So, we reconsider about this area. personally I hope to reintroduce oom_score_adj later, but It must don't break current userland.

#7 lore raw
Quoted 4 lines · KOSAKI Motohiro

I've sent revert patch to linus. We DON'T want to break any userland seriously. So, we reconsider about this area. personally I hope to reintroduce oom_score_adj later, but It must don't break current userland.

Nobody is going to stall their development waiting for your patches to be merged (especially when you've proposed them four times before and they haven't been), so patches in this area should be against Linus' latest tree.

#8 lore raw
Quoted 11 lines · KOSAKI Motohiro
Quoted 5 lines

I've sent revert patch to linus. We DON'T want to break any userland seriously. So, we reconsider about this area. personally I hope to reintroduce oom_score_adj later, but It must don't break current userland.

Nobody is going to stall their development waiting for your patches to be merged (especially when you've proposed them four times before and they haven't been), so patches in this area should be against Linus' latest tree.

Nobody want to accept you break userland.

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#13 lore raw

Re: [PATCH] oom: allow a non-CAP_SYS_RESOURCE proces to oom_score_adj down

Quoted 6 lines · Mandeep Singh Baines

We'd like to be able to oom_score_adj a process up/down as its enters/leaves the foreground. Currently, it is not possible to oom_adj down without CAP_SYS_RESOURCE. This patch allows a task to decrease its oom_score_adj back to the value that a CAP_SYS_RESOURCE thread set it or its inherited value at fork. Assuming the thread that has forked it has oom_score_adj of 0, each tab

process

Quoted 3 lines

could decrease it back from 0 upon
activation unless a CAP_SYS_RESOURCE thread elevated it to something higher.