From owner-svn-src-all@FreeBSD.ORG Thu Jul 23 19:43:24 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 758B31065670; Thu, 23 Jul 2009 19:43:24 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 637698FC22; Thu, 23 Jul 2009 19:43:24 +0000 (UTC) (envelope-from alc@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n6NJhNgj087505; Thu, 23 Jul 2009 19:43:23 GMT (envelope-from alc@svn.freebsd.org) Received: (from alc@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n6NJhN3m087504; Thu, 23 Jul 2009 19:43:23 GMT (envelope-from alc@svn.freebsd.org) Message-Id: <200907231943.n6NJhN3m087504@svn.freebsd.org> From: Alan Cox Date: Thu, 23 Jul 2009 19:43:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r195836 - head/sys/i386/i386 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Thu, 23 Jul 2009 19:43:25 -0000 Author: alc Date: Thu Jul 23 19:43:23 2009 New Revision: 195836 URL: http://svn.freebsd.org/changeset/base/195836 Log: Eliminate unnecessary cache and TLB flushes by pmap_change_attr(). (This optimization was implemented in the amd64 version roughly 1 year ago.) Approved by: re (kensmith) Modified: head/sys/i386/i386/pmap.c Modified: head/sys/i386/i386/pmap.c ============================================================================== --- head/sys/i386/i386/pmap.c Thu Jul 23 19:03:04 2009 (r195835) +++ head/sys/i386/i386/pmap.c Thu Jul 23 19:43:23 2009 (r195836) @@ -4482,6 +4482,7 @@ pmap_change_attr(vm_offset_t va, vm_size pt_entry_t *pte; u_int opte, npte; pd_entry_t *pde; + boolean_t changed; base = trunc_page(va); offset = va & PAGE_MASK; @@ -4505,6 +4506,8 @@ pmap_change_attr(vm_offset_t va, vm_size return (EINVAL); } + changed = FALSE; + /* * Ok, all the pages exist and are 4k, so run through them updating * their cache mode. @@ -4522,6 +4525,8 @@ pmap_change_attr(vm_offset_t va, vm_size npte |= pmap_cache_bits(mode, 0); } while (npte != opte && !atomic_cmpset_int((u_int *)pte, opte, npte)); + if (npte != opte) + changed = TRUE; tmpva += PAGE_SIZE; size -= PAGE_SIZE; } @@ -4530,10 +4535,12 @@ pmap_change_attr(vm_offset_t va, vm_size * Flush CPU caches to make sure any data isn't cached that shouldn't * be, etc. */ - pmap_invalidate_range(kernel_pmap, base, tmpva); - /* If "Self Snoop" is supported, do nothing. */ - if (!(cpu_feature & CPUID_SS)) - pmap_invalidate_cache(); + if (changed) { + pmap_invalidate_range(kernel_pmap, base, tmpva); + /* If "Self Snoop" is supported, do nothing. */ + if (!(cpu_feature & CPUID_SS)) + pmap_invalidate_cache(); + } return (0); }