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

Commit dba77ad7 authored by David Anderson's avatar David Anderson
Browse files

snapuserd: Factor setpriority/settid calls into a helper.

This allows disabling the code in host builds, since settid() isn't
available in the glibc prebuilt.

Bug: 288273605
Test: snapuserd_test
Change-Id: Ifddb5cb8b04484a1ab0a29794d65c9839759a919
parent fe032d03
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ cc_library_static {
        "user-space-merge/snapuserd_transitions.cpp",
        "user-space-merge/snapuserd_verify.cpp",
        "user-space-merge/worker.cpp",
        "utility.cpp",
    ],
    static_libs: [
        "libbase",
+3 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include "merge_worker.h"

#include "snapuserd_core.h"
#include "utility.h"

namespace android {
namespace snapshot {
@@ -550,8 +551,8 @@ bool MergeWorker::Run() {
        return true;
    }

    if (setpriority(PRIO_PROCESS, gettid(), kNiceValueForMergeThreads)) {
        SNAP_PLOG(ERROR) << "Failed to set priority for TID: " << gettid();
    if (!SetThreadPriority(kNiceValueForMergeThreads)) {
        SNAP_PLOG(ERROR) << "Failed to set thread priority";
    }

    SNAP_LOG(INFO) << "Merge starting..";
+3 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include "read_worker.h"

#include "snapuserd_core.h"
#include "utility.h"

namespace android {
namespace snapshot {
@@ -208,8 +209,8 @@ bool ReadWorker::Init() {
bool ReadWorker::Run() {
    SNAP_LOG(INFO) << "Processing snapshot I/O requests....";

    if (setpriority(PRIO_PROCESS, gettid(), kNiceValueForMergeThreads)) {
        SNAP_PLOG(ERROR) << "Failed to set priority for TID: " << gettid();
    if (!SetThreadPriority(kNiceValueForMergeThreads)) {
        SNAP_PLOG(ERROR) << "Failed to set thread priority";
    }

    // Start serving IO
+3 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include "snapuserd_readahead.h"

#include "snapuserd_core.h"
#include "utility.h"

namespace android {
namespace snapshot {
@@ -765,8 +766,8 @@ bool ReadAhead::RunThread() {

    InitializeIouring();

    if (setpriority(PRIO_PROCESS, gettid(), kNiceValueForMergeThreads)) {
        SNAP_PLOG(ERROR) << "Failed to set priority for TID: " << gettid();
    if (!SetThreadPriority(kNiceValueForMergeThreads)) {
        SNAP_PLOG(ERROR) << "Failed to set thread priority";
    }

    while (!RAIterDone()) {
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@
#include "snapuserd_core.h"
#include "testing/dm_user_harness.h"
#include "testing/temp_device.h"
#include "utility.h"

DEFINE_string(force_config, "", "Force testing mode with iouring disabled");

Loading