From owner-svn-src-all@freebsd.org Sun Aug 16 16:57:21 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B6D829BBE02; Sun, 16 Aug 2015 16:57:21 +0000 (UTC) (envelope-from alc@rice.edu) Received: from pp2.rice.edu (proofpoint2.mail.rice.edu [128.42.201.101]) (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 85054185E; Sun, 16 Aug 2015 16:57:20 +0000 (UTC) (envelope-from alc@rice.edu) Received: from pps.filterd (pp2.rice.edu [127.0.0.1]) by pp2.rice.edu (8.15.0.59/8.15.0.59) with SMTP id t7GGtg2o012503; Sun, 16 Aug 2015 11:57:18 -0500 Received: from mh3.mail.rice.edu (mh3.mail.rice.edu [128.42.199.10]) by pp2.rice.edu with ESMTP id 1wa0ffrbnx-1; Sun, 16 Aug 2015 11:57:18 -0500 X-Virus-Scanned: by amavis-2.7.0 at mh3.mail.rice.edu, auth channel Received: from 108-254-203-201.lightspeed.hstntx.sbcglobal.net (108-254-203-201.lightspeed.hstntx.sbcglobal.net [108.254.203.201]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) (Authenticated sender: alc) by mh3.mail.rice.edu (Postfix) with ESMTPSA id 046B44044B; Sun, 16 Aug 2015 11:57:17 -0500 (CDT) Message-ID: <55D0C0ED.807@rice.edu> Date: Sun, 16 Aug 2015 11:57:17 -0500 From: Alan Cox User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Konstantin Belousov , Roger Pau Monn?? CC: Jason Harmening , "Jason A. Harmening" , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r286787 - head/sys/x86/x86 References: <201508142008.t7EK8Hkt037329@repo.freebsd.org> <55CF390F.5010407@FreeBSD.org> <55CF5B13.1040501@gmail.com> <55D046F5.60601@FreeBSD.org> <20150816090358.GW2072@kib.kiev.ua> <20150816095004.GX2072@kib.kiev.ua> In-Reply-To: <20150816095004.GX2072@kib.kiev.ua> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 kscore.is_bulkscore=0 kscore.compositescore=1 compositescore=0.9 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 kscore.is_spamscore=0 rbsscore=0.9 spamscore=0 urlsuspectscore=0.9 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1507310000 definitions=main-1508160309 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: Sun, 16 Aug 2015 16:57:21 -0000 On 08/16/2015 04:50, Konstantin Belousov wrote: > On Sun, Aug 16, 2015 at 12:03:58PM +0300, Konstantin Belousov wrote: >> On Sun, Aug 16, 2015 at 10:16:53AM +0200, Roger Pau Monn?? wrote: >>> pmap_map_io_transient contains some of this logic, but it uses >>> vmem_alloc (with M_WAITOK) instead of a pcpu pageframe, which defeats >>> part of the purpose of this change and cannot be used as-is. >> This logic can be repeated, but it is probably too much for the purpose. >> It would be enough to have single frame (we cannot reuse CMAP1), >> protected by a spin mutex. I do not see much sense in providing >> optimized per-cpu frames for this case. > Like this. I only compiled the patch. > > diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c > index 1e64fc8..9d2b2d9 100644 > --- a/sys/amd64/amd64/pmap.c > +++ b/sys/amd64/amd64/pmap.c > @@ -390,6 +390,8 @@ static struct md_page *pv_table; > */ > pt_entry_t *CMAP1 = 0; > caddr_t CADDR1 = 0; > +static vm_offset_t qframe = 0; > +static struct mtx qframe_mtx; > > static int pmap_flags = PMAP_PDE_SUPERPAGE; /* flags for x86 pmaps */ > > @@ -1031,7 +1033,7 @@ pmap_init(void) > struct pmap_preinit_mapping *ppim; > vm_page_t mpte; > vm_size_t s; > - int i, pv_npg; > + int error, i, pv_npg; > > /* > * Initialize the vm page array entries for the kernel pmap's > @@ -1112,6 +1114,12 @@ pmap_init(void) > printf("PPIM %u: PA=%#lx, VA=%#lx, size=%#lx, mode=%#x\n", i, > ppim->pa, ppim->va, ppim->sz, ppim->mode); > } > + > + mtx_init(&qframe_mtx, "qfrmlk", NULL, MTX_SPIN); > + error = vmem_alloc(kernel_arena, PAGE_SIZE, M_BESTFIT | M_WAITOK, > + (vmem_addr_t *)&qframe); > + if (error != 0) > + panic("qframe allocation failed"); > } > > static SYSCTL_NODE(_vm_pmap, OID_AUTO, pde, CTLFLAG_RD, 0, > @@ -7019,13 +7027,28 @@ pmap_unmap_io_transient(vm_page_t page[], vm_offset_t vaddr[], int count, > vm_offset_t > pmap_quick_enter_page(vm_page_t m) > { > + vm_paddr_t paddr; > > - return (PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m))); > + paddr = VM_PAGE_TO_PHYS(m); > + if (paddr < dmaplimit) > + return (PHYS_TO_DMAP(paddr)); > + mtx_lock_spin(&qframe_mtx); > + KASSERT(*vtopte(qframe) == 0, ("qframe busy")); > + pte_store(vtopte(qframe), paddr | X86_PG_RW | X86_PG_V | X86_PG_A | > + X86_PG_M | pmap_cache_bits(kernel_pmap, m->md.pat_mode, 0)); > + invlpg(qframe); This invlpg is unnecessary. > + return (qframe); > } > > void > pmap_quick_remove_page(vm_offset_t addr) > { > + > + if (addr != qframe) > + return; > + pte_store(vtopte(qframe), 0); > + invlpg(qframe); > + mtx_unlock_spin(&qframe_mtx); > } > > #include "opt_ddb.h" > >