From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: Menny Hamburger <menny@exanet.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Simple OOM kill protection interface
Date: Thu, 07 Dec 2006 16:59:22 +0100 [thread overview]
Message-ID: <1165507162.32332.10.camel@twins> (raw)
In-Reply-To: <A6FDE6B975803043804A49F12F49028E0F5588@hawk.exanet-il.co.il>
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?
next prev parent reply other threads:[~2006-12-07 16:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-07 15:50 Menny Hamburger
2006-12-07 15:59 ` Peter Zijlstra [this message]
2006-12-07 17:14 ` Alan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1165507162.32332.10.camel@twins \
--to=a.p.zijlstra@chello.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=menny@exanet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®