notaz.gp2x.de
/
libpicofe.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e7f5800
)
retry with mmap when mremap fails
author
notaz
<notasas@gmail.com>
Thu, 5 Oct 2017 22:23:03 +0000
(
01:23
+0300)
committer
notaz
<notasas@gmail.com>
Thu, 5 Oct 2017 22:23:03 +0000
(
01:23
+0300)
linux/plat.c
patch
|
blob
|
blame
|
history
diff --git
a/linux/plat.c
b/linux/plat.c
index
06c315e
..
2842691
100644
(file)
--- a/
linux/plat.c
+++ b/
linux/plat.c
@@
-216,8
+216,18
@@
void *plat_mremap(void *ptr, size_t oldsize, size_t newsize)
void *ret;
ret = mremap(ptr, oldsize, newsize, MREMAP_MAYMOVE);
void *ret;
ret = mremap(ptr, oldsize, newsize, MREMAP_MAYMOVE);
- if (ret == MAP_FAILED)
- return NULL;
+ if (ret == MAP_FAILED) {
+ fprintf(stderr, "mremap %p %zd %zd: ",
+ ptr, oldsize, newsize);
+ perror(NULL);
+ // might be because huge pages can't be remapped,
+ // just make a new mapping
+ ret = plat_mmap(0, newsize, 0, 0);
+ if (ret == MAP_FAILED)
+ return NULL;
+ memcpy(ret, ptr, oldsize);
+ munmap(ptr, oldsize);
+ }
if (ret != ptr)
printf("warning: mremap moved: %p -> %p\n", ptr, ret);
if (ret != ptr)
printf("warning: mremap moved: %p -> %p\n", ptr, ret);