lkml.org 
[lkml]   [2006]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Simple OOM kill protection interface
From
Date
On Thu, 2006-12-07 at 17:50 +0200, Menny Hamburger wrote:
> Hi,
>
> Following is a rather simple module implementation that adds an interface for protecting against the oom_killer by setting the oomkilladj in the task struct.


> There are two interfaces:
> 1) /proc interface (/proc/oom_kill_protection) that can be used inside scripts
> 2) A device that registers an ioctl, which can be issued via a calling c program.
>
> To create the device after the module is loaded do the following from a script:
> major_name=$(dmesg | grep oom_protect | grep dynamic | tail -n 1 | awk '{print $5}' | xargs)
> if [ -n "$major_name" ]; then
> mknod /dev/oom_protect c $major_name 1
> fi
> if [ ! -r /dev/oom_protect ]; then
> logger -p error "Unable to create /dev/oom_protect"
> else
> logger -p notice "Created device /dev/oom_protect"
> fi
>
> Usage via a script:
> echo "setprotection $$ 1 > /proc/oom_kill_protection/ctl"
>
> Usage via a c prog:
> #include <sys/ioctl.h>
>
> .........
>
> #define OOMSETPROTECTCMD _IOWR('O', 1, int)
>
> int oom_protection = 1, oom_protected = 1, fd;
>
> if ((fd = open("/dev/oom_protect", 0)) >= 0) {
> if (ioctl(fd, OOMSETPROTECTCMD, &oom_protection) == 0)
> oom_protected = 1;
>
> close(fd);
> }
> .....

Whatever for?
Why is writing to /proc/{<pid>,self}/oom_adj not good enough?

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-12-07 17:09    [W:0.028 / U:52.356 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site