Skip to content

Commit

Permalink
Revert "subr_pctrie: use ilog2(x) instead of fls(x)-1"
Browse files Browse the repository at this point in the history
This reverts commit 574ef65.
  • Loading branch information
Doug Moore authored and Doug Moore committed Jun 3, 2024
1 parent 574ef65 commit e3537f9
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 104 deletions.
6 changes: 3 additions & 3 deletions sys/kern/subr_pctrie.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ pctrie_insert_node(void *parentp, struct pctrie_node *parent, uint64_t *val)
"uint64 too wide");
_Static_assert(sizeof(uint64_t) * NBBY <=
(1 << (sizeof(parent->pn_clev) * NBBY)), "pn_clev too narrow");
parent->pn_clev = rounddown(ilog2(index ^ newind), PCTRIE_WIDTH);
parent->pn_clev = rounddown(flsll(index ^ newind) - 1, PCTRIE_WIDTH);
parent->pn_owner = PCTRIE_COUNT;
parent->pn_owner = index & -(parent->pn_owner << parent->pn_clev);

Expand Down Expand Up @@ -546,14 +546,14 @@ pctrie_lookup_le(struct pctrie *ptree, uint64_t index)
KASSERT((pred->pn_popmap & ((1 << slot) - 1)) != 0,
("%s: no popmap siblings before slot %d in node %p",
__func__, slot, pred));
slot = ilog2(pred->pn_popmap & ((1 << slot) - 1));
slot = fls(pred->pn_popmap & ((1 << slot) - 1)) - 1;
pred = pctrie_node_load(&pred->pn_child[slot], NULL,
PCTRIE_LOCKED);
}
while (!pctrie_isleaf(pred)) {
KASSERT(pred->pn_popmap != 0,
("%s: no popmap children in node %p", __func__, pred));
slot = ilog2(pred->pn_popmap);
slot = fls(pred->pn_popmap) - 1;
pred = pctrie_node_load(&pred->pn_child[slot], NULL,
PCTRIE_LOCKED);
}
Expand Down
4 changes: 1 addition & 3 deletions sys/vm/_vm_phys.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ struct vm_freelist {
int lcnt;
};

typedef struct vm_freelist vm_freelist_tbl[VM_NFREEPOOL][VM_NFREEORDER_MAX];

struct vm_phys_seg {
vm_paddr_t start;
vm_paddr_t end;
Expand All @@ -64,7 +62,7 @@ struct vm_phys_seg {
void *md_first;
#endif
int domain;
vm_freelist_tbl *free_queues;
struct vm_freelist (*free_queues)[VM_NFREEPOOL][VM_NFREEORDER_MAX];
};

extern struct vm_phys_seg vm_phys_segs[];
Expand Down
5 changes: 2 additions & 3 deletions sys/vm/vm_page.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ vm_page_init_page(vm_page_t m, vm_paddr_t pa, int segind)
m->psind = 0;
m->segind = segind;
m->order = VM_NFREEORDER;
m->pool = VM_NFREEPOOL;
m->pool = VM_FREEPOOL_DEFAULT;
m->valid = m->dirty = 0;
pmap_page_init(m);
}
Expand Down Expand Up @@ -785,8 +785,7 @@ vm_page_startup(vm_offset_t vaddr)
m = seg->first_page + atop(startp - seg->start);
vmd = VM_DOMAIN(seg->domain);
vm_domain_free_lock(vmd);
vm_phys_enqueue_contig(m, VM_FREEPOOL_DEFAULT,
pagecount);
vm_phys_enqueue_contig(m, pagecount);
vm_domain_free_unlock(vmd);
vm_domain_freecnt_inc(vmd, pagecount);
vm_cnt.v_page_count += (u_int)pagecount;
Expand Down
Loading

0 comments on commit e3537f9

Please sign in to comment.