[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 6/6] libpager: Use libc heap for pagemap
From: |
Samuel Thibault |
Subject: |
Re: [PATCH 6/6] libpager: Use libc heap for pagemap |
Date: |
Fri, 7 May 2021 11:33:24 +0200 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
Sergey Bugaev, le ven. 07 mai 2021 12:26:39 +0300, a ecrit:
> On Thu, May 6, 2021 at 3:56 PM Sergey Bugaev <bugaevc@gmail.com> wrote:
> > - newaddr = mmap (0, newsize * sizeof (*p->pagemap),
> > - PROT_READ|PROT_WRITE, MAP_ANON, 0, 0);
> > + void *newaddr = reallocarray (p->pagemap, off,
> > + sizeof (*p->pagemap));
>
> It seems while fixing preexisting issues I accidentally introduces a
> new one. Unlike mmap, reallocarray does not zero-initialize the newly
> allocated memory; but other code expects new pagemap entries to be set
> to zero. This is the cause of those tarfs hangs I've been seeing
> lately.
>
> I'm sorry, and here's a hotfix.
Applied, thanks!
> Sergey
>
> -- >8 --
> Subject: [PATCH] libpager: Properly zero-initialize pagemap
>
> Unlike mmap () and calloc (), reallocarray () does not automatically
> zero-fill the newly allocated memory. Do so explicitly.
> ---
> libpager/pagemap.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/libpager/pagemap.c b/libpager/pagemap.c
> index 7bbb8c56..c7c86d60 100644
> --- a/libpager/pagemap.c
> +++ b/libpager/pagemap.c
> @@ -32,6 +32,8 @@ _pager_pagemap_resize (struct pager *p, vm_address_t off)
> if (!newaddr)
> return errno;
>
> + memset ((short *) newaddr + p->pagemapsize, 0,
> + (off - p->pagemapsize) * sizeof (*p->pagemap));
> p->pagemap = newaddr;
> p->pagemapsize = off;
> }
> --
> 2.31.1
>
- [PATCH 0/6] Various libpager fixes, Sergey Bugaev, 2021/05/06
- [PATCH 1/6] libpager: Fix mixing up success and error, Sergey Bugaev, 2021/05/06
- [PATCH 2/6] libpager: Do not flush in-core pages on offer, Sergey Bugaev, 2021/05/06
- [PATCH 4/6] libpager: Store pagemapsize as vm_size_t, Sergey Bugaev, 2021/05/06
- [PATCH 6/6] libpager: Use libc heap for pagemap, Sergey Bugaev, 2021/05/06
- [PATCH 3/6] libpager: Add error handling to various functions, Sergey Bugaev, 2021/05/06
- [PATCH 5/6] libpager: Fix overallocating pagemap, Sergey Bugaev, 2021/05/06
- And another patch..., Sergey Bugaev, 2021/05/06