Date: Thu, 23 Jul 2009 19:43:23 +0000 (UTC) From: Alan Cox <alc@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r195836 - head/sys/i386/i386 Message-ID: <200907231943.n6NJhN3m087504@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907231943.n6NJhN3m087504>