PERFORCE change 96840 for review

Kip Macy kmacy at FreeBSD.org
Tue May 9 00:11:00 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=96840

Change 96840 by kmacy at kmacy_storage:sun4v_rwbuf on 2006/05/09 00:10:36

	disable interrupts entirely when updating hash bucket

Affected files ...

.. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/tte_hash.c#26 edit

Differences ...

==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/tte_hash.c#26 (text+ko) ====

@@ -142,22 +142,24 @@
 	uma_zfree(thzone, th);
 }
 
-static void
+static int
 hash_bucket_lock(tte_hash_field_t fields) 
 {
 	uint64_t data;
+	int s;
+	s = intr_disable_all();
 
-	spinlock_enter();
 	data = fields[0].tte.data & ~VTD_LOCK;
 	while (atomic_cmpset_long(&fields[0].tte.data, data, data | VTD_LOCK))
 		data = fields[0].tte.data & ~VTD_LOCK;
 
-	membar(LoadLoad);
+	membar(Sync);
+	return s;
 		
 }
 
 static __inline void
-hash_bucket_unlock_inline(tte_hash_field_t fields) 
+hash_bucket_unlock_inline(tte_hash_field_t fields, int s) 
 {
 
 	membar(StoreStore|LoadStore);
@@ -167,8 +169,8 @@
 #endif
 
 	fields[0].tte.data &= ~VTD_LOCK;
-	membar(StoreLoad);
-	spinlock_exit();
+	membar(Sync);
+	intr_restore_all(s);
 }
 
 void 
@@ -411,18 +413,19 @@
 	uint64_t hash_shift, hash_index;
 	tte_hash_field_t fields, lookup_field;
 	tte_t otte_data;
+	int s;
 
 	/* 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);
+	s = 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);
+	hash_bucket_unlock_inline(fields, s);
 
 	return (otte_data);
 }
@@ -433,6 +436,7 @@
 	uint64_t hash_shift, hash_index;
 	tte_hash_field_t fields, lookup_field, last_field;
 	tte_t tte_data;
+	int s;
 	
 	/* XXX - only handle 8K pages for now */
 
@@ -440,7 +444,7 @@
 	hash_index = (va >> hash_shift) & HASH_MASK(th);
 	fields = (th->th_hashtable[hash_index].the_fields);
 
-	hash_bucket_lock(fields);
+	s  = hash_bucket_lock(fields);
 	
 	if ((tte_data = tte_hash_lookup_inline(th, va, &lookup_field)) == 0) 
 		goto done;
@@ -459,7 +463,7 @@
 	
 	tte_hash_set_field(last_field, 0, 0);
 done:	
-	hash_bucket_unlock_inline(fields);
+	hash_bucket_unlock_inline(fields, s);
 
 	return (tte_data);
 }
@@ -471,7 +475,7 @@
 	uint64_t hash_shift, hash_index, tte_tag;
 	tte_hash_field_t fields, lookup_field;
 	tte_t otte_data;
-	
+	int s;
 
 	/* XXX - only handle 8K pages for now */
 	hash_shift = PAGE_SHIFT;
@@ -480,7 +484,7 @@
 
 	tte_tag = (((uint64_t)th->th_context << TTARGET_CTX_SHIFT)|(va >> TTARGET_VA_SHIFT));
 
-	hash_bucket_lock(fields);
+	s = hash_bucket_lock(fields);
 	otte_data = tte_hash_lookup_inline(th, va, &lookup_field);
 	if (lookup_field->tte.tag != 0)
 		lookup_field = tte_hash_allocate_fragment_entry(th, lookup_field);
@@ -491,7 +495,7 @@
 #endif
 	tte_hash_set_field(lookup_field, tte_tag, tte_data);
 
-	hash_bucket_unlock_inline(fields);
+	hash_bucket_unlock_inline(fields, s);
 	th->th_entries++;
 }
 
@@ -516,15 +520,16 @@
 	uint64_t hash_shift, hash_index;
 	tte_hash_field_t fields;
 	tte_t tte_data;
+	int s;
 	/* 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);
+	s = hash_bucket_lock(fields);
 	tte_data = tte_hash_lookup_inline(th, va, NULL);
-	hash_bucket_unlock_inline(fields);
+	hash_bucket_unlock_inline(fields, s);
 	
 	return (tte_data);
 }
@@ -567,13 +572,14 @@
 	tte_hash_field_t fields, lookup_field;
 	tte_t otte_data;
 	uint64_t tag;
+	int s;
 
 	/* 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);
+	s = hash_bucket_lock(fields);
 	otte_data = tte_hash_lookup_inline(th, va, &lookup_field);
 	if (otte_data == 0 && lookup_field->tte.tag != 0)
 		lookup_field = tte_hash_allocate_fragment_entry(th, lookup_field);
@@ -582,7 +588,7 @@
 	
 	tte_hash_set_field(lookup_field, tag, tte_data);
 
-	hash_bucket_unlock_inline(fields);
+	hash_bucket_unlock_inline(fields, s);
 
 	if (otte_data == 0)
 		th->th_entries++;


More information about the p4-projects mailing list