]> err.no Git - systemd/commitdiff
Add support for oom_score_adj
authorLuca Tettamanti <kronos.it@gmail.com>
Mon, 23 Aug 2010 12:35:37 +0000 (14:35 +0200)
committerMartin Pitt <martin.pitt@ubuntu.com>
Wed, 25 Aug 2010 14:50:30 +0000 (16:50 +0200)
/proc/<pid>/oom_adj has been deprecated (kernel v2.6.36) due to the
rework of the badness heuristic; oom_score_adj is the replacement.
Keep a fallback to the old interface for compatibility with older
kernels.

See http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=a63d83f427fbce97a6cea0db2e64b0eb8435cd10

Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
udev/udevd.c

index 374a4e0bc829b4c6f7786807d700956a559b5af2..0ec3c3d4ec8e87f64906ace8763e837fcc1a57c3 100644 (file)
@@ -1285,12 +1285,19 @@ int main(int argc, char *argv[])
                fclose(f);
        }
 
-       /* OOM_DISABLE == -17 */
-       fd = open("/proc/self/oom_adj", O_RDWR);
+       fd = open("/proc/self/oom_score_adj", O_RDWR);
        if (fd < 0) {
-               err(udev, "error disabling OOM: %m\n");
+               /* Fallback to old interface */
+               fd = open("/proc/self/oom_adj", O_RDWR);
+               if (fd < 0) {
+                       err(udev, "error disabling OOM: %m\n");
+               } else {
+                       /* OOM_DISABLE == -17 */
+                       write(fd, "-17", 3);
+                       close(fd);
+               }
        } else {
-               write(fd, "-17", 3);
+               write(fd, "-1000", 5);
                close(fd);
        }