oom: remove totalpage normalization from oom_badness()
Subsystems (5)
PATCH RESEND 1/2 oom: remove totalpage normalization from oom_badness()
ok, this one got no objection except original patch author. then, I'll push it to mainline. I'm glad that I who stabilization developer have finished this work.
If you think this patch is slightly large, please run,
% git diff a63d83f42^ mm/oom_kill.c
you'll understand this is minimal revert of unnecessary change.
Thanks.
===================================================================
From 938ce3a7aa79ae4a6cbc275259d586086c41eb87 Mon Sep 17 00:00:00 2001
From: KOSAKI Motohiro <[email protected]>
Date: Fri, 27 Aug 2010 15:24:09 +0900
Subject: [PATCH 1/2] oom: remove totalpage normalization from oom_badness()
Current oom_score_adj is completely broken because It is strongly bound google usecase and ignore other all.
1) Priority inversion
As kamezawa-san pointed out, This break cgroup and lxr environment. He said,
> Assume 2 proceses A, B which has oom_score_adj of 300 and 0 > And A uses 200M, B uses 1G of memory under 4G system > > Under the system. > A's socre = (200M *1000)/4G + 300 = 350 > B's score = (1G * 1000)/4G = 250. > > In the cpuset, it has 2G of memory. > A's score = (200M * 1000)/2G + 300 = 400 > B's socre = (1G * 1000)/2G = 500 > > This priority-inversion don't happen in current system.
2) Ratio base point don't works large machine oom_score_adj normalize oom-score to 0-1000 range. but if the machine has 1TB memory, 1 point (i.e. 0.1%) mean 1GB. this is no suitable for tuning parameter.
As I said, proposional value oriented tuning parameter has scalability risk.
3) No reason to implement ABI breakage.
old tuning parameter mean)
oom-score = oom-base-score x 2^oom_adj
new tuning parameter mean)
oom-score = oom-base-score + oom_score_adj / (totalram + totalswap)
but "oom_score_adj / (totalram + totalswap)" can be calculated in userland too. beucase both totalram and totalswap has been exporsed by /proc. So no reason to introduce funny new equation.
4) totalram based normalization assume flat memory model. example, the machine is assymmetric numa. fat node memory and thin node memory might have another wight value.
In other word, totalram based priority is a one of policy. Fixed and workload depended policy shouldn't be embedded in kernel. probably.
Then, this patch remove *UGLY* total_pages suck completely. Googler can calculate it at userland!
--- fs/proc/base.c | 33 ++--------- include/linux/oom.h | 16 +----- include/linux/sched.h | 2 +- mm/oom_kill.c | 144 ++++++++++++++++++++----------------------------- 4 files changed, 68 insertions(+), 127 deletions(-)
fs/proc/base.c +6 -27
@@ -434,8 +434,7 @@ static int proc_oom_score(struct task_struct *task, char *buffer)read_lock (&tasklist_lock);if (pid_alive (task)) - points =oom_badness (task,NULL ,NULL , - totalram_pages + total_swap_pages); + points =oom_badness (task,NULL ,NULL );read_unlock (&tasklist_lock);return sprintf (buffer,"%lu\n" , points); }
@@ -1056,15 +1055,7 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf, current->comm,task_pid_nr (current), task_pid_nr(task), task_pid_nr(task)); task->signal->oom_adj = oom_adjust; -/* -* Scale /proc/pid/oom_score_adj appropriately ensuring that a maximum -* value is always attainable. -*/ -if (task->signal->oom_adj ==OOM_ADJUST_MAX ) - task->signal->oom_score_adj =OOM_SCORE_ADJ_MAX ; -else - task->signal->oom_score_adj = (oom_adjust *OOM_SCORE_ADJ_MAX ) / - -OOM_DISABLE ; +unlock_task_sighand (task, &flags);put_task_struct (task);
@@ -1081,8 +1072,8 @@ static ssize_t oom_score_adj_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode); -char buffer[PROC_NUMBUF ]; -int oom_score_adj =OOM_SCORE_ADJ_MIN ; +char buffer[21 ]; +long oom_score_adj =0 ;unsigned long flags;size_t len;
@@ -1093,7 +1084,7 @@ static ssize_t oom_score_adj_read(struct file *file, char __user *buf,unlock_task_sighand (task, &flags); }put_task_struct (task); - len =snprintf (buffer,sizeof (buffer),"%d\n" , oom_score_adj); + len =snprintf (buffer,sizeof (buffer),"%ld\n" , oom_score_adj);return simple_read_from_buffer (buf, count, ppos, buffer, len); }
@@ -1101,7 +1092,7 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct task_struct *task; -char buffer[PROC_NUMBUF ]; +char buffer[21 ];unsigned long flags;long oom_score_adj;int err;
@@ -1115,9 +1106,6 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf, err =strict_strtol (strstrip (buffer),0 , &oom_score_adj);if (err)return -EINVAL ; -if (oom_score_adj <OOM_SCORE_ADJ_MIN || - oom_score_adj >OOM_SCORE_ADJ_MAX ) -return -EINVAL ; task =get_proc_task (file->f_path.dentry->d_inode);if (!task)
@@ -1134,15 +1122,6 @@ static ssize_t oom_score_adj_write(struct file *file, const char __user *buf, } task->signal->oom_score_adj = oom_score_adj; -/* -* Scale /proc/pid/oom_adj appropriately ensuring that OOM_DISABLE is -* always attainable. -*/ -if (task->signal->oom_score_adj ==OOM_SCORE_ADJ_MIN ) - task->signal->oom_adj =OOM_DISABLE ; -else - task->signal->oom_adj = (oom_score_adj *OOM_ADJUST_MAX ) / -OOM_SCORE_ADJ_MAX ;unlock_task_sighand (task, &flags);put_task_struct (task);return count;
include/linux/oom.h +3 -13
@@ -12,13 +12,6 @@#define OOM_ADJUST_MIN (-16)#define OOM_ADJUST_MAX 15 -/* -* /proc/<pid>/oom_score_adj set to OOM_SCORE_ADJ_MIN disables oom killing for -* pid. -*/ -#define OOM_SCORE_ADJ_MIN (-1000) -#define OOM_SCORE_ADJ_MAX 1000 -#ifdef __KERNEL__#include <linux/sched.h>
@@ -40,8 +33,9 @@ enum oom_constraint { CONSTRAINT_MEMCG, }; -extern unsigned int oom_badness (struct task_struct *p,struct mem_cgroup *mem, -const nodemask_t *nodemask,unsigned long totalpages); +/* The badness from the OOM killer */ +extern unsigned long oom_badness (struct task_struct *p,struct mem_cgroup *mem, +const nodemask_t *nodemask);extern int try_set_zonelist_oom (struct zonelist *zonelist,gfp_t gfp_flags);extern void clear_zonelist_oom (struct zonelist *zonelist,gfp_t gfp_flags);
@@ -62,10 +56,6 @@ static inline void oom_killer_enable(void) oom_killer_disabled = false; } -/* The badness from the OOM killer */ -extern unsigned long badness (struct task_struct *p,struct mem_cgroup *mem, -const nodemask_t *nodemask,unsigned long uptime); -extern struct task_struct *find_lock_task_mm (struct task_struct *p);/* sysctls */
include/linux/sched.h +1 -1
@@ -622,7 +622,7 @@ struct signal_struct {#endif int oom_adj;/* OOM kill score adjustment (bit shift) */ -int oom_score_adj;/* OOM kill score adjustment */ +long oom_score_adj;/* OOM kill score adjustment */ };/* Context switch must be unlocked if interrupts are to be enabled */
mm/oom_kill.c +58 -86
312 lines not on this page · raw message
Signature · 9 lines
1.6.5.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH RESEND 2/2 Revert "oom: deprecate oom_adj tunable"
oom_adj is not only used for kernel knob, but also used for application interface.
Then, adding new knob is no good reason to deprecate it.
Also, after former patch, oom_score_adj can't be used for setting OOM_DISABLE. We need "echo -17 > /proc/<pid>/oom_adj" thing.
This reverts commit 51b1bd2ace1595b72956224deda349efa880b693.
--- Documentation/feature-removal-schedule.txt | 25 ------------------------- Documentation/filesystems/proc.txt | 3 --- fs/proc/base.c | 8 -------- include/linux/oom.h | 3 --- 4 files changed, 0 insertions(+), 39 deletions(-)
Documentation/feature-removal-schedule.txt +0 -25
@@ -151,31 +151,6 @@ Who: Eric Biederman <[email protected]> --------------------------- -What: /proc/<pid>/oom_adj -When: August 2012 -Why: /proc/<pid>/oom_adj allows userspace to influence the oom killer's - badness heuristic used to determine which task to kill when the kernel - is out of memory. - - The badness heuristic has since been rewritten since the introduction of - this tunable such that its meaning is deprecated. The value was - implemented as a bitshift on a score generated by the badness() - function that did not have any precise units of measure. With the - rewrite, the score is given as a proportion of available memory to the - task allocating pages, so using a bitshift which grows the score - exponentially is, thus, impossible to tune with fine granularity. - - A much more powerful interface, /proc/<pid>/oom_score_adj, was - introduced with the oom killer rewrite that allows users to increase or - decrease the badness() score linearly. This interface will replace - /proc/<pid>/oom_adj. - - A warning will be emitted to the kernel log if an application uses this - deprecated interface. After it is printed once, future warnings will be - suppressed until the kernel is rebooted. - ---------------------------- - What: remove EXPORT_SYMBOL(kernel_thread) When: August 2006 Files: arch/*/kernel/*_ksyms.c
Documentation/filesystems/proc.txt +0 -3
@@ -1285,9 +1285,6 @@ scaled linearly with /proc/<pid>/oom_score_adj. Writing to /proc/<pid>/oom_score_adj or /proc/<pid>/oom_adj will change the other with its scaled value. -NOTICE: /proc/<pid>/oom_adj is deprecated and will be removed, please see -Documentation/feature-removal-schedule.txt. - Caveat: when a parent task is selected, the oom killer will sacrifice any first generation children with seperate address spaces instead, if possible. This avoids servers and important system daemons from being killed and loses the
fs/proc/base.c +0 -8
@@ -1046,14 +1046,6 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,return -EACCES ; } -/* -* Warn that /proc/pid/oom_adj is deprecated, see -* Documentation/feature-removal-schedule.txt. -*/ -printk_once (KERN_WARNING "%s (%d): /proc/%d/oom_adj is deprecated, " -"please use /proc/%d/oom_score_adj instead.\n" , - current->comm,task_pid_nr (current), -task_pid_nr (task),task_pid_nr (task)); task->signal->oom_adj = oom_adjust;unlock_task_sighand (task, &flags);
include/linux/oom.h +0 -3
@@ -2,9 +2,6 @@#define __INCLUDE_LINUX_OOM_H/* -* /proc/<pid>/oom_adj is deprecated, see -* Documentation/feature-removal-schedule.txt. -* * /proc/<pid>/oom_adj set to -17 protects from the oom-killer */ #define OOM_DISABLE (-17)
Signature · 9 lines
1.6.5.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
David Rientjes
reviewerQuoted 1 line · KOSAKI Motohiro
ok, this one got no objection except original patch author.
Would you care to respond to my objections?
I replied to these two patches earlier with my nack, here they are:
http://marc.info/?l=linux-mm&m=128273555323993 http://marc.info/?l=linux-mm&m=128337879310476
Please carry on a useful debate of the issues rather than continually resending patches and labeling them as bugfixes, which they aren't.
Quoted 3 lines
then, I'll push it to mainline. I'm glad that I who stabilization developer have finished this work.
You're not the maintainer of this code, patches go through Andrew.
That said, I'm really tired of you trying to make this personal with me; I've been very respectful and accomodating during this discussion and I hope that you will be the same.
Thanks.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 6 lines · KOSAKI Motohiro
Quoted 2 lines
ok, this one got no objection except original patch author.
Would you care to respond to my objections?
Quoted 7 lines
I replied to these two patches earlier with my nack, here they are:
http://marc.info/?l=linux-mm&m=128273555323993 http://marc.info/?l=linux-mm&m=128337879310476Please carry on a useful debate of the issues rather than continually resending patches and labeling them as bugfixes, which they aren't.
You are still talking about only your usecase. Why do we care you? Why? Why don't you fix the code by yourself? Why? Why do you continue selfish development? Why? I can't understand.
Quoted 9 lines
Quoted 3 lines
then, I'll push it to mainline. I'm glad that I who stabilization developer have finished this work.
You're not the maintainer of this code, patches go through Andrew.
That said, I'm really tired of you trying to make this personal with me; I've been very respectful and accomodating during this discussion and I hope that you will be the same.
As I said, You only need to don't break userland and fix the code immediately. You don't have to expect stabilization developer allow userland and code breakage.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
David Rientjes
reviewerQuoted 6 lines · KOSAKI Motohiro
Quoted 6 lines
Quoted 1 line
ok, this one got no objection except original patch author.
Would you care to respond to my objections?
I replied to these two patches earlier with my nack, here they are:
Quoted 7 lines
Quoted 5 lines
http://marc.info/?l=linux-mm&m=128273555323993 http://marc.info/?l=linux-mm&m=128337879310476Please carry on a useful debate of the issues rather than continually resending patches and labeling them as bugfixes, which they aren't.
You are still talking about only your usecase. Why do we care you? Why?
It's an example of how the new interface may be used to represent oom killing priorities for an aggregate of tasks competing for the same set of resources.
Quoted 3 lines
Why don't you fix the code by yourself? Why? Why do you continue selfish development? Why? I can't understand.
I can only reiterate what I've said before (and you can be assured I'll only keep it technical and professional even though you've always made this personal with me): current users of /proc/pid/oom_adj only polarize a task to either disable oom killing (-17 or -16), or always prefer a task (+15). Very, very few users tune it to anything in between, and when it's done, it's relative to other oom_adj values.
A single example of a /proc/pid/oom_adj usecase has not been presented that shows anybody using it as a function of either an application's expected memory usage or of the system capacity. Those two variables are important for oom_adj to make any sense since its old definition was basically oom_adj = mm->total_vm << oom_adj for positive oom_adj and oom_adj = mm->total_vm >> oom_adj for negative oom_adj. If an application, system daemon, or job scheduler does not tune it without consideration to the amount of expected RAM usage or system RAM capacity, it doesn't make any sense. You're welcome to present such a user at this time.
That said, I felt it was possible to use the current usecase for /proc/pid/oom_adj to expand upon its applicability by introducing /proc/pid/oom_score_adj with a much higher resolution and ability to stay static based on the relative importance of a task compared to others sharing the same resources in a dynamic environment (memcg limits changing, cpuset mems added, mempolicy nodes changing, etc).
Thus, my introduction of oom_score_adj causes no regression for real-world users of /proc/pid/oom_adj and allows users of cgroups and mempolicies a much more powerful interface to tune oom killing priority.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
David Rientjes
reviewerQuoted 4 lines · David Rientjes
Thus, my introduction of
oom_score_adjcauses no regression for real-world users of/proc/pid/oom_adjand allows users of cgroups and mempolicies a much more powerful interface to tune oom killing priority.
I want to elaborate on this point just a little more because I feel that Andrew is in the unpleasant position of trying to judge whether the introduction of this feature actually has a negative side-effect for current users of oom_adj, and I want to stress that it doesn't.
The problem being reported here is that current users of oom_adj will now experience altered semantics of the value if it doesn't lie at the absolute extremes such as +15 or -16. The prior implementation would, in its simpliest form, do this:
badness_score = task->mm->total_vm << oom_adj
for a positive oom_adj and this:
badness_score = task->mm->total_vm >> -oom_adj
for a negative oom_adj. That implementation would require that the task setting oom_adj would know the expected RAM usage of the task at the time of oom and the system capacity. Otherwise, it would be impossible to judge an approriate value for the bitshift if we didn't know the total VM size of task and how the score would rank in comparison to other tasks.
The comparison is important because we use these scores as an indicator of the "memory hogging" task to kill and we know that the system is oom so the remainder of system RAM that this application is not using may be consumed by another that we would therefore want to select instead.
It's my contention that nobody is currently using oom_adj in that way, and if they are, they are more deserving of a finer-grained utility that doesn't operate exponentially on the VM size, which leaves much to be desired. oom_score_adj, for these users that aren't using cpusets or memcg or mempolicies, allows for the same static value that scales linearly as opposed to exponentially.
Current users of oom_adj do one of two things:
- polarize the value such that a task is always preferred (+15) or always protected (-16) [or, completely disabled, -17], or
- set up very rough approximations of oom killing priority such as one task at +10 and another at +5.
The latter is certainly in the very, very minority and have arbitrary values to imply that the former task should be selected over the latter iff the latter has exploded in memory use such that it's using much more than expected and probably leaking memory.
My contention that we are safe in proceeding with what is currently in 2.6.36-rc3 is based on the assumption that all users currently use oom_adj in one of the two ways enumerated above. If that assumption isn't accepted, then I believe the revert criteria is to show a user, any user, of oom_adj that considers both expected memory usage and system capacity of the application it is tuning the value for and does so in comparison to other tasks on the system. Unless that can be shown, I do not believe the revert criteria has been met in this case.
Furthermore, the characterization of the above as being a "bug" that affects endusers is inaccurate. The vast majority of Linux users do not use cpusets, memcg, mempolicies, or memory hotplug. For those users, the proportional scores that are used by oom_score_adj stay static since the system capacity remains static. They will find that oom_score_adj is exceptionally more powerful for the users that this is being inaccurately described as imposing a regression for: if they are tuning oom_adj based on the specific memory usage of their applications and the system capacity, they may now do so with a rough linear approximation via oom_adj as they always did or use oom_score_adj with a _much_ higher resolution (1/1000th of RAM) that scales linearly and not exponentially.
For the users of cpusets or memcg, existing users of oom_adj will see a rough approximation of the priority (and always an exact equivalent in the high-probability case where they are polarizing the task with +15 or -17) while using the old interface. The badness score _will_ change if the set of cpuset mems or the memcg limit changes, which is new behavior. This is the exact equivalent according to the oom killer as if we were using memory hotplug on a system and hot-adding memory or hot-removing memory:
badness scores that have a certain value may no longer have the same kill priority because we're using more or less memory. Considering the unconstrained, system-wide oom case: if we hot-added memory and are now oom and the memory usage of a task hasn't changed, it may no longer be the first task to be killed anymore because another task's usage may now cause its badness score to exceed the former. Likewise, if we hot-removed memory and are now oom and the memory usage of a task hasn't changed, it may now be selected first because all other task's usage may now be less than ours.
That's the exact same behavior as oom_score_adj when constrained to a cpuset or memcg. See either of them as a virtualized system with a set of resources and an aggregate of tasks competing for those resources. Priorities will change as memory is allowed or restricted, just like we always have had with memory hotplug, but we now allow users to define the proportion of that working set they are allowed instead of a static value. Static oom_adj scores never work appropriately in a dynamic environment because we don't know the capacity when we set the value (remember the two prerequisites to use oom_adj: expected RAM usage of the application, and memory capacity available to it).
For the users of mempolicies, the entire oom killer rewrite has changed how those ooms are handled: prior to the rewrite, the oom killer would simply kill current. Now, the tasklist is iterated if the oom_kill_allocating_task sysctl is not selected and the badness scores are used to select a task. The prior behavior of oom_adj in these oom contexts are therefore unrelated to this discussion.
This explains the power and necessity of oom_score_adj for users who use cpusets, memcg, or mempolicies. Those environments are dynamic and we _can't_ expect oom_adj to be written anytime a task changes cgroups or a cpuset mem is added, a memcg limit is reduced, or a node is added to a mempolicy. We _can_ expect the admin to know the priority of killing jobs relative to others competing for the same set of now fully depleted memory if they are using the tunable.
Given the above, it's not possible to meet the revert criteria. The real question to be asking in this case is not whether we need to revert oom_score_adj, but rather whether we need dual interfaces to exist:oom_adj and oom_score_adj. I believe that we should only have a single interface available in the kernel, and since oom_score_adj is much more powerful than oom_adj, acts on a higher resolution, respects the dynamic nature of cgroups, provides a rough approximation to users of oom_adj, and an exact equivalent of polarizing users of oom_adj, that it should exist and oom_adj should be deprecated.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 7 lines
ok, this one got no objection except original patch author. then, I'll push it to mainline. I'm glad that I who stabilization developer have finished this work.
If you think this patch is slightly large, please run,
% git diff a63d83f42^mm/oom_kill.c
you'll understand this is minimal revert of unnecessary change.
Andrew, please don't be lazy this one. I don't hope to slip this anymore. I was making the patch as you requested. but no responce. I who stabilization developr can't permit this userland breakage and sucky status. please join to fix it. Sadly, The delay will be increase, I have to switch full revert entirely instead your opinion.
Spell out: I don't hope to continus this crazy discussion. a userland breakage bug is a bug, not anything else. I don't hope to talk this one anymore even though it's only 5 miniture. I don't think any rare usecase feature should die. but ZERO USER FEATURE SHOULDN'T BREAK USERLAND.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>