> -----Original Message----- > From: lng-odp-boun...@lists.linaro.org [mailto:lng-odp- > boun...@lists.linaro.org] On Behalf Of ext Maxim Uvarov > Sent: Thursday, January 22, 2015 5:01 PM > To: lng-odp@lists.linaro.org > Subject: [lng-odp] [PATCH] linux-generic: shm fix unmap for hugepages > > In case of hugepages unmap has to be done with address aligned to > page size. Also unmap() has to be done for address returned by mmap(), > not for aligned address after that. > > To reproduce original bug run: > echo 4096 > /proc/sys/vm/nr_hugepages > make check > > Signed-off-by: Maxim Uvarov <maxim.uva...@linaro.org> > --- > platform/linux-generic/odp_shared_memory.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux- > generic/odp_shared_memory.c > index 99c5b40..51eba02 100644 > --- a/platform/linux-generic/odp_shared_memory.c > +++ b/platform/linux-generic/odp_shared_memory.c > @@ -134,8 +134,14 @@ int odp_shm_free(odp_shm_t shm) > odp_spinlock_lock(&odp_shm_tbl->lock); > shm_block = &odp_shm_tbl->block[i]; > > +#ifdef MAP_HUGETLB > + /* round up alloc size by page */ > + alloc_size = (shm_block->size + (shm_block->page_sz - 1)) > + & (-shm_block->page_sz);
Could you rebase this on top of my two patches. And then move this calculation to shm_reserve() side, so that the same size gets allocated, saved into block->alloc_size, and the freed here. -Petri > +#else > alloc_size = shm_block->size + shm_block->align; > - ret = munmap(shm_block->addr, alloc_size); > +#endif > + ret = munmap(shm_block->addr_orig, alloc_size); > if (0 != ret) { > ODP_DBG("odp_shm_free: munmap failed\n"); > odp_spinlock_unlock(&odp_shm_tbl->lock); > -- > 1.8.5.1.163.gd7aced9 > > > _______________________________________________ > lng-odp mailing list > lng-odp@lists.linaro.org > http://lists.linaro.org/mailman/listinfo/lng-odp _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org http://lists.linaro.org/mailman/listinfo/lng-odp