[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: OOM-killer prevention for master kdeinit process
From:       Oswald Buddenhagen <ossi () kde ! org>
Date:       2006-08-09 18:44:49
Message-ID: 20060809184449.GA4697 () ugly ! local
[Download RAW message or body]

On Wed, Aug 09, 2006 at 03:48:07PM +0200, Lubos Lunak wrote:
> On Monday 07 August 2006 19:31, Oswald Buddenhagen wrote:
> > On Mon, Aug 07, 2006 at 11:18:29AM +0200, Lubos Lunak wrote:
> > >  Stupid OOM-killer should be probably avoided more.
> >
> > might well be. ;)
> > but the point is, that having it in a separate binary doesn't exactly
> > buy us a particular lot, unless it simplifies the surrounding logic.
> 
>  It avoids C++ ctors from libraries, for those who want to be really paranoid.
> 
i can buy into that. :)

> > btw, i think your reset_oom_protect() implementation has a race
> > condition: the write may have been already read and the process
> > SIGCONT-ed before you even SIGSTOP yourself. you should use sigprocmask
> > and sigsuspend or something.
> 
>  Hmm, yes, although it should be very unlikely.
>
actually, i'm surprised it didn't happen all the time: the other process
is already waiting for the data, so it should be scheduled as soon as
something is written (to reduce the latency of chatting processes). but
i guess the scheduler is somewhat more complicated than that.

> Added a somewhat non-elegant solution.
> 
indeed. you are risking a ~1:1e11 chance of waiting a second for no
reason. :)
not that it would matter for this application, but somebody might copy
the code and have a bad surprise, so better do it right:
- sigaction sigX on an empty handler function
- block sigX, save old sigmask
- write
- sigsuspend with empty sigmask
- restore old sigmask

> > fwiw, kill(getpid(), SIG) should be raise(SIG).
> 
>  Which does exactly that :).
> 
obviously. but every byte to read counts. :)

fwiw, by committing this you accept that a regular user can escape
oom-killing to a certain degree for arbitrary applications (all that are
launched by kdeinit) - i'm not sure how big the impact of -5 is, but i
can imagine that's not something you *really* want in a multi-user
environment.

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic