From owner-svn-src-user@FreeBSD.ORG Thu May 9 02:23:03 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8C2D797C; Thu, 9 May 2013 02:23:03 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 6DAFA172A; Thu, 9 May 2013 02:23:03 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r492N3Va048329; Thu, 9 May 2013 02:23:03 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r492N3w7048328; Thu, 9 May 2013 02:23:03 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201305090223.r492N3w7048328@svn.freebsd.org> From: Attilio Rao Date: Thu, 9 May 2013 02:23:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r250401 - user/attilio/jeff-numa/sys/vm X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 May 2013 02:23:03 -0000 Author: attilio Date: Thu May 9 02:23:02 2013 New Revision: 250401 URL: http://svnweb.freebsd.org/changeset/base/250401 Log: Port vm_phys changes to recent -CURRENT. Sponsored by: EMC / Isilon storage division Modified: user/attilio/jeff-numa/sys/vm/vm_phys.c Modified: user/attilio/jeff-numa/sys/vm/vm_phys.c ============================================================================== --- user/attilio/jeff-numa/sys/vm/vm_phys.c Thu May 9 02:04:28 2013 (r250400) +++ user/attilio/jeff-numa/sys/vm/vm_phys.c Thu May 9 02:23:02 2013 (r250401) @@ -48,7 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#if MAXDOMAIN > 1 +#if MAXMEMDOM > 1 #include #endif #include @@ -96,7 +96,7 @@ static struct mtx vm_phys_fictitious_reg MALLOC_DEFINE(M_FICT_PAGES, "", ""); static struct vm_freelist - vm_phys_free_queues[MAXDOMAIN][VM_NFREELIST][VM_NFREEPOOL][VM_NFREEORDER]; + vm_phys_free_queues[MAXMEMDOM][VM_NFREELIST][VM_NFREEPOOL][VM_NFREEORDER]; static int vm_nfreelists = VM_FREELIST_DEFAULT + 1; @@ -115,6 +115,8 @@ SYSCTL_OID(_vm, OID_AUTO, phys_segs, CTL SYSCTL_INT(_vm, OID_AUTO, ndomains, CTLFLAG_RD, &vm_ndomains, 0, "Number of physical memory domains available."); +static vm_page_t vm_phys_alloc_domain_pages(int domain, int flind, int pool, + int order); static void _vm_phys_create_seg(vm_paddr_t start, vm_paddr_t end, int flind, int domain); static void vm_phys_create_seg(vm_paddr_t start, vm_paddr_t end, int flind); @@ -125,7 +127,7 @@ static void vm_phys_split_pages(vm_page_ static __inline int vm_rr_selectdomain(void) { -#if MAXDOMAIN > 1 +#if MAXMEMDOM > 1 struct thread *td; td = curthread; @@ -388,16 +390,43 @@ vm_phys_add_page(vm_paddr_t pa) } /* + * Allocate a contiguous, power of two-sized set of physical pages + * from the free lists. + * + * The free page queues must be locked. + */ +vm_page_t +vm_phys_alloc_pages(int pool, int order) +{ + vm_page_t m; + int domain, flind; + + KASSERT(pool < VM_NFREEPOOL, + ("vm_phys_alloc_pages: pool %d is out of range", pool)); + KASSERT(order < VM_NFREEORDER, + ("vm_phys_alloc_pages: order %d is out of range", order)); + + domain = vm_rr_selectdomain(); + for (flind = 0; flind < vm_nfreelists; flind++) { + m = vm_phys_alloc_domain_pages(domain, flind, pool, order); + if (m != NULL) + return (m); + } + return (NULL); +} + +/* * Find and dequeue a free page on the given free list, with the * specified pool and order */ -static vm_page_t -vm_phys_alloc_freelist_pages_domain(int domain, int flind, int pool, int order) -{ - struct vm_freelist *fl; - struct vm_freelist *alt; - int oind, pind; +vm_page_t +vm_phys_alloc_freelist_pages(int flind, int pool, int order) +{ +#if MAXMEMDOM > 1 vm_page_t m; + int i; +#endif + int domain; KASSERT(flind < VM_NFREELIST, ("vm_phys_alloc_freelist_pages: freelist %d is out of range", flind)); @@ -406,6 +435,39 @@ vm_phys_alloc_freelist_pages_domain(int KASSERT(order < VM_NFREEORDER, ("vm_phys_alloc_freelist_pages: order %d is out of range", order)); +#if MAXMEMDOM > 1 + /* + * This routine expects to be called with a VM_FREELIST_* constant. + * On a system with multiple domains we need to adjust the flind + * appropriately. If it is for VM_FREELIST_DEFAULT we need to + * iterate over the per-domain lists. + */ + domain = vm_rr_selectdomain(); + if (flind == VM_FREELIST_DEFAULT) { + m = NULL; + for (i = 0; i < vm_ndomains; i++, flind++) { + m = vm_phys_alloc_domain_pages(domain, flind, pool, + order); + if (m != NULL) + break; + } + return (m); + } else if (flind > VM_FREELIST_DEFAULT) + flind += vm_ndomains - 1; +#else + domain = 0; +#endif + return (vm_phys_alloc_domain_pages(domain, flind, pool, order)); +} + +static vm_page_t +vm_phys_alloc_domain_pages(int domain, int flind, int pool, int order) +{ + struct vm_freelist *fl; + struct vm_freelist *alt; + int oind, pind; + vm_page_t m; + mtx_assert(&vm_page_queue_free_mtx, MA_OWNED); fl = &vm_phys_free_queues[domain][flind][pool][0]; for (oind = order; oind < VM_NFREEORDER; oind++) { @@ -439,40 +501,6 @@ vm_phys_alloc_freelist_pages_domain(int } /* - * See the comments for vm_phys_alloc_freelist_pages_domain(). - * When MAXDOMAIN is bumped picks up a domain in round-robin fashion. - */ -vm_page_t -vm_phys_alloc_freelist_pages(int flind, int pool, int order) -{ - - return (vm_phys_alloc_freelist_pages_domain(vm_rr_selectdomain(), - flind, pool, order)); -} - -/* - * Allocate a contiguous, power of two-sized set of physical pages - * from the free lists. - * - * The free page queues must be locked. - */ -vm_page_t -vm_phys_alloc_pages(int pool, int order) -{ - vm_page_t m; - int domain, flind; - - domain = vm_rr_selectdomain(); - for (flind = 0; flind < vm_nfreelists; flind++) { - m = vm_phys_alloc_freelist_pages_domain(domain, flind, pool, - order); - if (m != NULL) - return (m); - } - return (NULL); -} - -/* * Find the vm_page corresponding to the given physical address. */ vm_page_t