From owner-freebsd-current@FreeBSD.ORG Mon Jan 30 02:38:35 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 977B4106566C; Mon, 30 Jan 2012 02:38:35 +0000 (UTC) (envelope-from ambrosehua@gmail.com) Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 07BA58FC0A; Mon, 30 Jan 2012 02:38:34 +0000 (UTC) Received: by werm13 with SMTP id m13so2031892wer.13 for ; Sun, 29 Jan 2012 18:38:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=Y5rCNTk6ET/23FnX3pyKQU0k0Lo1BC+FwZ1A/TYvs08=; b=x5Sq3ifbXVBDEYXcJlPGxmDawE47BKH61PxLST+KJnL5t2isPCYdjNPUyrEblzReMh iH/4RwHPMONZSughGYvs25ELDw6rdPn0Jfp3+HEwIzOhFxi03kQ6rUsQjY9I0jWVKJJh lsdg7vOsnidb/rw52Va39qqdnZSut5sK68PzY= MIME-Version: 1.0 Received: by 10.216.138.24 with SMTP id z24mr6434766wei.48.1327889751434; Sun, 29 Jan 2012 18:15:51 -0800 (PST) Received: by 10.223.42.18 with HTTP; Sun, 29 Jan 2012 18:15:51 -0800 (PST) Date: Mon, 30 Jan 2012 10:15:51 +0800 Message-ID: From: Paul Ambrose To: freebsd-current Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: quoted-printable Cc: kib@freebsd.org Subject: Does anyone try kib's Sandy Bridge PCID patch (pcid.2.patch)? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Jan 2012 02:38:35 -0000 I have two boxes, one is AMD Athlon 610e 2.4G with FreeBSD-current patched with pcid.2.patch? It works well without other issue and it seem the pcid patch does not affect other part of the kernel. The other one is Sandy Bridge i5-2300 with FreeBSD 9 release patched with pcid.1.patch( the pcid.2.patch seems dependent on AVX and XSAVE stuffs which is available on -current). But it hangs up just in a few minutes. I doubt the nvidia-driver which is not recompiled with patched kernel is the root, I will check this out later, but does anyone meet similar problem? I have two question about the pcid.2.patch 1. iff --git a/sys/amd64/amd64/apic_vector.S b/sys/amd64/amd64/apic_vector.S index 96c778d..5b7b759 100644 --- a/sys/amd64/amd64/apic_vector.S +++ b/sys/amd64/amd64/apic_vector.S @@ -149,17 +149,40 @@ IDTVEC(invltlb) #endif pushq %rax + pushq %rdx - movq %cr3, %rax /* invalidate the TLB */ - movq %rax, %cr3 - + cmpl $0,pmap_pcid_enabled + je 1f + + cmpq $0,smp_tlb_invpcid + je 1f + + /* + * For PCID-enabled pmap, set bit 63 of loaded %cr3 to zero. + */ + movq %cr3,%rax + movq $pcid_cr3,%rdx + cmpq %rax,%rdx + je 1f + movq %rdx,%cr3 + btsq $63, %rax //set bit 63. not flush the tlb when recovering + jmp 2f + + /* + * Invalidate the TLB. + */ +1: + movq %cr3,%rax +2: // if pcid is available, can we recover the old pcid with 63 bit set=A3=BF + movq %rax,%cr3 movq lapic, %rax movl $0, LA_EOI(%rax) /* End Of Interrupt to APIC */ 2. amd64/amd64/pmap.c @@ -5098,15 +5168,20 @@ pmap_activate(struct thread *td) critical_enter(); pmap =3D vmspace_pmap(td->td_proc->p_vmspace); oldpmap =3D PCPU_GET(curpmap); + CPU_ZERO(&pmap->pm_save); cpuid =3D PCPU_GET(cpuid); #ifdef SMP CPU_CLR_ATOMIC(cpuid, &oldpmap->pm_active); CPU_SET_ATOMIC(cpuid, &pmap->pm_active); + CPU_SET_ATOMIC(cpuid, &pmap->pm_save); #else CPU_CLR(cpuid, &oldpmap->pm_active); CPU_SET(cpuid, &pmap->pm_active); + CPU_SET(cpuid, &pmap->pm_active); // this should be pm_save not pm_active #endif cr3 =3D DMAP_TO_PHYS((vm_offset_t)pmap->pm_pml4); + if (pmap->pm_pcid !=3D -1) + cr3 |=3D pmap->pm_pcid; td->td_pcb->pcb_cr3 =3D cr3; load_cr3(cr3); PCPU_SET(curpmap, pmap);