From owner-freebsd-arm@FreeBSD.ORG Thu Sep 27 16:29:23 2012 Return-Path: Delivered-To: arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 128B01065670 for ; Thu, 27 Sep 2012 16:29:23 +0000 (UTC) (envelope-from alc@rice.edu) Received: from mh10.mail.rice.edu (mh10.mail.rice.edu [128.42.201.30]) by mx1.freebsd.org (Postfix) with ESMTP id D1F788FC0A for ; Thu, 27 Sep 2012 16:29:22 +0000 (UTC) Received: from mh10.mail.rice.edu (localhost.localdomain [127.0.0.1]) by mh10.mail.rice.edu (Postfix) with ESMTP id E2A88604EA; Thu, 27 Sep 2012 11:29:21 -0500 (CDT) Received: from mh10.mail.rice.edu (localhost.localdomain [127.0.0.1]) by mh10.mail.rice.edu (Postfix) with ESMTP id E14E0604D1; Thu, 27 Sep 2012 11:29:21 -0500 (CDT) X-Virus-Scanned: by amavis-2.7.0 at mh10.mail.rice.edu, auth channel Received: from mh10.mail.rice.edu ([127.0.0.1]) by mh10.mail.rice.edu (mh10.mail.rice.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id CrIKMf78IRaA; Thu, 27 Sep 2012 11:29:21 -0500 (CDT) Received: from adsl-216-63-78-18.dsl.hstntx.swbell.net (adsl-216-63-78-18.dsl.hstntx.swbell.net [216.63.78.18]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) (Authenticated sender: alc) by mh10.mail.rice.edu (Postfix) with ESMTPSA id 84D2B604D4; Thu, 27 Sep 2012 11:29:21 -0500 (CDT) Message-ID: <50647EE0.6010900@rice.edu> Date: Thu, 27 Sep 2012 11:29:20 -0500 From: Alan Cox User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:8.0) Gecko/20111113 Thunderbird/8.0 MIME-Version: 1.0 To: John-Mark Gurney References: <1346350374.1140.525.camel@revolution.hippie.lan> <5045351F.6060201@rice.edu> <1346723041.1140.602.camel@revolution.hippie.lan> <504B85BE.3030101@rice.edu> <1347316458.1137.41.camel@revolution.hippie.lan> <504F8BAC.4040902@rice.edu> <20120915045040.GZ58312@funkthat.com> <5054D69B.40209@rice.edu> <20120917033308.GB58312@funkthat.com> <5061D2AA.3000100@rice.edu> <20120926061340.GL19036@funkthat.com> In-Reply-To: <20120926061340.GL19036@funkthat.com> Content-Type: multipart/mixed; boundary="------------010608060907090309010509" Cc: "arm@freebsd.org" Subject: Re: arm pmap locking X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Sep 2012 16:29:23 -0000 This is a multi-part message in MIME format. --------------010608060907090309010509 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 09/26/2012 01:13, John-Mark Gurney wrote: > Alan Cox wrote this message on Tue, Sep 25, 2012 at 10:50 -0500: >> On 09/16/2012 22:33, John-Mark Gurney wrote: >>> Still getting the LOR.. It always right after boot.. after trying >>> to mount root and warning about no time-of-day clock, but before setting >>> hostuuid.. >> Could you please try the attached patch on your armv6 BEAGLEBONE? My >> hope is that this addresses the root cause of the LORs involving the >> pmap lock. > Good news... That patch boots and doesn't have the LOR... > > FreeBSD 10.0-CURRENT #10 r240947M: Mon Sep 24 17:01:11 PDT 2012 > jmg@pcbsd-779:/usr/obj/arm.armv6/usr/src.HEAD/sys/helium arm > > [...] > > Trying to mount root from ufs:mmcsd0s2 []... > warning: no time-of-day clock registered, system time will not be set accurately > Setting hostuuid: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. > > Thanks for your work tracking it down! > Great. Now that the LOR is out of the way, let's try further simplifications to the locking. I don't believe that pmap_alloc_l2_bucket() needs to unlock and relock around every allocation. Here is another patch to eliminate that. Also, the patch replaces an explicit bzero() call with M_ZERO. Alan --------------010608060907090309010509 Content-Type: text/plain; name="armv6-pmap4.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="armv6-pmap4.patch" Index: arm/arm/pmap-v6.c =================================================================== --- arm/arm/pmap-v6.c (revision 240983) +++ arm/arm/pmap-v6.c (working copy) @@ -607,36 +607,20 @@ pmap_alloc_l2_bucket(pmap_t pm, vm_offset_t va) l1idx = L1_IDX(va); PMAP_ASSERT_LOCKED(pm); - rw_assert(&pvh_global_lock, RA_WLOCKED); if ((l2 = pm->pm_l2[L2_IDX(l1idx)]) == NULL) { /* * No mapping at this address, as there is * no entry in the L1 table. * Need to allocate a new l2_dtable. */ - PMAP_UNLOCK(pm); - rw_wunlock(&pvh_global_lock); - if ((l2 = uma_zalloc(l2table_zone, M_NOWAIT)) == NULL) { - rw_wlock(&pvh_global_lock); - PMAP_LOCK(pm); + l2 = uma_zalloc(l2table_zone, M_NOWAIT | M_ZERO); + if (l2 == NULL) return (NULL); - } - rw_wlock(&pvh_global_lock); - PMAP_LOCK(pm); - if (pm->pm_l2[L2_IDX(l1idx)] != NULL) { - /* - * Someone already allocated the l2_dtable while - * we were doing the same. - */ - uma_zfree(l2table_zone, l2); - l2 = pm->pm_l2[L2_IDX(l1idx)]; - } else { - bzero(l2, sizeof(*l2)); - /* - * Link it into the parent pmap - */ - pm->pm_l2[L2_IDX(l1idx)] = l2; - } + + /* + * Link it into the parent pmap. + */ + pm->pm_l2[L2_IDX(l1idx)] = l2; } l2b = &l2->l2_bucket[L2_BUCKET(l1idx)]; @@ -651,17 +635,7 @@ pmap_alloc_l2_bucket(pmap_t pm, vm_offset_t va) * No L2 page table has been allocated. Chances are, this * is because we just allocated the l2_dtable, above. */ - PMAP_UNLOCK(pm); - rw_wunlock(&pvh_global_lock); ptep = uma_zalloc(l2zone, M_NOWAIT); - rw_wlock(&pvh_global_lock); - PMAP_LOCK(pm); - if (l2b->l2b_kva != 0) { - /* We lost the race. */ - uma_zfree(l2zone, ptep); - return (l2b); - } - l2b->l2b_phys = vtophys(ptep); if (ptep == NULL) { /* * Oops, no more L2 page tables available at this @@ -677,6 +651,7 @@ pmap_alloc_l2_bucket(pmap_t pm, vm_offset_t va) l2->l2_occupancy++; l2b->l2b_kva = ptep; + l2b->l2b_phys = pmap_kextract((vm_offset_t)ptep); l2b->l2b_l1idx = l1idx; } --------------010608060907090309010509--