Date: Mon, 07 Oct 1996 17:07:59 +0000 From: Matt Thomas <matt@lkg.dec.com> To: hackers@freebsd.org Cc: Mikael Karpberg <karpen@ocean.campus.luth.se> Subject: Re: Optimizing bzero() Message-ID: <199610071708.RAA20621@whydos.lkg.dec.com> In-Reply-To: Your message of "Mon, 30 Sep 1996 10:33:14 %2B0200." <199609300833.KAA18915@ocean.campus.luth.se>
next in thread | previous in thread | raw e-mail | index | archive | help
> According to Poul-Henning Kamp: > > In message <199609250343.AA109333032@fakir.india.hp.com>, A JOSEPH KOSHY writes > > : > > >>>>> "phk" == "Poul-Henning Kamp" <phk@critter.tfs.com> 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 <limits.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <sys/mman.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610071708.RAA20621>