[Sugar-devel] OOM conditions
Lucian Branescu
lucian.branescu at gmail.com
Sun Nov 8 07:07:58 EST 2009
Slightly off-topic, has anyone tried compcache
(http://code.google.com/p/compcache/) on an XO-1? I might if I can get
it to work.
2009/11/8 Tomeu Vizoso <tomeu at sugarlabs.org>:
> On Sat, Nov 7, 2009 at 12:06, Martin Dengler <martin at martindengler.com> wrote:
>> On Fri, Nov 06, 2009 at 04:50:53PM +0000, Tomeu Vizoso wrote:
>>> On Wed, Nov 4, 2009 at 14:16, Martin Dengler <martin at martindengler.com> wrote:
>>> > On Fri, Oct 30, 2009 at 11:22:13PM +0100, Tomeu Vizoso wrote:
>>> >> On Fri, Oct 30, 2009 at 16:58, Richard A. Smith <richard at laptop.org> wrote:
>>> >> > Working the table at the Boston book festival I was reminded how
>>> >> > painful the OOM stuff is on a gen 1. The demo machines were in
>>> >> > this state a lot as each visitor would open up a new
>>> >> > program. Basically you have to just turn the unit off and restart
>>> >> > as trying to recover is futile.
>>> >>
>>> >> What if activities had a higher oom_score? Would that protect enough
>>> >> the processes that once killed require a system restart (X, shell,
>>> >> etc)?
>>> >
>>> > See patch vs sugar-toolkit HEAD below[1] (I can backport to 0.82 if
>>> > wanted).
>>>
>>> Maybe would be better to have the shell do that? So it works for
>>> non-python activities.
>>
>> Patch inline below.
>
> Looks great, thanks a lot. Have you seen less memory-induced lockups
> on the XO-1?
>
> Regards,
>
> Tomeu
>
>>> >> Regards,
>>> >>
>>> >> Tomeu
>>> >
>>> > Martin
>>> >
>>> Thanks,
>>>
>>> Tomeu
>>
>> Martin
>>
>>
>> (untested) patch against
>> http://cgit.sugarlabs.org/sugar-toolkit/mainline/tree/src/sugar/activity/activityfactory.py
>> :
>>
>> From 4bd6fb9f7f245c2aed92d6964746627d0c96cbec Mon Sep 17 00:00:00 2001
>> From: Martin Dengler <martin at martindengler.com>
>> Date: Sat, 7 Nov 2009 10:55:16 +0000
>> Subject: [PATCH] sacrifice activities to the OOM killer first
>>
>> change the OOM-killer score of launched activities to be the maximum.
>> See discussion at http://linux-mm.org/OOM_Killer
>> ---
>> src/sugar/activity/activityfactory.py | 35 +++++++++++++++++++++++++++++++++
>> 1 files changed, 35 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/sugar/activity/activityfactory.py b/src/sugar/activity/activityfactory.py
>> index ee0fd92..5deee6e 100644
>> --- a/src/sugar/activity/activityfactory.py
>> +++ b/src/sugar/activity/activityfactory.py
>> @@ -65,6 +65,39 @@ def _close_fds():
>> pass
>>
>>
>> +def __oom_adj_pid(pid, omm_adj_value=None):
>> + """ Change a process' OOM likelihood to oom_adj_value.
>> +
>> + By default, use the value of gconf path
>> + "/desktop/sugar/performance/oom_adj_default"; if none exists, make
>> + this process most likely to be killed (oom_adj_value=15).
>> +
>> + Linux-specific. See http://linux-mm.org/OOM_Killer for details.
>> + """
>> + oom_adj_fullpath = "/proc/%s/oom_adj" % pid
>> + if os.path.exists(oom_adj_fullpath):
>> + try:
>> +
>> + # get values/defaults from gconf
>> + import gconf
>> + gconf_dir = "/desktop/sugar/performance"
>> + gconf_key = "oom_adj_default"
>> + client = gconf.client_get_default()
>> + if not client.dir_exists(gconf_dir):
>> + client.add_dir(gconf_dir, gconf.CLIENT_PRELOAD_NONE)
>> + if oom_adj_value is None:
>> + oom_adj_value = client.get_int(gconf_dir + "/" + gconf_key)
>> + if oom_adj_value is None:
>> + oom_adj_value = 15
>> + client.set_int(gconf_dir + "/" + gconf_key,
>> + oom_adj_value)
>> +
>> + file(oom_adj_fullpath).write(oom_adj_value)
>> +
>> + except:
>> + pass
>> +
>> +
>> def create_activity_id():
>> """Generate a new, unique ID for this activity"""
>> pservice = presenceservice.get_instance()
>> @@ -276,6 +309,8 @@ class ActivityCreationHandler(gobject.GObject):
>> stdout=log_file.fileno(),
>> stderr=log_file.fileno())
>>
>> + __oom_adj_pid(child.pid)
>> +
>> gobject.child_watch_add(child.pid,
>> _child_watch_cb,
>> (environment_dir, log_file))
>> --
>> 1.6.2.5
>>
>>
>
>
>
> --
> «Sugar Labs is anyone who participates in improving and using Sugar.
> What Sugar Labs does is determined by the participants.» - David
> Farning
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
More information about the Sugar-devel
mailing list