summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2019-07-15 20:03:39 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2019-07-15 20:03:39 +0000
commitf4490b1adf385a0e8b2641db170033622e06e28c (patch)
tree03a5f74ff778b301b1ef6c73d3ac01a4c018e6c7
parentfaefe359e4469f2d075ebca6498e05cbd59f8ef6 (diff)
parent072cc7e6995c9118d3434ad3c2b4fd5156c0c6d4 (diff)
Merge "Revert "Support initializing ProcessState with custom binder window size.""
-rw-r--r--libs/binder/ProcessState.cpp33
-rw-r--r--libs/binder/include/binder/ProcessState.h6
2 files changed, 9 insertions, 30 deletions
diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp
index b25cd7bf12..8b074ad16a 100644
--- a/libs/binder/ProcessState.cpp
+++ b/libs/binder/ProcessState.cpp
@@ -40,7 +40,7 @@
#include <sys/stat.h>
#include <sys/types.h>
-#define DEFAULT_BINDER_VM_SIZE ((1 * 1024 * 1024) - sysconf(_SC_PAGE_SIZE) * 2)
+#define BINDER_VM_SIZE ((1 * 1024 * 1024) - sysconf(_SC_PAGE_SIZE) * 2)
#define DEFAULT_MAX_BINDER_THREADS 15
#ifdef __ANDROID_VNDK__
@@ -77,13 +77,7 @@ sp<ProcessState> ProcessState::self()
if (gProcess != nullptr) {
return gProcess;
}
- gProcess = new ProcessState(kDefaultDriver, DEFAULT_BINDER_VM_SIZE);
- return gProcess;
-}
-
-sp<ProcessState> ProcessState::selfOrNull()
-{
- Mutex::Autolock _l(gProcessMutex);
+ gProcess = new ProcessState(kDefaultDriver);
return gProcess;
}
@@ -104,19 +98,13 @@ sp<ProcessState> ProcessState::initWithDriver(const char* driver)
driver = "/dev/binder";
}
- gProcess = new ProcessState(driver, DEFAULT_BINDER_VM_SIZE);
+ gProcess = new ProcessState(driver);
return gProcess;
}
-sp<ProcessState> ProcessState::initWithMmapSize(size_t mmap_size) {
+sp<ProcessState> ProcessState::selfOrNull()
+{
Mutex::Autolock _l(gProcessMutex);
- if (gProcess != nullptr) {
- LOG_ALWAYS_FATAL_IF(mmap_size != gProcess->getMmapSize(),
- "ProcessState already initialized with a different mmap size.");
- return gProcess;
- }
-
- gProcess = new ProcessState(kDefaultDriver, mmap_size);
return gProcess;
}
@@ -249,10 +237,6 @@ ssize_t ProcessState::getKernelReferences(size_t buf_count, uintptr_t* buf)
return count;
}
-size_t ProcessState::getMmapSize() {
- return mMmapSize;
-}
-
void ProcessState::setCallRestriction(CallRestriction restriction) {
LOG_ALWAYS_FATAL_IF(IPCThreadState::selfOrNull(), "Call restrictions must be set before the threadpool is started.");
@@ -437,7 +421,7 @@ static int open_driver(const char *driver)
return fd;
}
-ProcessState::ProcessState(const char *driver, size_t mmap_size)
+ProcessState::ProcessState(const char *driver)
: mDriverName(String8(driver))
, mDriverFD(open_driver(driver))
, mVMStart(MAP_FAILED)
@@ -451,12 +435,11 @@ ProcessState::ProcessState(const char *driver, size_t mmap_size)
, mBinderContextUserData(nullptr)
, mThreadPoolStarted(false)
, mThreadPoolSeq(1)
- , mMmapSize(mmap_size)
, mCallRestriction(CallRestriction::NONE)
{
if (mDriverFD >= 0) {
// mmap the binder, providing a chunk of virtual address space to receive transactions.
- mVMStart = mmap(nullptr, mMmapSize, PROT_READ, MAP_PRIVATE | MAP_NORESERVE, mDriverFD, 0);
+ mVMStart = mmap(nullptr, BINDER_VM_SIZE, PROT_READ, MAP_PRIVATE | MAP_NORESERVE, mDriverFD, 0);
if (mVMStart == MAP_FAILED) {
// *sigh*
ALOGE("Using %s failed: unable to mmap transaction memory.\n", mDriverName.c_str());
@@ -473,7 +456,7 @@ ProcessState::~ProcessState()
{
if (mDriverFD >= 0) {
if (mVMStart != MAP_FAILED) {
- munmap(mVMStart, mMmapSize);
+ munmap(mVMStart, BINDER_VM_SIZE);
}
close(mDriverFD);
}
diff --git a/libs/binder/include/binder/ProcessState.h b/libs/binder/include/binder/ProcessState.h
index 1622ba2712..61bd69d94d 100644
--- a/libs/binder/include/binder/ProcessState.h
+++ b/libs/binder/include/binder/ProcessState.h
@@ -36,8 +36,6 @@ class ProcessState : public virtual RefBase
public:
static sp<ProcessState> self();
static sp<ProcessState> selfOrNull();
- // Note: don't call self() or selfOrNull() before initWithMmapSize()
- static sp<ProcessState> initWithMmapSize(size_t mmapSize); // size in bytes
/* initWithDriver() can be used to configure libbinder to use
* a different binder driver dev node. It must be called *before*
@@ -78,7 +76,6 @@ public:
String8 getDriverName();
ssize_t getKernelReferences(size_t count, uintptr_t* buf);
- size_t getMmapSize();
enum class CallRestriction {
// all calls okay
@@ -95,7 +92,7 @@ public:
private:
friend class IPCThreadState;
- explicit ProcessState(const char* driver, size_t mmap_size);
+ explicit ProcessState(const char* driver);
~ProcessState();
ProcessState(const ProcessState& o);
@@ -140,7 +137,6 @@ private:
String8 mRootDir;
bool mThreadPoolStarted;
volatile int32_t mThreadPoolSeq;
- const size_t mMmapSize;
CallRestriction mCallRestriction;
};