Date: Sun, 7 May 2006 01:41:19 GMT From: Kip Macy <kmacy@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 96758 for review Message-ID: <200605070141.k471fJeZ024209@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=96758 Change 96758 by kmacy@kmacy_storage:sun4v_rwbuf on 2006/05/07 01:41:12 close some races in bit clearing by adding new routine to atomically lookup a tte and clear bits on it Affected files ... .. //depot/projects/kmacy_sun4v/src/sys/sun4v/include/tte_hash.h#14 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/tte.c#8 edit .. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/tte_hash.c#24 edit Differences ... ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/include/tte_hash.h#14 (text+ko) ==== @@ -12,6 +12,8 @@ void tte_hash_clear(tte_hash_t hash); +tte_t tte_hash_clear_bits(tte_hash_t hash, vm_offset_t va, uint64_t flags); + tte_hash_t tte_hash_kernel_create(vm_offset_t, uint64_t); tte_hash_t tte_hash_create(uint64_t context, uint64_t *scratchval); ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/tte.c#8 (text+ko) ==== @@ -51,8 +51,6 @@ #include <machine/cpu.h> #include <machine/tte_hash.h> - - void tte_clear_phys_bit(vm_page_t m, uint64_t flags) { @@ -68,24 +66,18 @@ * setting RO do we need to clear the VAC? */ TAILQ_FOREACH(pv, &m->md.pv_list, pv_list) { - tte_t otte_data, tte_data; + tte_t otte_data; /* * don't write protect pager mappings */ if (flags == VTD_SW_W) { if (!pmap_track_modified(pv->pv_pmap, pv->pv_va)) continue; + flags = (VTD_SW_W|VTD_W); } - otte_data = tte_hash_lookup(pv->pv_pmap->pm_hash, pv->pv_va); + otte_data = tte_hash_clear_bits(pv->pv_pmap->pm_hash, pv->pv_va, flags); if (otte_data & flags) { - if (flags == VTD_SW_W) { - tte_data = otte_data & ~(VTD_SW_W | VTD_W); - } else { - tte_data = otte_data & ~flags; - } - otte_data = tte_hash_update(pv->pv_pmap->pm_hash, pv->pv_va, tte_data); - if (otte_data & VTD_W) vm_page_dirty(m); @@ -94,17 +86,11 @@ } - if (flags == VTD_SW_W) + if (flags & VTD_SW_W) vm_page_flag_clear(m, PG_WRITEABLE); sched_unpin(); } -void -tte_set_phys_bit(vm_page_t m, uint64_t flags) -{ - UNIMPLEMENTED; -} - boolean_t tte_get_phys_bit(vm_page_t m, uint64_t flags) { @@ -115,14 +101,18 @@ void tte_clear_virt_bit(struct pmap *pmap, vm_offset_t va, uint64_t flags) { - tte_t tte_data; + tte_t otte_data; + + if (flags == VTD_SW_W) { + if (!pmap_track_modified(pmap, va)) + return; + flags = (VTD_SW_W|VTD_W); + } - tte_data = tte_hash_lookup(pmap->pm_hash, va); + otte_data = tte_hash_clear_bits(pmap->pm_hash, va, flags); - if (tte_data) { - tte_hash_update(pmap->pm_hash, va, tte_data & ~flags); + if (otte_data & flags) pmap_invalidate_page(pmap, va); - } } void ==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/tte_hash.c#24 (text+ko) ==== @@ -404,6 +404,27 @@ } +tte_t +tte_hash_clear_bits(tte_hash_t th, vm_offset_t va, uint64_t flags) +{ + uint64_t hash_shift, hash_index; + tte_hash_field_t fields, lookup_field; + tte_t otte_data; + + /* XXX - only handle 8K pages for now */ + hash_shift = PAGE_SHIFT; + hash_index = (va >> hash_shift) & HASH_MASK(th); + fields = (th->th_hashtable[hash_index].the_fields); + + hash_bucket_lock(fields); + if((otte_data = tte_hash_lookup_inline(th, va, &lookup_field)) != 0) + tte_hash_set_field(lookup_field, lookup_field->tte.tag, + lookup_field->tte.data & ~flags); + + hash_bucket_unlock_inline(fields); + + return (otte_data); +} tte_t tte_hash_delete(tte_hash_t th, vm_offset_t va)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200605070141.k471fJeZ024209>