From owner-svn-src-head@FreeBSD.ORG Sat Mar 21 15:33:01 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4FF37DBF; Sat, 21 Mar 2015 15:33:01 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3271F305; Sat, 21 Mar 2015 15:33:01 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2LFX096069040; Sat, 21 Mar 2015 15:33:00 GMT (envelope-from cognet@FreeBSD.org) Received: (from cognet@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2LFX0ZD069036; Sat, 21 Mar 2015 15:33:00 GMT (envelope-from cognet@FreeBSD.org) Message-Id: <201503211533.t2LFX0ZD069036@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: cognet set sender to cognet@FreeBSD.org using -f From: Olivier Houchard Date: Sat, 21 Mar 2015 15:33:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r280324 - head/sys/arm/arm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 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: Sat, 21 Mar 2015 15:33:01 -0000 Author: cognet Date: Sat Mar 21 15:32:59 2015 New Revision: 280324 URL: https://svnweb.freebsd.org/changeset/base/280324 Log: When waiting on PTE allocation, another thread could free the l2_dtable while we're not looking at it. Fix this by increasing l2->l2_occupancy before we try to alloc (and decrease it if the allocation failed, or if another thread did a similar allocation). Submitted by: Kohji Okuno MFC after: 1 week Modified: head/sys/arm/arm/pmap-v6.c head/sys/arm/arm/pmap.c Modified: head/sys/arm/arm/pmap-v6.c ============================================================================== --- head/sys/arm/arm/pmap-v6.c Sat Mar 21 15:01:19 2015 (r280323) +++ head/sys/arm/arm/pmap-v6.c Sat Mar 21 15:32:59 2015 (r280324) @@ -758,6 +758,7 @@ pmap_alloc_l2_bucket(pmap_t pmap, vm_off * No L2 page table has been allocated. Chances are, this * is because we just allocated the l2_dtable, above. */ + l2->l2_occupancy++; PMAP_UNLOCK(pmap); rw_wunlock(&pvh_global_lock); ptep = uma_zalloc(l2zone, M_NOWAIT); @@ -765,6 +766,7 @@ pmap_alloc_l2_bucket(pmap_t pmap, vm_off PMAP_LOCK(pmap); if (l2b->l2b_kva != 0) { /* We lost the race. */ + l2->l2_occupancy--; uma_zfree(l2zone, ptep); return (l2b); } @@ -775,6 +777,7 @@ pmap_alloc_l2_bucket(pmap_t pmap, vm_off * time. We may need to deallocate the l2_dtable * if we allocated a new one above. */ + l2->l2_occupancy--; if (l2->l2_occupancy == 0) { pmap->pm_l2[L2_IDX(l1idx)] = NULL; uma_zfree(l2table_zone, l2); @@ -782,7 +785,6 @@ pmap_alloc_l2_bucket(pmap_t pmap, vm_off return (NULL); } - l2->l2_occupancy++; l2b->l2b_kva = ptep; l2b->l2b_l1idx = l1idx; } Modified: head/sys/arm/arm/pmap.c ============================================================================== --- head/sys/arm/arm/pmap.c Sat Mar 21 15:01:19 2015 (r280323) +++ head/sys/arm/arm/pmap.c Sat Mar 21 15:32:59 2015 (r280324) @@ -878,6 +878,7 @@ pmap_alloc_l2_bucket(pmap_t pm, vm_offse * No L2 page table has been allocated. Chances are, this * is because we just allocated the l2_dtable, above. */ + l2->l2_occupancy++; PMAP_UNLOCK(pm); rw_wunlock(&pvh_global_lock); ptep = uma_zalloc(l2zone, M_NOWAIT); @@ -885,6 +886,7 @@ pmap_alloc_l2_bucket(pmap_t pm, vm_offse PMAP_LOCK(pm); if (l2b->l2b_kva != 0) { /* We lost the race. */ + l2->l2_occupancy--; uma_zfree(l2zone, ptep); return (l2b); } @@ -895,6 +897,7 @@ pmap_alloc_l2_bucket(pmap_t pm, vm_offse * time. We may need to deallocate the l2_dtable * if we allocated a new one above. */ + l2->l2_occupancy--; if (l2->l2_occupancy == 0) { pm->pm_l2[L2_IDX(l1idx)] = NULL; uma_zfree(l2table_zone, l2); @@ -902,7 +905,6 @@ pmap_alloc_l2_bucket(pmap_t pm, vm_offse return (NULL); } - l2->l2_occupancy++; l2b->l2b_kva = ptep; l2b->l2b_l1idx = l1idx; }