PERFORCE change 101679 for review
Kip Macy
kmacy at FreeBSD.org
Sun Jul 16 04:06:21 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=101679
Change 101679 by kmacy at kmacy_storage:sun4v_work_stable on 2006/07/16 04:05:43
make sure that a fragment page is allocated for the kernel hash table
Affected files ...
.. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/include/tte_hash.h#2 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/sun4v/pmap.c#9 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/sun4v/tte_hash.c#3 edit
Differences ...
==== //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/include/tte_hash.h#2 (text+ko) ====
@@ -19,7 +19,7 @@
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_kernel_create(vm_offset_t, uint64_t, vm_paddr_t);
tte_hash_t tte_hash_create(uint64_t context, uint64_t *scratchval);
==== //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/sun4v/pmap.c#9 (text+ko) ====
@@ -756,7 +756,7 @@
* This could happen earlier - but I put it here to avoid
* attempts to do updates until they're legal
*/
- pm->pm_hash = tte_hash_kernel_create(TLB_PHYS_TO_DIRECT(kernel_hash_pa), kernel_hash_size);
+ pm->pm_hash = tte_hash_kernel_create(TLB_PHYS_TO_DIRECT(kernel_hash_pa), kernel_hash_size, pmap_bootstrap_alloc(PAGE_SIZE));
pm->pm_hashscratch = tte_hash_set_scratchpad_kernel(pm->pm_hash);
for (i = 0; i < translations_size; i++) {
==== //depot/projects/kmacy_sun4v_stable/src/sys/sun4v/sun4v/tte_hash.c#3 (text+ko) ====
@@ -150,7 +150,7 @@
}
tte_hash_t
-tte_hash_kernel_create(vm_offset_t va, uint64_t size)
+tte_hash_kernel_create(vm_offset_t va, uint64_t size, vm_paddr_t fragment_page)
{
tte_hash_t th;
@@ -159,17 +159,40 @@
th->th_entries = 0;
th->th_context = 0;
th->th_hashtable = (tte_hash_entry_t)va;
-
+ th->th_fhtail = th->th_fhhead = (void *)TLB_PHYS_TO_DIRECT(fragment_page);
+
return th;
}
+static inline vm_page_t
+alloc_zeroed_page(void)
+{
+ vm_page_t m;
+ static int color;
+
+ m = NULL;
+
+ while (m == NULL) {
+ m = vm_page_alloc(NULL, color++,
+ VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED |
+ VM_ALLOC_ZERO);
+
+ if (m == NULL)
+ VM_WAIT;
+ }
+
+ if ((m->flags & PG_ZERO) == 0)
+ pmap_zero_page(m);
+
+ return (m);
+}
+
tte_hash_t
tte_hash_create(uint64_t context, uint64_t *scratchval)
{
tte_hash_t th;
vm_page_t m, tm;
int i;
- static int color;
th = get_tte_hash();
@@ -191,20 +214,11 @@
pmap_zero_page(tm);
th->th_hashtable = (void *)TLB_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(m));
- m = NULL;
- while (m == NULL) {
- m = vm_page_alloc(NULL, color++,
- VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED |
- VM_ALLOC_ZERO);
+ m = alloc_zeroed_page();
- if (m == NULL)
- VM_WAIT;
- }
- if ((m->flags & PG_ZERO) == 0)
- pmap_zero_page(m);
-
th->th_fhtail = th->th_fhhead = (void *)TLB_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(m));
+ KASSERT(th->th_fhtail != NULL, ("th->th_fhtail == NULL"));
*scratchval = (uint64_t)((vm_offset_t)th->th_hashtable) | ((vm_offset_t)th->th_size);
@@ -273,30 +287,17 @@
struct tte_hash_fragment *fh;
tte_hash_entry_t newentry;
vm_page_t m;
- static int color;
-
+
fh = th->th_fhtail;
if (fh->thf_head.fh_free_head == MAX_FRAGMENT_ENTRIES) {
- m = NULL;
- while (m == NULL) {
- m = vm_page_alloc(NULL, color++,
- VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED |
- VM_ALLOC_ZERO);
-
- if (m == NULL)
- VM_WAIT;
- }
+ m = alloc_zeroed_page();
- if ((m->flags & PG_ZERO) == 0)
- pmap_zero_page(m);
-
fh->thf_head.fh_next = (void *)TLB_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(m));
fh = th->th_fhtail = (void *)TLB_PHYS_TO_DIRECT(VM_PAGE_TO_PHYS(m));
fh->thf_head.fh_free_head = 1;
#ifdef NOISY_DEBUG
printf("new fh=%p \n", fh);
#endif
-
}
newentry = &fh->thf_entries[fh->thf_head.fh_free_head];
More information about the p4-projects
mailing list