From owner-svn-src-all@FreeBSD.ORG Sat Aug 2 16:54:52 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8192FC94; Sat, 2 Aug 2014 16:54:52 +0000 (UTC) Received: from mx1.sbone.de (bird.sbone.de [46.4.1.90]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "mx1.sbone.de", Issuer "SBone.DE" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id EB57C2623; Sat, 2 Aug 2014 16:54:51 +0000 (UTC) Received: from mail.sbone.de (mail.sbone.de [IPv6:fde9:577b:c1a9:31::2013:587]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx1.sbone.de (Postfix) with ESMTPS id C8D0D25D3892; Sat, 2 Aug 2014 16:54:48 +0000 (UTC) Received: from content-filter.sbone.de (content-filter.sbone.de [IPv6:fde9:577b:c1a9:31::2013:2742]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPS id F1306C25D45; Sat, 2 Aug 2014 16:54:47 +0000 (UTC) X-Virus-Scanned: amavisd-new at sbone.de Received: from mail.sbone.de ([IPv6:fde9:577b:c1a9:31::2013:587]) by content-filter.sbone.de (content-filter.sbone.de [fde9:577b:c1a9:31::2013:2742]) (amavisd-new, port 10024) with ESMTP id X-ZPXp3iOeWN; Sat, 2 Aug 2014 16:54:44 +0000 (UTC) Received: from [IPv6:fde9:577b:c1a9:4410:c013:8aed:774:63c7] (unknown [IPv6:fde9:577b:c1a9:4410:c013:8aed:774:63c7]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mail.sbone.de (Postfix) with ESMTPSA id 5B6BEC25BA5; Sat, 2 Aug 2014 16:54:43 +0000 (UTC) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: svn commit: r269433 - head/sys/vm From: "Bjoern A. Zeeb" In-Reply-To: <201408021610.s72GAPAd040967@svn.freebsd.org> Date: Sat, 2 Aug 2014 16:54:27 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: References: <201408021610.s72GAPAd040967@svn.freebsd.org> To: Alan Cox X-Mailer: Apple Mail (2.1878.6) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Aug 2014 16:54:52 -0000 On 02 Aug 2014, at 16:10 , Alan Cox wrote: > Author: alc > Date: Sat Aug 2 16:10:24 2014 > New Revision: 269433 > URL: http://svnweb.freebsd.org/changeset/base/269433 >=20 > Log: > Handle wiring failures in vm_map_wire() with the new functions > pmap_unwire() and vm_object_unwire(). >=20 > Retire vm_fault_{un,}wire(), since they are no longer used. >=20 > (See r268327 and r269134 for the motivation behind this change.) >=20 > Reviewed by: kib > Sponsored by: EMC / Isilon Storage Division >=20 cc1: warnings being treated as errors /scratch/tmp/bz/head.svn/sys/vm/vm_map.c: In function 'vm_map_wire': /scratch/tmp/bz/head.svn/sys/vm/vm_map.c:2470: warning: 'rv' may be used = uninitialized in this function --- vm_map.o --- *** [vm_map.o] Error code 1 > Modified: > head/sys/vm/vm_extern.h > head/sys/vm/vm_fault.c > head/sys/vm/vm_map.c >=20 > Modified: head/sys/vm/vm_extern.h > = =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/vm/vm_extern.h Sat Aug 2 15:05:23 2014 = (r269432) > +++ head/sys/vm/vm_extern.h Sat Aug 2 16:10:24 2014 = (r269433) > @@ -81,7 +81,6 @@ int vm_fault_hold(vm_map_t map, vm_offse > int fault_flags, vm_page_t *m_hold); > int vm_fault_quick_hold_pages(vm_map_t map, vm_offset_t addr, = vm_size_t len, > vm_prot_t prot, vm_page_t *ma, int max_count); > -int vm_fault_wire(vm_map_t, vm_offset_t, vm_offset_t, boolean_t); > int vm_forkproc(struct thread *, struct proc *, struct thread *, = struct vmspace *, int); > void vm_waitproc(struct proc *); > int vm_mmap(vm_map_t, vm_offset_t *, vm_size_t, vm_prot_t, vm_prot_t, = int, objtype_t, void *, vm_ooffset_t); >=20 > Modified: head/sys/vm/vm_fault.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/vm/vm_fault.c Sat Aug 2 15:05:23 2014 = (r269432) > +++ head/sys/vm/vm_fault.c Sat Aug 2 16:10:24 2014 = (r269433) > @@ -106,7 +106,6 @@ __FBSDID("$FreeBSD$"); > #define PFFOR 4 >=20 > static int vm_fault_additional_pages(vm_page_t, int, int, vm_page_t *, = int *); > -static void vm_fault_unwire(vm_map_t, vm_offset_t, vm_offset_t, = boolean_t); >=20 > #define VM_FAULT_READ_BEHIND 8 > #define VM_FAULT_READ_MAX (1 + VM_FAULT_READ_AHEAD_MAX) > @@ -1155,68 +1154,6 @@ error:=09 > } >=20 > /* > - * vm_fault_wire: > - * > - * Wire down a range of virtual addresses in a map. > - */ > -int > -vm_fault_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, > - boolean_t fictitious) > -{ > - vm_offset_t va; > - int rv; > - > - /* > - * We simulate a fault to get the page and enter it in the = physical > - * map. For user wiring, we only ask for read access on = currently > - * read-only sections. > - */ > - for (va =3D start; va < end; va +=3D PAGE_SIZE) { > - rv =3D vm_fault(map, va, VM_PROT_NONE, = VM_FAULT_CHANGE_WIRING); > - if (rv) { > - if (va !=3D start) > - vm_fault_unwire(map, start, va, = fictitious); > - return (rv); > - } > - } > - return (KERN_SUCCESS); > -} > - > -/* > - * vm_fault_unwire: > - * > - * Unwire a range of virtual addresses in a map. > - */ > -static void > -vm_fault_unwire(vm_map_t map, vm_offset_t start, vm_offset_t end, > - boolean_t fictitious) > -{ > - vm_paddr_t pa; > - vm_offset_t va; > - vm_page_t m; > - pmap_t pmap; > - > - pmap =3D vm_map_pmap(map); > - > - /* > - * Since the pages are wired down, we must be able to get their > - * mappings from the physical map system. > - */ > - for (va =3D start; va < end; va +=3D PAGE_SIZE) { > - pa =3D pmap_extract(pmap, va); > - if (pa !=3D 0) { > - pmap_change_wiring(pmap, va, FALSE); > - if (!fictitious) { > - m =3D PHYS_TO_VM_PAGE(pa); > - vm_page_lock(m); > - vm_page_unwire(m, PQ_ACTIVE); > - vm_page_unlock(m); > - } > - } > - } > -} > - > -/* > * Routine: > * vm_fault_copy_entry > * Function: >=20 > Modified: head/sys/vm/vm_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/vm/vm_map.c Sat Aug 2 15:05:23 2014 = (r269432) > +++ head/sys/vm/vm_map.c Sat Aug 2 16:10:24 2014 = (r269433) > @@ -140,6 +140,8 @@ static void vmspace_zdtor(void *mem, int > static int vm_map_stack_locked(vm_map_t map, vm_offset_t addrbos, > vm_size_t max_ssize, vm_size_t growsize, vm_prot_t prot, vm_prot_t = max, > int cow); > +static void vm_map_wire_entry_failure(vm_map_t map, vm_map_entry_t = entry, > + vm_offset_t failed_addr); >=20 > #define ENTRY_CHARGED(e) ((e)->cred !=3D NULL || \ > ((e)->object.vm_object !=3D NULL && (e)->object.vm_object->cred !=3D= NULL && \ > @@ -2418,6 +2420,42 @@ done: > } >=20 > /* > + * vm_map_wire_entry_failure: > + * > + * Handle a wiring failure on the given entry. > + * > + * The map should be locked. > + */ > +static void > +vm_map_wire_entry_failure(vm_map_t map, vm_map_entry_t entry, > + vm_offset_t failed_addr) > +{ > + > + VM_MAP_ASSERT_LOCKED(map); > + KASSERT((entry->eflags & MAP_ENTRY_IN_TRANSITION) !=3D 0 && > + entry->wired_count =3D=3D 1, > + ("vm_map_wire_entry_failure: entry %p isn't being wired", = entry)); > + KASSERT(failed_addr < entry->end, > + ("vm_map_wire_entry_failure: entry %p was fully wired", = entry)); > + > + /* > + * If any pages at the start of this entry were successfully = wired, > + * then unwire them. > + */ > + if (failed_addr > entry->start) { > + pmap_unwire(map->pmap, entry->start, failed_addr); > + vm_object_unwire(entry->object.vm_object, entry->offset, > + failed_addr - entry->start, PQ_ACTIVE); > + } > + > + /* > + * Assign an out-of-range value to represent the failure to wire = this > + * entry. > + */ > + entry->wired_count =3D -1; > +} > + > +/* > * vm_map_wire: > * > * Implements both kernel and user wiring. > @@ -2427,10 +2465,10 @@ vm_map_wire(vm_map_t map, vm_offset_t st > int flags) > { > vm_map_entry_t entry, first_entry, tmp_entry; > - vm_offset_t saved_end, saved_start; > + vm_offset_t faddr, saved_end, saved_start; > unsigned int last_timestamp; > int rv; > - boolean_t fictitious, need_wakeup, result, user_wire; > + boolean_t need_wakeup, result, user_wire; > vm_prot_t prot; >=20 > if (start =3D=3D end) > @@ -2523,17 +2561,24 @@ vm_map_wire(vm_map_t map, vm_offset_t st > entry->wired_count++; > saved_start =3D entry->start; > saved_end =3D entry->end; > - fictitious =3D entry->object.vm_object !=3D NULL = && > - (entry->object.vm_object->flags & > - OBJ_FICTITIOUS) !=3D 0; > + > /* > * Release the map lock, relying on the = in-transition > * mark. Mark the map busy for fork. > */ > vm_map_busy(map); > vm_map_unlock(map); > - rv =3D vm_fault_wire(map, saved_start, = saved_end, > - fictitious); > + > + for (faddr =3D saved_start; faddr < saved_end; = faddr +=3D > + PAGE_SIZE) { > + /* > + * Simulate a fault to get the page and = enter > + * it into the physical map. > + */ > + if ((rv =3D vm_fault(map, faddr, = VM_PROT_NONE, > + VM_FAULT_CHANGE_WIRING)) !=3D = KERN_SUCCESS) > + break; > + } > vm_map_lock(map); > vm_map_unbusy(map); > if (last_timestamp + 1 !=3D map->timestamp) { > @@ -2552,23 +2597,22 @@ vm_map_wire(vm_map_t map, vm_offset_t st > first_entry =3D NULL; > entry =3D tmp_entry; > while (entry->end < saved_end) { > - if (rv !=3D KERN_SUCCESS) { > - = KASSERT(entry->wired_count =3D=3D 1, > - ("vm_map_wire: bad = count")); > - entry->wired_count =3D = -1; > - } > + /* > + * In case of failure, handle = entries > + * that were not fully wired = here; > + * fully wired entries are = handled > + * later. > + */ > + if (rv !=3D KERN_SUCCESS && > + faddr < entry->end) > + = vm_map_wire_entry_failure(map, > + entry, faddr); > entry =3D entry->next; > } > } > last_timestamp =3D map->timestamp; > if (rv !=3D KERN_SUCCESS) { > - KASSERT(entry->wired_count =3D=3D 1, > - ("vm_map_wire: bad count")); > - /* > - * Assign an out-of-range value to = represent > - * the failure to wire this entry. > - */ > - entry->wired_count =3D -1; > + vm_map_wire_entry_failure(map, entry, = faddr); > end =3D entry->end; > goto done; > } > @@ -2632,6 +2676,10 @@ done: > entry->wired_count =3D 0; > } else if (!user_wire || > (entry->eflags & MAP_ENTRY_USER_WIRED) =3D=3D 0) { > + /* > + * Undo the wiring. Wiring succeeded on this = entry > + * but failed on a later entry. =20 > + */ > if (entry->wired_count =3D=3D 1) > vm_map_entry_unwire(map, entry); > else >=20 =97=20 Bjoern A. Zeeb "Come on. Learn, goddamn it.", WarGames, 1983