From owner-svn-src-head@FreeBSD.ORG Mon Dec 8 13:01:51 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8FCFC106567E; Mon, 8 Dec 2008 13:01:51 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id 1EA948FC08; Mon, 8 Dec 2008 13:01:51 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63 (FreeBSD)) (envelope-from ) id 1L9fkD-000GPI-F8; Mon, 08 Dec 2008 15:01:49 +0200 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id mB8D1i5X035235 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 8 Dec 2008 15:01:45 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3) with ESMTP id mB8D1iWl067053; Mon, 8 Dec 2008 15:01:44 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id mB8D1iOU067052; Mon, 8 Dec 2008 15:01:44 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 8 Dec 2008 15:01:44 +0200 From: Kostik Belousov To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Message-ID: <20081208130144.GU2038@deviant.kiev.zoral.com.ua> References: <200812081234.mB8CYqr0060148@svn.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="w5nY8nmEklXMR7Cj" Content-Disposition: inline In-Reply-To: <200812081234.mB8CYqr0060148@svn.freebsd.org> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.93.3, clamav-milter version 0.93.3 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua X-Virus-Scanned: mail.terabit.net.ua 1L9fkD-000GPI-F8 e96cf10ae2a472d33bda9789f4a9430d X-Terabit: YES Cc: rdivacky@freebsd.org Subject: Re: svn commit: r185765 - in head/sys: compat/linprocfs fs/procfs X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Mon, 08 Dec 2008 13:01:51 -0000 --w5nY8nmEklXMR7Cj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 08, 2008 at 12:34:52PM +0000, Konstantin Belousov wrote: > Author: kib > Date: Mon Dec 8 12:34:52 2008 > New Revision: 185765 > URL: http://svn.freebsd.org/changeset/base/185765 >=20 > Log: > Change the linprocfs /maps and procfs /map handlers to use > sbuf instead of doing uiomove. This allows for reads from non-zero > offsets to work. > =20 > Patch is forward-ported des@' one, and was adopted to current code > by dchagin@ and me. > =20 > Reviewed by: des (linprocfs part) > PR: kern/101453 > MFC after: 1 week >=20 > Modified: > head/sys/compat/linprocfs/linprocfs.c > head/sys/fs/procfs/procfs_map.c Thanks for Roman Divacky for pointing this out, commit message is wrong. I specified wrong log file to the svn ci -F switch. The right commit message is below. In procfs map handler, and in linprocfs maps handler, do not call vn_fullpath() while having vm map locked. This is done in anticipation of the vop_vptocnp commit, that would make vn_fullpath sometime acquire vnode lock. Also, in linprocfs, maps handler already acquires vnode lock. No objections from: des MFC after: 2 week >=20 > Modified: head/sys/compat/linprocfs/linprocfs.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=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/compat/linprocfs/linprocfs.c Mon Dec 8 12:29:30 2008 (r1857= 64) > +++ head/sys/compat/linprocfs/linprocfs.c Mon Dec 8 12:34:52 2008 (r1857= 65) > @@ -876,10 +876,12 @@ static int > linprocfs_doprocmaps(PFS_FILL_ARGS) > { > vm_map_t map =3D &p->p_vmspace->vm_map; > - vm_map_entry_t entry; > + vm_map_entry_t entry, tmp_entry; > vm_object_t obj, tobj, lobj; > - vm_offset_t saved_end; > + vm_offset_t e_start, e_end; > vm_ooffset_t off =3D 0; > + vm_prot_t e_prot; > + unsigned int last_timestamp; > char *name =3D "", *freename =3D NULL; > ino_t ino; > int ref_count, shadow_count, flags; > @@ -905,7 +907,9 @@ linprocfs_doprocmaps(PFS_FILL_ARGS) > freename =3D NULL; > if (entry->eflags & MAP_ENTRY_IS_SUB_MAP) > continue; > - saved_end =3D entry->end; > + e_prot =3D entry->protection; > + e_start =3D entry->start; > + e_end =3D entry->end; > obj =3D entry->object.vm_object; > for (lobj =3D tobj =3D obj; tobj; tobj =3D tobj->backing_object) { > VM_OBJECT_LOCK(tobj); > @@ -913,6 +917,8 @@ linprocfs_doprocmaps(PFS_FILL_ARGS) > VM_OBJECT_UNLOCK(lobj); > lobj =3D tobj; > } > + last_timestamp =3D map->timestamp; > + vm_map_unlock_read(map); > ino =3D 0; > if (lobj) { > off =3D IDX_TO_OFF(lobj->size); > @@ -950,10 +956,10 @@ linprocfs_doprocmaps(PFS_FILL_ARGS) > */ > error =3D sbuf_printf(sb, > "%08lx-%08lx %s%s%s%s %08lx %02x:%02x %lu%s%s\n", > - (u_long)entry->start, (u_long)entry->end, > - (entry->protection & VM_PROT_READ)?"r":"-", > - (entry->protection & VM_PROT_WRITE)?"w":"-", > - (entry->protection & VM_PROT_EXECUTE)?"x":"-", > + (u_long)e_start, (u_long)e_end, > + (e_prot & VM_PROT_READ)?"r":"-", > + (e_prot & VM_PROT_WRITE)?"w":"-", > + (e_prot & VM_PROT_EXECUTE)?"x":"-", > "p", > (u_long)off, > 0, > @@ -968,6 +974,16 @@ linprocfs_doprocmaps(PFS_FILL_ARGS) > error =3D 0; > break; > } > + vm_map_lock_read(map); > + if (last_timestamp + 1 !=3D map->timestamp) { > + /* > + * Look again for the entry because the map was > + * modified while it was unlocked. Specifically, > + * the entry may have been clipped, merged, or deleted. > + */ > + vm_map_lookup_entry(map, e_end - 1, &tmp_entry); > + entry =3D tmp_entry; > + } > } > vm_map_unlock_read(map); > =20 >=20 > Modified: head/sys/fs/procfs/procfs_map.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=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/fs/procfs/procfs_map.c Mon Dec 8 12:29:30 2008 (r185764) > +++ head/sys/fs/procfs/procfs_map.c Mon Dec 8 12:34:52 2008 (r185765) > @@ -84,9 +84,10 @@ procfs_doprocmap(PFS_FILL_ARGS) > { > int error, vfslocked; > vm_map_t map =3D &p->p_vmspace->vm_map; > - vm_map_entry_t entry; > + vm_map_entry_t entry, tmp_entry; > struct vnode *vp; > char *fullpath, *freepath; > + unsigned int last_timestamp; > #ifdef COMPAT_IA32 > int wrap32 =3D 0; > #endif > @@ -113,13 +114,19 @@ procfs_doprocmap(PFS_FILL_ARGS) > entry =3D entry->next) { > vm_object_t obj, tobj, lobj; > int ref_count, shadow_count, flags; > - vm_offset_t addr; > + vm_offset_t e_start, e_end, addr; > int resident, privateresident; > char *type; > + vm_eflags_t e_eflags; > + vm_prot_t e_prot; > =20 > if (entry->eflags & MAP_ENTRY_IS_SUB_MAP) > continue; > =20 > + e_eflags =3D entry->eflags; > + e_prot =3D entry->protection; > + e_start =3D entry->start; > + e_end =3D entry->end; > privateresident =3D 0; > obj =3D entry->object.vm_object; > if (obj !=3D NULL) { > @@ -143,11 +150,13 @@ procfs_doprocmap(PFS_FILL_ARGS) > VM_OBJECT_UNLOCK(lobj); > lobj =3D tobj; > } > + last_timestamp =3D map->timestamp; > + vm_map_unlock_read(map); > =20 > freepath =3D NULL; > fullpath =3D "-"; > if (lobj) { > - switch(lobj->type) { > + switch (lobj->type) { > default: > case OBJT_DEFAULT: > type =3D "default"; > @@ -193,19 +202,19 @@ procfs_doprocmap(PFS_FILL_ARGS) > */ > error =3D sbuf_printf(sb, > "0x%lx 0x%lx %d %d %p %s%s%s %d %d 0x%x %s %s %s %s\n", > - (u_long)entry->start, (u_long)entry->end, > + (u_long)e_start, (u_long)e_end, > resident, privateresident, > #ifdef COMPAT_IA32 > wrap32 ? NULL : obj, /* Hide 64 bit value */ > #else > obj, > #endif > - (entry->protection & VM_PROT_READ)?"r":"-", > - (entry->protection & VM_PROT_WRITE)?"w":"-", > - (entry->protection & VM_PROT_EXECUTE)?"x":"-", > + (e_prot & VM_PROT_READ)?"r":"-", > + (e_prot & VM_PROT_WRITE)?"w":"-", > + (e_prot & VM_PROT_EXECUTE)?"x":"-", > ref_count, shadow_count, flags, > - (entry->eflags & MAP_ENTRY_COW)?"COW":"NCOW", > - (entry->eflags & MAP_ENTRY_NEEDS_COPY)?"NC":"NNC", > + (e_eflags & MAP_ENTRY_COW)?"COW":"NCOW", > + (e_eflags & MAP_ENTRY_NEEDS_COPY)?"NC":"NNC", > type, fullpath); > =20 > if (freepath !=3D NULL) > @@ -215,6 +224,16 @@ procfs_doprocmap(PFS_FILL_ARGS) > error =3D 0; > break; > } > + vm_map_lock_read(map); > + if (last_timestamp + 1 !=3D map->timestamp) { > + /* > + * Look again for the entry because the map was > + * modified while it was unlocked. Specifically, > + * the entry may have been clipped, merged, or deleted. > + */ > + vm_map_lookup_entry(map, e_end - 1, &tmp_entry); > + entry =3D tmp_entry; > + } > } > vm_map_unlock_read(map); > return (error); --w5nY8nmEklXMR7Cj Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkk9GrcACgkQC3+MBN1Mb4h76gCg9MxYoQcoxC3fIXy1dNnhpm6n HdAAn2o0XBcNhBDKk5KSjLsTdMMzEQis =GYHS -----END PGP SIGNATURE----- --w5nY8nmEklXMR7Cj--