PERFORCE change 96747 for review
Kip Macy
kmacy at FreeBSD.org
Sat May 6 20:11:39 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=96747
Change 96747 by kmacy at kmacy_storage:sun4v_rwbuf on 2006/05/06 20:11:36
fix tte_hash_lookup_last_inline
generalize number of hash entries
Affected files ...
.. //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/tte_hash.c#23 edit
Differences ...
==== //depot/projects/kmacy_sun4v/src/sys/sun4v/sun4v/tte_hash.c#23 (text+ko) ====
@@ -62,10 +62,11 @@
#define MAX_HASH_SIZE 16
#define HASH_MASK(th) ((th->th_size << (PAGE_SHIFT - THE_SHIFT)) - 1)
#define HASH_VALID 0x1
+#define HASH_ENTRIES 4
+#define NULL_TAG 0
-
struct tte_hash_entry;
#define MAX_FRAGMENT_ENTRIES ((PAGE_SIZE / sizeof(struct tte_hash_entry)) - 1)
@@ -83,7 +84,7 @@
typedef struct tte_hash_entry {
- tte_hash_field the_fields[4];
+ tte_hash_field the_fields[HASH_ENTRIES];
} *tte_hash_entry_t;
@@ -338,20 +339,23 @@
entry = 0;
retry:
- for (i = 0; i < 4 && fields[i].tte.tag != 0; i++) {
+ for (i = 0; i < HASH_ENTRIES && fields[i].tte.tag != 0; i++) {
if (((fields[i].tte.tag << TTARGET_VA_SHIFT) == (va & ~PAGE_MASK_4M))) {
entry = (fields[i].tte.data & ~VTD_LOCK);
break;
}
}
- if (i == 4) {
- if (fields[3].of.flags & TH_COLLISION) {
- fields = fields[3].of.next;
+ if (i == HASH_ENTRIES) {
+ if (fields[(HASH_ENTRIES - 1)].of.flags & TH_COLLISION) {
+ fields = fields[(HASH_ENTRIES - 1)].of.next;
goto retry;
}
- i = 3;
+ i = (HASH_ENTRIES - 1);
}
+ if (i >= HASH_ENTRIES)
+ panic("invalid state");
+
if (field)
*field = &fields[i];
@@ -364,33 +368,40 @@
{
uint64_t hash_shift, hash_index;
tte_hash_field_t fields;
- int i;
+ int i, index;
/* 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);
+ index = -1;;
+
retry:
- for (i = 0; i < 4 && fields[i + 1].tte.tag != 0; i++)
- ;
+ for (i = 0; i < (HASH_ENTRIES - 1); i++)
+ if (fields[i + 1].tte.tag == 0) {
+ index = i;
+ break;
+ }
- if (i == 4) {
- if (fields[3].of.flags & TH_COLLISION) {
- if (fields[3].of.next[0].tte.tag != 0) {
- fields = fields[3].of.next;
+ if (index != -1)
+ *field = &fields[index];
+ else {
+ if (fields[(HASH_ENTRIES - 1)].of.flags & TH_COLLISION) {
+ if (fields[(HASH_ENTRIES - 1)].of.next[0].tte.tag != 0) {
+ fields = fields[(HASH_ENTRIES - 1)].of.next;
goto retry;
} else {
/* 3rd entry is last */
- *field = &fields[2];
+ *field = &fields[(HASH_ENTRIES - 2)];
/* clear collision pointer */
- tte_hash_set_field(&fields[3], 0, 0);
+ tte_hash_set_field(&fields[(HASH_ENTRIES - 1)], 0, 0);
}
} else
- *field = &fields[3]; /* 4th is the last entry */
- } else
- *field = &fields[i];
+ *field = &fields[(HASH_ENTRIES - 1)]; /* last in bucket */
+ }
+
}
More information about the p4-projects
mailing list