summaryrefslogtreecommitdiff
path: root/libartpalette
diff options
context:
space:
mode:
authorOrion Hodson <oth@google.com>2019-10-15 09:09:34 +0000
committerOrion Hodson <oth@google.com>2019-10-15 09:21:12 +0000
commitaf47ca01e96c280a15c24e2ae8152f61ffb8c1ce (patch)
tree50ef867248332c93a366f1d531b08be8ddab8d59 /libartpalette
parent65ae669694e4376d6015d8a54668d5d4bc826c27 (diff)
Revert "zygote: use libcutils to allocate JIT memory"
This reverts commit ee61519ae61297be973820d94c48e00653bc74d4. Reason for revert: Fails is post submit testing in ART buildbots (https://ci.chromium.org/p/art/builders/ci/angler-armv7-ndebug/1005) Change-Id: I72cb2b4fe501a8f5aaa78db1d01584387aaea710
Diffstat (limited to 'libartpalette')
-rw-r--r--libartpalette/system/palette_android.cc31
1 files changed, 27 insertions, 4 deletions
diff --git a/libartpalette/system/palette_android.cc b/libartpalette/system/palette_android.cc
index 4ef4a88ba3..bb9841ae66 100644
--- a/libartpalette/system/palette_android.cc
+++ b/libartpalette/system/palette_android.cc
@@ -19,6 +19,7 @@
#include "palette/palette.h"
#include <errno.h>
+#include <linux/ashmem.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <unistd.h>
@@ -28,7 +29,6 @@
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/macros.h>
-#include <cutils/ashmem.h>
#include <cutils/sched_policy.h>
#include <cutils/trace.h>
#include <log/event_tag_map.h>
@@ -174,15 +174,38 @@ enum PaletteStatus PaletteTraceIntegerValue(const char* name, int32_t value) {
}
enum PaletteStatus PaletteAshmemCreateRegion(const char* name, size_t size, int* fd) {
- *fd = ashmem_create_region(name, size);
- if (*fd < 0) {
+ // We implement our own ashmem creation, as the libcutils implementation does
+ // a binder call, and our only use of ashmem in ART is for zygote, which
+ // cannot communicate to binder.
+ *fd = TEMP_FAILURE_RETRY(open("/dev/ashmem", O_RDWR | O_CLOEXEC));
+ if (*fd == -1) {
return PaletteStatus::kCheckErrno;
}
+
+ if (TEMP_FAILURE_RETRY(ioctl(*fd, ASHMEM_SET_SIZE, size)) < 0) {
+ goto error;
+ }
+
+ if (name != nullptr) {
+ char buf[ASHMEM_NAME_LEN] = {0};
+ strlcpy(buf, name, sizeof(buf));
+ if (TEMP_FAILURE_RETRY(ioctl(*fd, ASHMEM_SET_NAME, buf)) < 0) {
+ goto error;
+ }
+ }
+
return PaletteStatus::kOkay;
+
+error:
+ // Save errno before closing.
+ int save_errno = errno;
+ close(*fd);
+ errno = save_errno;
+ return PaletteStatus::kCheckErrno;
}
enum PaletteStatus PaletteAshmemSetProtRegion(int fd, int prot) {
- if (ashmem_set_prot_region(fd, prot) < 0) {
+ if (TEMP_FAILURE_RETRY(ioctl(fd, ASHMEM_SET_PROT_MASK, prot)) < 0) {
return PaletteStatus::kCheckErrno;
}
return PaletteStatus::kOkay;