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

Commit aa45cb85 authored by Tim Murray's avatar Tim Murray
Browse files

Set stune groups from set_sched_policy.

bug 29512132

Change-Id: Ib4176b80787db9e7ace9468cbf670f05cc428786
parent 3a29e344
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -66,9 +66,11 @@ static int system_bg_cpuset_fd = -1;
static int bg_cpuset_fd = -1;
static int fg_cpuset_fd = -1;
static int ta_cpuset_fd = -1; // special cpuset for top app
#endif

// File descriptors open to /dev/stune/../tasks, setup by initialize, or -1 on error
static int bg_schedboost_fd = -1;
static int fg_schedboost_fd = -1;
#endif

/* Add tid to the scheduling group defined by the policy */
static int add_tid_to_cgroup(int tid, int fd)
@@ -313,10 +315,12 @@ int set_cpuset_policy(int tid, SchedPolicy policy)
            return -errno;
    }

#ifdef USE_SCHEDBOOST
    if (boost_fd > 0 && add_tid_to_cgroup(tid, boost_fd) != 0) {
        if (errno != ESRCH && errno != ENOENT)
            return -errno;
    }
#endif

    return 0;
#endif
@@ -373,19 +377,26 @@ int set_sched_policy(int tid, SchedPolicy policy)
#endif

    if (__sys_supports_schedgroups) {
        int fd;
        int fd = -1;
        int boost_fd = -1;
        switch (policy) {
        case SP_BACKGROUND:
            fd = bg_cgroup_fd;
            boost_fd = bg_schedboost_fd;
            break;
        case SP_FOREGROUND:
        case SP_AUDIO_APP:
        case SP_AUDIO_SYS:
            fd = fg_cgroup_fd;
            boost_fd = bg_schedboost_fd;
            break;
        case SP_TOP_APP:
            fd = fg_cgroup_fd;
            boost_fd = fg_schedboost_fd;
            break;
        default:
            fd = -1;
            boost_fd = -1;
            break;
        }

@@ -394,6 +405,13 @@ int set_sched_policy(int tid, SchedPolicy policy)
            if (errno != ESRCH && errno != ENOENT)
                return -errno;
        }

#ifdef USE_SCHEDBOOST
        if (boost_fd > 0 && add_tid_to_cgroup(tid, boost_fd) != 0) {
            if (errno != ESRCH && errno != ENOENT)
                return -errno;
        }
#endif
    } else {
        struct sched_param param;