OOM conditions
Tomeu Vizoso
tomeu at sugarlabs.org
Fri Nov 6 11:50:53 EST 2009
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.
>> Maybe even have the background activities have a higher
>> oom_score than the one in the foreground?
>
> Interesting. Another approach I'd love feedback on would be to set
> the allowed number of simultaneous running activities to be 2 (1 +
> Journal) and writing a simple control panel extension that would allow
> tweaking that, this oom_adj, and other related gconf values.
The downside I see to that is its complexity, maybe something simpler
would be enough?
Thanks,
Tomeu
>> Regards,
>>
>> Tomeu
>
> Martin
>
>
> 1. patch against
> http://cgit.sugarlabs.org/sugar-toolkit/mainline/tree/src/sugar/activity/main.py :
>
> diff --git a/src/sugar/activity/main.py b/src/sugar/activity/main.py
> index 93f34e6..c868e11 100644
> --- a/src/sugar/activity/main.py
> +++ b/src/sugar/activity/main.py
> @@ -31,7 +31,40 @@ from sugar.bundle.activitybundle import ActivityBundle
> from sugar import logger
>
>
> +def __oom_adj_self(omm_adj_value=None):
> + """ Change this 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/self/oom_adj"
> + 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_instance(constructor, handle):
> + __oom_adj_self()
> activity = constructor(handle)
> activity.show()
>
>
--
«Sugar Labs is anyone who participates in improving and using Sugar.
What Sugar Labs does is determined by the participants.» - David
Farning
More information about the Devel
mailing list