0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2025-01-03 07:31:54 +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 *next;
struct linpool *lp;
uintptr_t data_align[0];
byte data[0];
};
@ -100,30 +101,29 @@ lp_alloc(linpool *m, uint size)
{
/* Too large => allocate large chunk */
c = xmalloc(sizeof(struct lp_chunk) + size);
m->total_large += size;
c->lp = m;
c->next = m->first_large;
m->total_large += size;
m->first_large = c;
}
else
{
if (m->current && m->current->next)
{
/* Still have free chunks from previous incarnation (before lp_flush()) */
c = m->current->next;
}
else
{
if (m->current)
ASSERT_DIE(!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
m->first = c;
}
m->current = c;
m->ptr = c->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;
xfree(c);
}
while (m->current && (c = m->current->next))
{
m->current->next = c->next;
free_page(c);
}
}
static void