Date: Wed, 14 Jun 2006 16:56:00 +0300 From: Konstantin Belousov <kostikbel@gmail.com> To: Bruno Haible <bruno@clisp.org> Cc: Vasil Dimov <vd@freebsd.org>, hackers@freebsd.org Subject: Re: valid VMA ranges and mincore() Message-ID: <20060614135600.GB86300@deviant.kiev.zoral.com.ua> In-Reply-To: <200606141404.08811.bruno@clisp.org> References: <200606101822.46437.bruno@clisp.org> <20060614103420.GA86300@deviant.kiev.zoral.com.ua> <200606141404.08811.bruno@clisp.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--neYutvxvOLaeuPCA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jun 14, 2006 at 02:04:08PM +0200, Bruno Haible wrote: > Hello Konstantin, >=20 > Thanks for reacting on this issue. >=20 > > Please, evaluate the patch. If it does what you need >=20 > - It doesn't change the manual page mincore.2. Yes, it was intended. Exactly because I anticipated issues you described below. > - For unmapped areas, it appears to be filling in values of -1 into > the array. This is not what Linux, Solaris, NetBSD do: They return > -1 from the system call and set errno to ENOMEM. See > Linux: http://linux.about.com/library/cmd/blcmdl2_mincore.htm > Solaris: http://docs.sun.com/app/docs/doc/816-5167/6mbb2jaib?a=3Dview > NetBSD: http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/sys/mincore.= 2?rev=3D1.19&content-type=3Dtext/plain > - Filling in values of -1 into the array will confuse existing applicatio= ns, > because -1 is all bits set, i.e. the nonexistent pages will appear to > be in-core, modified, referenced. Ok. See below. I hope that I fixed my problems with comprehension. > - 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. For instance, it happens for freshly allocated anonymous memory that has not faulted any pages still. Index: vm_mmap.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 =3D addr =3D trunc_page((vm_offset_t) uap->addr); end =3D addr + (vm_size_t)round_page(uap->len); map =3D &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); =20 /* * Address of byte vector @@ -770,8 +772,18 @@ RestartScan: timestamp =3D map->timestamp; =20 - if (!vm_map_lookup_entry(map, addr, &entry)) - entry =3D entry->next; + if (!vm_map_lookup_entry(map, first_addr, &entry)) { + vm_map_unlock_read(map); + return (ENOMEM); + } + for (current =3D entry; + (current !=3D &map->header) && (current->end < end); + current =3D current->next) { + if (current->end !=3D current->next->start) { + vm_map_unlock_read(map); + return (ENOMEM); + } + } =20 /* * Do this on a map entry basis so that if the pages are not --neYutvxvOLaeuPCA Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (FreeBSD) iD8DBQFEkBVrC3+MBN1Mb4gRAmZFAJ9l+IK963pIg2T4UOH/5HDGt3rKfACg4EBB CEwdj3EuDfmaSv5cCMpH6GA= =bnEY -----END PGP SIGNATURE----- --neYutvxvOLaeuPCA--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060614135600.GB86300>