merge in nyc-dr1-release history after reset to nyc-dr1-dev
diff --git a/libpagemap/pm_memusage.c b/libpagemap/pm_memusage.c
index 70cfede..71a5783 100644
--- a/libpagemap/pm_memusage.c
+++ b/libpagemap/pm_memusage.c
@@ -89,15 +89,15 @@
if (mu->p_swap == NULL)
return;
- if (offset > mu->p_swap->array_size) {
+ if (offset >= mu->p_swap->array_size) {
fprintf(stderr, "SWAP offset %d is out of swap bounds.\n", offset);
return;
+ }
+
+ if (mu->p_swap->offset_array[offset] == USHRT_MAX) {
+ fprintf(stderr, "SWAP offset %d ref. count if overflowing ushort type.\n", offset);
} else {
- if (mu->p_swap->offset_array[offset] == USHRT_MAX) {
- fprintf(stderr, "SWAP offset %d ref. count if overflowing ushort type.\n", offset);
- } else {
- mu->p_swap->offset_array[offset]++;
- }
+ mu->p_swap->offset_array[offset]++;
}
soff = malloc(sizeof(pm_swap_offset_t));
diff --git a/tests/binder/benchmarks/binderAddInts.cpp b/tests/binder/benchmarks/binderAddInts.cpp
index d0b2910..7ac5360 100644
--- a/tests/binder/benchmarks/binderAddInts.cpp
+++ b/tests/binder/benchmarks/binderAddInts.cpp
@@ -79,7 +79,7 @@
// File scope function prototypes
static bool server(void);
-static void BM_client(benchmark::State& state);
+static void BM_addInts(benchmark::State& state);
static void bindCPU(unsigned int cpu);
static ostream &operator<<(ostream &stream, const String16& str);
static ostream &operator<<(ostream &stream, const cpu_set_t& set);
@@ -103,9 +103,8 @@
return true;
}
-static void BM_client(benchmark::State& state)
+static void BM_addInts(benchmark::State& state)
{
- server();
int rv;
sp<IServiceManager> sm = defaultServiceManager();
@@ -162,7 +161,7 @@
state.ResumeTiming();
}
}
-BENCHMARK(BM_client);
+BENCHMARK(BM_addInts);
AddIntsService::AddIntsService(int cpu): cpu_(cpu) {
@@ -305,6 +304,30 @@
}
}
- ::benchmark::RunSpecifiedBenchmarks();
-}
+ fflush(stdout);
+ switch (pid_t pid = fork()) {
+ case 0: // Child
+ ::benchmark::RunSpecifiedBenchmarks();
+ return 0;
+ default: // Parent
+ if (!server()) { break; }
+
+ // Wait for all children to end
+ do {
+ int stat;
+ rv = wait(&stat);
+ if ((rv == -1) && (errno == ECHILD)) { break; }
+ if (rv == -1) {
+ cerr << "wait failed, rv: " << rv << " errno: "
+ << errno << endl;
+ perror(NULL);
+ exit(8);
+ }
+ } while (1);
+ return 0;
+
+ case -1: // Error
+ exit(9);
+ }
+}