Skip to content

Commit

Permalink
u3: adds free-list migration to account for new bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
joemfb committed Oct 11, 2023
1 parent f2436a6 commit a1d23ce
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
63 changes: 63 additions & 0 deletions pkg/noun/allocate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2318,6 +2318,69 @@ u3a_idle(u3a_road* rod_u)
return fre_w;
}

/* u3a_ream(): ream free-lists.
*/
void
u3a_ream(void)
{
u3p(u3a_fbox) lit_p;
u3a_fbox* fox_u;
c3_w sel_w, i_w;

for ( i_w = 0; i_w < u3a_fbox_no; i_w++ ) {
lit_p = u3R->all.fre_p[i_w];

while ( lit_p ) {
fox_u = u3to(u3a_fbox, lit_p);
lit_p = fox_u->nex_p;
sel_w = _box_slot(fox_u->box_u.siz_w);

if ( sel_w != i_w ) {
// inlined _box_detach()
//
{
u3p(u3a_fbox) fre_p = u3of(u3a_fbox, &(fox_u->box_u));
u3p(u3a_fbox) pre_p = u3to(u3a_fbox, fre_p)->pre_p;
u3p(u3a_fbox) nex_p = u3to(u3a_fbox, fre_p)->nex_p;

if ( nex_p ) {
if ( u3to(u3a_fbox, nex_p)->pre_p != fre_p ) {
u3_assert(!"loom: corrupt");
}
u3to(u3a_fbox, nex_p)->pre_p = pre_p;
}
if ( pre_p ) {
if( u3to(u3a_fbox, pre_p)->nex_p != fre_p ) {
u3_assert(!"loom: corrupt");
}
u3to(u3a_fbox, pre_p)->nex_p = nex_p;
}
else {
if ( fre_p != u3R->all.fre_p[i_w] ) {
u3_assert(!"loom: corrupt");
}
u3R->all.fre_p[i_w] = nex_p;
}
}

// inlined _box_attach()
{
u3p(u3a_fbox) fre_p = u3of(u3a_fbox, &(fox_u->box_u));
u3p(u3a_fbox)* pfr_p = &u3R->all.fre_p[sel_w];
u3p(u3a_fbox) nex_p = *pfr_p;

u3to(u3a_fbox, fre_p)->pre_p = 0;
u3to(u3a_fbox, fre_p)->nex_p = nex_p;
if ( nex_p ) {
u3to(u3a_fbox, nex_p)->pre_p = fre_p;
}
(*pfr_p) = fre_p;
}
}
}
}
}

/* u3a_sweep(): sweep a fully marked road.
*/
c3_w
Expand Down
5 changes: 5 additions & 0 deletions pkg/noun/allocate.h
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,11 @@
c3_w
u3a_idle(u3a_road* rod_u);

/* u3a_ream(): ream free-lists.
*/
void
u3a_ream(void);

/* u3a_sweep(): sweep a fully marked road.
*/
c3_w
Expand Down
4 changes: 4 additions & 0 deletions pkg/noun/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,10 @@ _find_home(void)
}
}

// XX move me
//
u3a_ream();

/* As a further guard against any sneaky loom corruption */
u3a_loom_sane();

Expand Down

0 comments on commit a1d23ce

Please sign in to comment.