Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Nov 2011 14:44:10 +0200
From:      Kostik Belousov <kostikbel@gmail.com>
To:        arch@freebsd.org
Cc:        is@nginx.org, current@freebsd.org
Subject:   RLIMIT_DATA and malloc(3) use of mmap(2)
Message-ID:  <20111122124410.GP50300@deviant.kiev.zoral.com.ua>

next in thread | raw e-mail | index | archive | help

--0GVCiSrLHbw8OoqI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

I was reminded about the patch I wrote for Igor Sysoev some time ago.
The issue the patch tries to handle is that jemalloc uses mmap() instead
of sbrk() for pages allocation, and thus RLIMIT_DATA limit is no longer
effective to put the bounds on the process heap. Since reverting to sbrk
for such purpose is worse then the issue itself, I proposed a solution
of 'self-restricting malloc'.

The patch adds a flag MAP_DATALIMIT to the flags argument of mmap(2),
which instructs the system to account the mapping in the RLIMIT_DATA
resource count. The malloc(3) also gets new option 'L' to enable
passing MAP_DATALIMIT to mmap() when allocating pages. By default,
the 'L' option is not activated.

Now, if user wants to ensure that process heap is restricted by the
ulimit -d and still use mmap() for jemalloc, he supplies the option
using any mechanism. The behaviour is voluntaristic, to prevent the
trashing use RLIMIT_SWAP.

Do people consider the facility useful ? Any comments for the patch itself ?

http://people.freebsd.org/~kib/misc/map_datalimit.1.patch


--0GVCiSrLHbw8OoqI
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (FreeBSD)

iEYEARECAAYFAk7LmRoACgkQC3+MBN1Mb4gr7gCeM4pLMS2vJRO9MN2TLcsBEpjK
BbAAn26eANd2C7HD4MnpBNthTjnvfhbx
=FksP
-----END PGP SIGNATURE-----

--0GVCiSrLHbw8OoqI--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111122124410.GP50300>