From owner-p4-projects@FreeBSD.ORG Sun May 7 01:41:20 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9E0D416A413; Sun, 7 May 2006 01:41:20 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 628CB16A400 for ; Sun, 7 May 2006 01:41:20 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id EDAFC43D49 for ; Sun, 7 May 2006 01:41:19 +0000 (GMT) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k471fJYC024215 for ; Sun, 7 May 2006 01:41:19 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k471fJeZ024209 for perforce@freebsd.org; Sun, 7 May 2006 01:41:19 GMT (envelope-from kmacy@freebsd.org) Date: Sun, 7 May 2006 01:41:19 GMT Message-Id: <200605070141.k471fJeZ024209@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 96758 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 May 2006 01:41:20 -0000 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 #include - - 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)