Date: Wed, 14 Jun 2006 16:13:53 +0200 From: Bruno Haible <bruno@clisp.org> To: Konstantin Belousov <kostikbel@gmail.com> Cc: Vasil Dimov <vd@freebsd.org>, hackers@freebsd.org Subject: Re: valid VMA ranges and mincore() Message-ID: <200606141613.54027.bruno@clisp.org> In-Reply-To: <20060614135600.GB86300@deviant.kiev.zoral.com.ua> References: <200606101822.46437.bruno@clisp.org> <200606141404.08811.bruno@clisp.org> <20060614135600.GB86300@deviant.kiev.zoral.com.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
Hello Konstantin, > > - Filling in values of -1 into the array could be done more easily by > > changing the statements in sys/vm/vm_mmap.c lines 861 and 902. > I do not agree. It zeroes array not only for holes, but also for (some) > skipped vm areas. ok, you understand the code better than I do :-) > Index: vm_mmap.c > =================================================================== > RCS file: /usr/local/arch/ncvs/src/sys/vm/vm_mmap.c,v > retrieving revision 1.205 > diff -u -r1.205 vm_mmap.c > --- vm_mmap.c 21 Apr 2006 07:17:25 -0000 1.205 > +++ vm_mmap.c 14 Jun 2006 13:51:20 -0000 > @@ -756,8 +756,10 @@ > first_addr = addr = trunc_page((vm_offset_t) uap->addr); > end = addr + (vm_size_t)round_page(uap->len); > map = &td->td_proc->p_vmspace->vm_map; > - if (end > vm_map_max(map) || end < addr) > + if (end < addr) > return (EINVAL); > + if (end > vm_map_max(map)) > + return (ENOMEM); > > /* > * Address of byte vector > @@ -770,8 +772,18 @@ > RestartScan: > timestamp = map->timestamp; > > - if (!vm_map_lookup_entry(map, addr, &entry)) > - entry = entry->next; > + if (!vm_map_lookup_entry(map, first_addr, &entry)) { > + vm_map_unlock_read(map); > + return (ENOMEM); > + } > + for (current = entry; > + (current != &map->header) && (current->end < end); > + current = current->next) { > + if (current->end != current->next->start) { > + vm_map_unlock_read(map); > + return (ENOMEM); > + } > + } > > /* > * Do this on a map entry basis so that if the pages are not > Looks good to me: This does what Linux, NetBSD, Solaris do. Thanks! Bruno
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606141613.54027.bruno>