From owner-svn-src-all@FreeBSD.ORG Sat May 9 20:25:46 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 0CBFB3E3 for ; Sat, 9 May 2015 20:25:46 +0000 (UTC) Received: from mail-ie0-f182.google.com (mail-ie0-f182.google.com [209.85.223.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D1A0A1F2B for ; Sat, 9 May 2015 20:25:45 +0000 (UTC) Received: by iedfl3 with SMTP id fl3so95540748ied.1 for ; Sat, 09 May 2015 13:25:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=hwbvr7+AZBnnmsj0c99nfNrwrxo842r/dXyVJZe2XTo=; b=UjLpw+TytGuzX+CxfJJjJs10KbBB3J/lK1p2GTYATQKwXNvVM76hl8k9MUtJtNBu8n 6wTjQ2EZvUdv6dpxrflIHpl6KCCOYnvxLK9Y4816cz6j9EVJgtAcdlAw49Vbui9jILYn gYRJjJ3U6H9Tpq6fx/+PQqVTzt+PJ954yyeaB0jbYiJxAIUGZQtewZ1CPPldVzrcZ4eX 7lUfiOL5O5dH3fokJQKmev3mmBgVVas9NE+KCJ9+h9iH1vT4qqnBoVBzMpXHL5Hp8/uq NtiS4ajMB3MWk9CWqu4Z01ktCWl4ip0eSp+VExsgA63mfX5F6iyW3S9DeQ/IowYe34Gu kDGQ== X-Gm-Message-State: ALoCoQm19vCiI8YL2Ki3qjM/hZzsyLRltykaAE6Dq1EicF9griRVoNsKybVDpdl9r3ZIuB6ZwwkO MIME-Version: 1.0 X-Received: by 10.50.136.134 with SMTP id qa6mr6295405igb.26.1431203139462; Sat, 09 May 2015 13:25:39 -0700 (PDT) Received: by 10.79.11.6 with HTTP; Sat, 9 May 2015 13:25:39 -0700 (PDT) In-Reply-To: <201505091911.t49JB2gh067512@svn.freebsd.org> References: <201505091911.t49JB2gh067512@svn.freebsd.org> Date: Sat, 9 May 2015 22:25:39 +0200 Message-ID: Subject: Re: svn commit: r282684 - in head/sys: amd64/amd64 amd64/include x86/include x86/xen From: Oliver Pinter To: Konstantin Belousov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 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 20:25:46 -0000 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