From owner-freebsd-current@FreeBSD.ORG Tue Nov 22 12:44:16 2011 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1E2931065675; Tue, 22 Nov 2011 12:44:16 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 8EF898FC08; Tue, 22 Nov 2011 12:44:15 +0000 (UTC) Received: from alf.home (alf.kiev.zoral.com.ua [10.1.1.177]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id pAMCiA2r031304 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Nov 2011 14:44:11 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from alf.home (kostik@localhost [127.0.0.1]) by alf.home (8.14.5/8.14.5) with ESMTP id pAMCiAUn038971; Tue, 22 Nov 2011 14:44:10 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by alf.home (8.14.5/8.14.5/Submit) id pAMCiA5R038970; Tue, 22 Nov 2011 14:44:10 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: alf.home: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 22 Nov 2011 14:44:10 +0200 From: Kostik Belousov To: arch@freebsd.org Message-ID: <20111122124410.GP50300@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="0GVCiSrLHbw8OoqI" Content-Disposition: inline User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: is@nginx.org, current@freebsd.org Subject: RLIMIT_DATA and malloc(3) use of mmap(2) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Nov 2011 12:44:16 -0000 --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--