The code tried to round up the allocation size to a multiple of page size. But we actually allocate newsize * sizeof (*p->pagemap) bytes, not newsize bytes, which meant allocations were sizeof (*p->pagemap) times larger than they needed to be. --- libpager/pagemap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/libpager/pagemap.c b/libpager/pagemap.c index 63c5f44d..1570c75b 100644 --- a/libpager/pagemap.c +++ b/libpager/pagemap.c @@ -17,21 +17,22 @@ #include "priv.h" #include <string.h> - + /* Grow the pagemap of pager P as necessary to deal with address OFF */ error_t _pager_pagemap_resize (struct pager *p, vm_address_t off) { error_t err = 0; - + off /= __vm_page_size; if (p->pagemapsize < off) { void *newaddr; - vm_size_t newsize = round_page (off); + vm_size_t newsize = round_page (off * sizeof (*p->pagemap)) + / sizeof (*p->pagemap); - newaddr = mmap (0, newsize * sizeof (*p->pagemap), + newaddr = mmap (0, newsize * sizeof (*p->pagemap), PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); err = (newaddr == (void *) -1) ? errno : 0; if (! err) -- 2.31.1