From owner-svn-src-all@FreeBSD.ORG Sat May 9 21:38:07 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3893C20D; Sat, 9 May 2015 21:38:07 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D03F31649; Sat, 9 May 2015 21:38:06 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id t49Lc1p1023616 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sun, 10 May 2015 00:38:01 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua t49Lc1p1023616 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id t49Lc112023615; Sun, 10 May 2015 00:38:01 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 10 May 2015 00:38:01 +0300 From: Konstantin Belousov To: Oliver Pinter Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r282684 - in head/sys: amd64/amd64 amd64/include x86/include x86/xen Message-ID: <20150509213800.GO2390@kib.kiev.ua> References: <201505091911.t49JB2gh067512@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 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, 09 May 2015 21:38:07 -0000 On Sat, May 09, 2015 at 10:25:39PM +0200, Oliver Pinter wrote: > Hi Konstantin! > > On 5/9/15, Konstantin Belousov wrote: > > Author: kib > > Date: Sat May 9 19:11:01 2015 > > New Revision: 282684 > > URL: https://svnweb.freebsd.org/changeset/base/282684 > > > > Log: > > Rewrite amd64 PCID implementation to follow an algorithm described in > > the Vahalia' "Unix Internals" section 15.12 "Other TLB Consistency > > Algorithms". The same algorithm is already utilized by the MIPS pmap > > to handle ASIDs. > > > > The PCID for the address space is now allocated per-cpu during context > > switch to the thread using pmap, when no PCID on the cpu was ever > > allocated, or the current PCID is invalidated. If the PCID is reused, > > bit 63 of %cr3 can be set to avoid TLB flush. > > > > Each cpu has PCID' algorithm generation count, which is saved in the > > pmap pcpu block when pcpu PCID is allocated. On invalidation, the > > pmap generation count is zeroed, which signals the context switch code > > that already allocated PCID is no longer valid. The implication is > > the TLB shootdown for the given cpu/address space, due to the > > allocation of new PCID. > > > > The pm_save mask is no longer has to be tracked, which (significantly) > > reduces the targets of the TLB shootdown IPIs. Previously, pm_save > > was reset only on pmap_invalidate_all(), which made it accumulate the > > cpuids of all processors on which the thread was scheduled between > > full TLB shootdowns. > > > > Besides reducing the amount of TLB shootdowns and removing atomics to > > update pm_saves in the context switch code, the algorithm is much > > simpler than the maintanence of pm_save and selection of the right > > address space in the shootdown IPI handler. > > > > Reviewed by: alc > > Tested by: pho > > Sponsored by: The FreeBSD Foundation > > MFC after: 3 weeks > > > > Modified: > > head/sys/amd64/amd64/apic_vector.S > > head/sys/amd64/amd64/cpu_switch.S > > head/sys/amd64/amd64/genassym.c > > head/sys/amd64/amd64/machdep.c > > head/sys/amd64/amd64/mp_machdep.c > > head/sys/amd64/amd64/pmap.c > > head/sys/amd64/amd64/vm_machdep.c > > head/sys/amd64/include/cpufunc.h > > head/sys/amd64/include/pcpu.h > > head/sys/amd64/include/pmap.h > > head/sys/amd64/include/smp.h > > head/sys/x86/include/specialreg.h > > head/sys/x86/xen/xen_apic.c > > ... > > The KASSERT should be ```KASSERT(pmap->pm_pcids[cpuid].pm_pcid != > PMAP_PCID_KERN || pmap == kernel_pmap,``` instead of the current > ```KASSERT(pmap != PMAP_PCID_KERN || pmap == kernel_pmap,```. > > You compared the pmap against the kernel pmap's PCID, instead of the > pmap's pcid. > https://github.com/freebsd/freebsd/commit/3fb738761ee4e1438402fd537fc893b44ae9312b#diff-9e67c23e66565ca69fc2e6a06631f43eR6605 Fixed by r282696, thanks.