Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Aug 2012 10:48:27 -0500
From:      Alan Cox <alan.l.cox@gmail.com>
To:        Luigi Rizzo <rizzo@iet.unipi.it>
Cc:        current@freebsd.org
Subject:   Re: less aggressive contigmalloc ?
Message-ID:  <CAJUyCcPOte19TJXpCVAskhf%2BDia_Zg5uj6J_idW67rGsOLaZXw@mail.gmail.com>
In-Reply-To: <20120822120105.GA63763@onelab2.iet.unipi.it>
References:  <20120822120105.GA63763@onelab2.iet.unipi.it>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Aug 22, 2012 at 7:01 AM, Luigi Rizzo <rizzo@iet.unipi.it> wrote:

> I am trying to make netmap adapt the amount of memory it allocates
> to what is available. At its core, it uses contigmalloc() with
> small chunks (even down to 1 page) to fetch memory.
>
> Problem is, i notice that before failing, contigmalloc()
> tries to swap out some processes (effectively killing them
> because i have no swap configured in my picobsd image).
> This happens with both M_WAITOK and M_NOWAIT, the difference
> is only in the number of retries it does -- see e.g.
>
>         sys/vm/vm_kern.c :: kmem_alloc_contig()
>
> where it retries once for M_NOWAIT and 3 times for M_WAITOK.
>
> I wonder if there is a way to make contigmalloc less aggressive
> and fail without killing those innocent processes ?
>
>
Have you actually observed processes being killed with M_NOWAIT?

The difference between M_NOWAIT and M_WAITOK is more than just the number
of retries.  Each successive iteration is more aggressive in its attempt to
recover pages.  On the first iteration, no pages should be written to
swap.  Nothing should happen that could result in process termination.

Alan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJUyCcPOte19TJXpCVAskhf%2BDia_Zg5uj6J_idW67rGsOLaZXw>