RLIMIT_DATA and malloc(3) use of mmap(2)

看板FB_current作者時間14年前 (2011/11/22 21:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/10 (看更多)
--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--
文章代碼(AID): #1EovqEW8 (FB_current)
討論串 (同標題文章)
文章代碼(AID): #1EovqEW8 (FB_current)