Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ccb9960b authored by Daniel Colascione's avatar Daniel Colascione Committed by Gerrit Code Review
Browse files

Merge "Add MCL_ONFAULT to mlockall"

parents 0ad42435 d39adf2a
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -900,7 +900,16 @@ int main(int argc __unused, char **argv __unused) {
    downgrade_pressure = (int64_t)property_get_int32("ro.lmk.downgrade_pressure", 60);
    is_go_device = property_get_bool("ro.config.low_ram", false);

    if (mlockall(MCL_CURRENT | MCL_FUTURE))
    // MCL_ONFAULT pins pages as they fault instead of loading
    // everything immediately all at once. (Which would be bad,
    // because as of this writing, we have a lot of mapped pages we
    // never use.) Old kernels will see MCL_ONFAULT and fail with
    // EINVAL; we ignore this failure.
    //
    // N.B. read the man page for mlockall. MCL_CURRENT | MCL_ONFAULT
    // pins ⊆ MCL_CURRENT, converging to just MCL_CURRENT as we fault
    // in pages.
    if (mlockall(MCL_CURRENT | MCL_FUTURE | MCL_ONFAULT) && errno != EINVAL)
        ALOGW("mlockall failed: errno=%d", errno);

    sched_setscheduler(0, SCHED_FIFO, &param);