From owner-freebsd-hackers Mon Oct 7 14:17:38 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id OAA29493 for hackers-outgoing; Mon, 7 Oct 1996 14:17:38 -0700 (PDT) Received: from mail13.digital.com (mail13.digital.com [192.208.46.30]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id OAA29483 for ; Mon, 7 Oct 1996 14:17:35 -0700 (PDT) Received: from muggsy.lkg.dec.com by mail13.digital.com (5.65v3.2/1.0/WV) id AA13308; Mon, 7 Oct 1996 17:06:22 -0400 Received: from whydos.lkg.dec.com by muggsy.lkg.dec.com (5.65/DEC-Ultrix/4.3) with SMTP id AA05433; Mon, 7 Oct 1996 17:06:21 -0400 Received: from localhost.lkg.dec.com (localhost.lkg.dec.com [127.0.0.1]) by whydos.lkg.dec.com (8.6.12/8.6.12) with SMTP id RAA20621; Mon, 7 Oct 1996 17:08:00 GMT Message-Id: <199610071708.RAA20621@whydos.lkg.dec.com> X-Authentication-Warning: whydos.lkg.dec.com: Host localhost.lkg.dec.com didn't use HELO protocol X-Mailer: exmh version 1.6.5 12/11/95 To: hackers@freebsd.org Cc: Mikael Karpberg Subject: Re: Optimizing bzero() In-Reply-To: Your message of "Mon, 30 Sep 1996 10:33:14 +0200." <199609300833.KAA18915@ocean.campus.luth.se> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 07 Oct 1996 17:07:59 +0000 From: Matt Thomas Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > According to Poul-Henning Kamp: > > In message <199609250343.AA109333032@fakir.india.hp.com>, A JOSEPH KOSHY writes > > : > > >>>>> "phk" == "Poul-Henning Kamp" writes > > > > > >phk> The next thing you could start to consider is when people realloc a > > >phk> multipage allocation to something bigger, it would be nice to be able > > >phk> to ask the kernel to "move these pages to this address" and then extend > > >phk> It there instead of copying the contents. > > > > > >Makes sense; can this be done without major surgery though? How costly > > >would it be for malloc(3) to invoke a system call to re-arrange the > > >address space compared to an memory allocation followed by a bcopy()? > > cheap(er). > Can't you just make realloc do that? Is there a problem with doing it? > If not, is there a way to tell the system to rearrange your address space? I've always wanted to be able to use procfs for doing that. Alas, procfs doesn't support mmap operations. #include #include #include #include #include static int x; int main( void) { char fname[50]; int fd; caddr_t ptr; sprintf(fname, "/proc/%05d", getpid()); fd = open(fname, O_RDONLY); if (fd < 0) { perror(fname); exit(1); } errno = 0; ptr = mmap(NULL, getpagesize(), PROT_READ, MAP_FILE|MAP_SHARED, fd, ((off_t) &x) & ~getpagesize()); if (ptr == (caddr_t) -1) { perror("mmap"); exit(1); } printf("OK\n"); } -- Matt Thomas Internet: matt@3am-software.com 3am Software Foundry WWW URL: http://www.3am-software.com/bio/matt.html Westford, MA Disclaimer: I disavow all knowledge of this message