On 01/22/2015 06:18 PM, Savolainen, Petri (NSN - FI/Espoo) wrote:
-----Original Message-----
From: [email protected] [mailto:lng-odp-
[email protected]] On Behalf Of ext Maxim Uvarov
Sent: Thursday, January 22, 2015 5:01 PM
To: [email protected]
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 <[email protected]>
---
  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

Ok, I saw your patches after I wrote mine. Will rebase it on top.

Maxim.


+#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
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp


_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to