eal/bsd: don't zero the pages during mmap in contigmem
PATCH 1/1 eal/bsd: don't zero the pages during mmap in contigmem
Don't zero the pages during mmap in contigmem. Instead, zero the pages after mmap in primary process. Otherwise, the multi-process support will be broken, as the pages will be zeroed when secondary processes map the memory.
--- lib/librte_eal/bsdapp/contigmem/contigmem.c | 1 - lib/librte_eal/bsdapp/eal/eal_memory.c | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-)
lib/librte_eal/bsdapp/contigmem/contigmem.c +0 -1
@@ -227,7 +227,6 @@ contigmem_mmap_single(struct cdev *cdev, vm_ooffset_t *offset, vm_size_t size,if (buffer_index >= contigmem_num_buffers)return EINVAL ; -memset (contigmem_buffers[buffer_index],0 , contigmem_buffer_size); *offset = (vm_ooffset_t )vtophys (contigmem_buffers[buffer_index]); *obj =vm_pager_allocate (OBJT_DEVICE , cdev, size, nprot, *offset, curthread->td_ucred);
lib/librte_eal/bsdapp/eal/eal_memory.c +3 -0
@@ -36,6 +36,7 @@#include <sys/sysctl.h> #include <inttypes.h> #include <fcntl.h> +#include <string.h> #include <rte_eal.h> #include <rte_eal_memconfig.h>
@@ -121,6 +122,8 @@ rte_eal_hugepage_init(void) seg->nrank = mcfg->nrank; seg->socket_id =0 ; +memset (seg->addr,0 , seg->len); +RTE_LOG (INFO ,EAL ,"Mapped memory segment %u @ %p: physaddr:0x%" PRIx64", len %zu\n" , seg_idx, addr, physaddr, hpi->hugepage_sz);
Signature · 1 line
2.12.1
Quoted 10 lines · Tiwei Bie
Don't zero the pages during mmap in contigmem. Instead, zero the pages after mmap in primary process. Otherwise, the multi-process support will be broken, as the pages will be zeroed when secondary processes map the memory.
Fixes 82f931805506 ("contigmem: zero all pages during mmap")Signed-off-by Tiwei Bie <[email protected]>---
I agree there is a problem here, but I'm not sure about the solution to it. I still think that the kernel should zero the pages before they get given to userspace. Is there any way to keep that working e.g
* have them zeroed on mmap only when they are not already mmaped into another process?
* have them zeroed on init, and again on unmap by the last process to have them mapped?
/Bruce
Quoted 11 lines · Bruce Richardson
Quoted 10 lines · Tiwei Bie
Don't zero the pages during mmap in contigmem. Instead, zero the pages after mmap in primary process. Otherwise, the multi-process support will be broken, as the pages will be zeroed when secondary processes map the memory.
Fixes 82f931805506 ("contigmem: zero all pages during mmap")Signed-off-by Tiwei Bie <[email protected]>---
Quoted 9 lines
I agree there is a problem here, but I'm not sure about the solution to it. I still think that the kernel should zero the pages before they get given to userspace. Is there any way to keep that working e.g
* have them zeroed on mmap only when they are not already mmaped into another process?
* have them zeroed on init, and again on unmap by the last process to have them mapped?
I think it's the simplest way to fix it in userspace, so I just did it. I'd like to fix it in kernel if you also prefer this.
Best regards,
Tiwei Bie