From owner-p4-projects Fri Jul 12 16:20:43 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C1CCA37B406; Fri, 12 Jul 2002 16:20:28 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E355537B400 for ; Fri, 12 Jul 2002 16:20:27 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 79D2C43E3B for ; Fri, 12 Jul 2002 16:20:27 -0700 (PDT) (envelope-from peter@freebsd.org) Received: from freefall.freebsd.org (perforce@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g6CNKRJU027496 for ; Fri, 12 Jul 2002 16:20:27 -0700 (PDT) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g6CNKRid027493 for perforce@freebsd.org; Fri, 12 Jul 2002 16:20:27 -0700 (PDT) Date: Fri, 12 Jul 2002 16:20:27 -0700 (PDT) Message-Id: <200207122320.g6CNKRid027493@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm Subject: PERFORCE change 14163 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=14163 Change 14163 by peter@peter_xeon on 2002/07/12 16:20:07 make it possible for pagezero to run outside of Giant. - add locking state assertions to vm_pageq.c - lock the vm_pageq_add stuff from early boot to not trip these - allow vm_page_flag_set() etc to work on pages not in the remaining giant protected queues. ie: not required for PQ_NONE or PQ_FREE. I hope. :-) It should probably only be exempt for PQ_NONE. Affected files ... .. //depot/projects/pmap/sys/vm/vm_page.c#5 edit .. //depot/projects/pmap/sys/vm/vm_pageq.c#5 edit Differences ... ==== //depot/projects/pmap/sys/vm/vm_page.c#5 (text+ko) ==== @@ -303,6 +303,7 @@ * last rather than first. On large-memory machines, this avoids * the exhaustion of low physical memory before isa_dmainit has run. */ + mtx_lock_spin(&vm_page_queue_free_mtx); cnt.v_page_count = 0; cnt.v_free_count = 0; for (i = 0; phys_avail[i + 1] && npages > 0; i += 2) { @@ -316,6 +317,7 @@ pa += PAGE_SIZE; } } + mtx_unlock_spin(&vm_page_queue_free_mtx); return (vaddr); } @@ -341,14 +343,22 @@ void vm_page_flag_set(vm_page_t m, unsigned short bits) { - GIANT_REQUIRED; + +#ifdef INVARIANTS + if (m->queue >= PQ_INACTIVE) + mtx_assert(&Giant, MA_OWNED); +#endif m->flags |= bits; } void vm_page_flag_clear(vm_page_t m, unsigned short bits) { - GIANT_REQUIRED; + +#ifdef INVARIANTS + if (m->queue >= PQ_INACTIVE) + mtx_assert(&Giant, MA_OWNED); +#endif m->flags &= ~bits; } ==== //depot/projects/pmap/sys/vm/vm_pageq.c#5 (text+ko) ==== @@ -26,6 +26,22 @@ struct vpgqueues vm_page_queues[PQ_COUNT]; static struct mtx vm_pageq_mtx[PQ_COUNT]; + +#ifdef INVARIANTS +static __inline void +vm_pageq_lockcheck(int queue) +{ + + if (queue >= PQ_FREE && queue < PQ_INACTIVE) + mtx_assert(&vm_page_queue_free_mtx, MA_OWNED); + else + mtx_assert(&Giant, MA_OWNED); +} +#define LOCKCHECK(queue) vm_pageq_lockcheck(queue) +#else +#define LOCKCHECK(queue) do { } while(0) +#endif + void vm_pageq_init(void) { @@ -108,8 +124,7 @@ { vm_page_t m; - GIANT_REQUIRED; - + LOCKCHECK(PQ_FREE); ++cnt.v_page_count; m = PHYS_TO_VM_PAGE(pa); m->phys_addr = pa; @@ -155,8 +170,8 @@ int queue = m->queue; struct vpgqueues *pq; - GIANT_REQUIRED; if (queue != PQ_NONE) { + LOCKCHECK(queue); m->queue = PQ_NONE; pq = &vm_page_queues[queue]; TAILQ_REMOVE(&pq->pl, m, pageq); @@ -195,9 +210,8 @@ vm_page_t m = NULL; struct vpgqueues *pq; - GIANT_REQUIRED; + LOCKCHECK(basequeue); pq = &vm_page_queues[basequeue]; - /* * Note that for the first loop, index+i and index-i wind up at the * same place. Even though this is not totally optimal, we've already @@ -217,10 +231,9 @@ vm_page_t vm_pageq_find(int basequeue, int index, boolean_t prefer_zero) { - vm_page_t m; + vm_page_t m; - GIANT_REQUIRED; - + LOCKCHECK(basequeue); #if PQ_L2_SIZE > 1 if (prefer_zero) { m = TAILQ_LAST(&vm_page_queues[basequeue+index].pl, pglist); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message