From owner-svn-src-head@freebsd.org Thu Jan 21 18:17:21 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 334FCA8C84A; Thu, 21 Jan 2016 18:17:21 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DD1AA13C1; Thu, 21 Jan 2016 18:17:20 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u0LIHJO6029844; Thu, 21 Jan 2016 18:17:19 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u0LIHJ7a029843; Thu, 21 Jan 2016 18:17:19 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201601211817.u0LIHJ7a029843@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Thu, 21 Jan 2016 18:17:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r294523 - head/lib/libc/gmon X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jan 2016 18:17:21 -0000 Author: brooks Date: Thu Jan 21 18:17:19 2016 New Revision: 294523 URL: https://svnweb.freebsd.org/changeset/base/294523 Log: Replace the last non-optional use of sbrk() in the tree with mmap(). All gmon want's is a region of memory without the overhead of malloc(). Just mapping some pages with mmap is an easy way to accomplish this. Approved by: jhb, cem, emaste Obtained from: CheriBSD (bf33e1e70b368ababde74aa3ac70d108c8a52c69) Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D5005 Modified: head/lib/libc/gmon/gmon.c Modified: head/lib/libc/gmon/gmon.c ============================================================================== --- head/lib/libc/gmon/gmon.c Thu Jan 21 18:02:31 2016 (r294522) +++ head/lib/libc/gmon/gmon.c Thu Jan 21 18:17:19 2016 (r294523) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -50,14 +51,6 @@ __FBSDID("$FreeBSD$"); #include "libc_private.h" -#if defined(__i386__) || defined(__sparc64__) || defined(__amd64__) || (defined(__powerpc__) && !defined(__powerpc64__)) -extern char *minbrk __asm (".minbrk"); -#elif defined(__powerpc64__) -extern char *minbrk __asm ("_minbrk"); -#else -extern char *minbrk __asm ("minbrk"); -#endif - struct gmonparam _gmonparam = { GMON_PROF_OFF }; static int s_scale; @@ -94,8 +87,9 @@ monstartup(u_long lowpc, u_long highpc) p->tolimit = MAXARCS; p->tossize = p->tolimit * sizeof(struct tostruct); - cp = sbrk(p->kcountsize + p->fromssize + p->tossize); - if (cp == (char *)-1) { + cp = mmap(NULL, p->kcountsize + p->fromssize + p->tossize, + PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); + if (cp == MAP_FAILED) { ERR("monstartup: out of memory\n"); return; } @@ -108,7 +102,6 @@ monstartup(u_long lowpc, u_long highpc) cp += p->kcountsize; p->froms = (u_short *)cp; - minbrk = sbrk(0); p->tos[0].link = 0; o = p->highpc - p->lowpc;