0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-03-21 22:07:03 +00:00

Linpool flushes unused pages even on lp_restore()

This commit is contained in:
Maria Matejka 2023-04-28 12:32:41 +02:00
parent 91471531a1
commit 010c26c296

View File

@ -27,6 +27,7 @@
struct lp_chunk { struct lp_chunk {
struct lp_chunk *next; struct lp_chunk *next;
struct linpool *lp;
uintptr_t data_align[0]; uintptr_t data_align[0];
byte data[0]; byte data[0];
}; };
@ -100,30 +101,29 @@ lp_alloc(linpool *m, uint size)
{ {
/* Too large => allocate large chunk */ /* Too large => allocate large chunk */
c = xmalloc(sizeof(struct lp_chunk) + size); c = xmalloc(sizeof(struct lp_chunk) + size);
m->total_large += size; c->lp = m;
c->next = m->first_large; c->next = m->first_large;
m->total_large += size;
m->first_large = c; m->first_large = c;
} }
else else
{ {
if (m->current && m->current->next) if (m->current)
{ ASSERT_DIE(!m->current->next);
/* Still have free chunks from previous incarnation (before lp_flush()) */
c = m->current->next; /* Need to allocate a new chunk */
} c = alloc_page();
m->total += LP_DATA_SIZE;
c->next = NULL;
c->lp = m;
if (m->current)
m->current->next = c;
else else
{ m->first = c;
/* Need to allocate a new chunk */
c = alloc_page();
m->total += LP_DATA_SIZE;
c->next = NULL;
if (m->current)
m->current->next = c;
else
m->first = c;
}
m->current = c; m->current = c;
m->ptr = c->data + size; m->ptr = c->data + size;
m->end = c->data + LP_DATA_SIZE; m->end = c->data + LP_DATA_SIZE;
@ -248,6 +248,12 @@ lp_restore(linpool *m, lp_state *p)
m->first_large = c->next; m->first_large = c->next;
xfree(c); xfree(c);
} }
while (m->current && (c = m->current->next))
{
m->current->next = c->next;
free_page(c);
}
} }
static void static void