Merge changes from topic "move sched_policy functions"
am: ca50ee91b5
Change-Id: I92310f7dd60384b95c056c98cdc616857ebcd1ec
This commit is contained in:
commit
e8b2ac49bb
15 changed files with 138 additions and 70 deletions
|
|
@ -109,6 +109,7 @@ CHARGER_STATIC_LIBRARIES := \
|
||||||
libbase \
|
libbase \
|
||||||
libutils \
|
libutils \
|
||||||
libcutils \
|
libcutils \
|
||||||
|
libprocessgroup \
|
||||||
liblog \
|
liblog \
|
||||||
libm \
|
libm \
|
||||||
libc \
|
libc \
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,6 @@ cc_library {
|
||||||
"load_file.cpp",
|
"load_file.cpp",
|
||||||
"native_handle.cpp",
|
"native_handle.cpp",
|
||||||
"record_stream.cpp",
|
"record_stream.cpp",
|
||||||
"sched_policy.cpp",
|
|
||||||
"sockets.cpp",
|
"sockets.cpp",
|
||||||
"strdup16to8.cpp",
|
"strdup16to8.cpp",
|
||||||
"strdup8to16.cpp",
|
"strdup8to16.cpp",
|
||||||
|
|
@ -178,8 +177,12 @@ cc_library {
|
||||||
"libbase_headers",
|
"libbase_headers",
|
||||||
"libcutils_headers",
|
"libcutils_headers",
|
||||||
"libutils_headers",
|
"libutils_headers",
|
||||||
|
"libprocessgroup_headers",
|
||||||
|
],
|
||||||
|
export_header_lib_headers: [
|
||||||
|
"libcutils_headers",
|
||||||
|
"libprocessgroup_headers",
|
||||||
],
|
],
|
||||||
export_header_lib_headers: ["libcutils_headers"],
|
|
||||||
local_include_dirs: ["include"],
|
local_include_dirs: ["include"],
|
||||||
|
|
||||||
cflags: [
|
cflags: [
|
||||||
|
|
|
||||||
|
|
@ -17,67 +17,10 @@
|
||||||
#ifndef __CUTILS_SCHED_POLICY_H
|
#ifndef __CUTILS_SCHED_POLICY_H
|
||||||
#define __CUTILS_SCHED_POLICY_H
|
#define __CUTILS_SCHED_POLICY_H
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if Linux kernel enables CPUSETS feature.
|
* For backwards compatibility only
|
||||||
*
|
* New users should include processgroup/sched_policy.h directly
|
||||||
* Return value: 1 if Linux kernel CONFIG_CPUSETS=y; 0 otherwise.
|
|
||||||
*/
|
*/
|
||||||
extern bool cpusets_enabled();
|
#include <processgroup/sched_policy.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* Check if Linux kernel enables SCHEDTUNE feature (only available in Android
|
|
||||||
* common kernel or Linaro LSK, not in mainline Linux as of v4.9)
|
|
||||||
*
|
|
||||||
* Return value: 1 if Linux kernel CONFIG_CGROUP_SCHEDTUNE=y; 0 otherwise.
|
|
||||||
*/
|
|
||||||
extern bool schedboost_enabled();
|
|
||||||
|
|
||||||
/* Keep in sync with THREAD_GROUP_* in frameworks/base/core/java/android/os/Process.java */
|
|
||||||
typedef enum {
|
|
||||||
SP_DEFAULT = -1,
|
|
||||||
SP_BACKGROUND = 0,
|
|
||||||
SP_FOREGROUND = 1,
|
|
||||||
SP_SYSTEM = 2, // can't be used with set_sched_policy()
|
|
||||||
SP_AUDIO_APP = 3,
|
|
||||||
SP_AUDIO_SYS = 4,
|
|
||||||
SP_TOP_APP = 5,
|
|
||||||
SP_RT_APP = 6,
|
|
||||||
SP_RESTRICTED = 7,
|
|
||||||
SP_CNT,
|
|
||||||
SP_MAX = SP_CNT - 1,
|
|
||||||
SP_SYSTEM_DEFAULT = SP_FOREGROUND,
|
|
||||||
} SchedPolicy;
|
|
||||||
|
|
||||||
extern int set_cpuset_policy(int tid, SchedPolicy policy);
|
|
||||||
|
|
||||||
/* Assign thread tid to the cgroup associated with the specified policy.
|
|
||||||
* If the thread is a thread group leader, that is it's gettid() == getpid(),
|
|
||||||
* then the other threads in the same thread group are _not_ affected.
|
|
||||||
* On platforms which support gettid(), zero tid means current thread.
|
|
||||||
* Return value: 0 for success, or -errno for error.
|
|
||||||
*/
|
|
||||||
extern int set_sched_policy(int tid, SchedPolicy policy);
|
|
||||||
|
|
||||||
/* Return the policy associated with the cgroup of thread tid via policy pointer.
|
|
||||||
* On platforms which support gettid(), zero tid means current thread.
|
|
||||||
* Return value: 0 for success, or -1 for error and set errno.
|
|
||||||
*/
|
|
||||||
extern int get_sched_policy(int tid, SchedPolicy *policy);
|
|
||||||
|
|
||||||
/* Return a displayable string corresponding to policy.
|
|
||||||
* Return value: non-NULL NUL-terminated name of unspecified length;
|
|
||||||
* the caller is responsible for displaying the useful part of the string.
|
|
||||||
*/
|
|
||||||
extern const char *get_sched_policy_name(SchedPolicy policy);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __CUTILS_SCHED_POLICY_H */
|
#endif /* __CUTILS_SCHED_POLICY_H */
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ test_libraries = [
|
||||||
"libcutils",
|
"libcutils",
|
||||||
"liblog",
|
"liblog",
|
||||||
"libbase",
|
"libbase",
|
||||||
|
"libprocessgroup",
|
||||||
]
|
]
|
||||||
|
|
||||||
cc_test {
|
cc_test {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,45 @@
|
||||||
|
cc_library_headers {
|
||||||
|
name: "libprocessgroup_headers",
|
||||||
|
vendor_available: true,
|
||||||
|
recovery_available: true,
|
||||||
|
host_supported: true,
|
||||||
|
export_include_dirs: ["include"],
|
||||||
|
target: {
|
||||||
|
linux_bionic: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
windows: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
cc_library {
|
cc_library {
|
||||||
srcs: ["processgroup.cpp"],
|
srcs: [
|
||||||
|
"processgroup.cpp",
|
||||||
|
"sched_policy.cpp",
|
||||||
|
],
|
||||||
name: "libprocessgroup",
|
name: "libprocessgroup",
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
recovery_available: true,
|
recovery_available: true,
|
||||||
shared_libs: ["libbase"],
|
vendor_available: true,
|
||||||
|
vndk: {
|
||||||
|
enabled: true,
|
||||||
|
support_system_process: true,
|
||||||
|
},
|
||||||
|
shared_libs: [
|
||||||
|
"libbase",
|
||||||
|
"liblog",
|
||||||
|
],
|
||||||
|
// for cutils/android_filesystem_config.h
|
||||||
|
header_libs: [
|
||||||
|
"libcutils_headers",
|
||||||
|
"libprocessgroup_headers",
|
||||||
|
],
|
||||||
export_include_dirs: ["include"],
|
export_include_dirs: ["include"],
|
||||||
|
export_header_lib_headers: [
|
||||||
|
"libprocessgroup_headers",
|
||||||
|
],
|
||||||
cflags: [
|
cflags: [
|
||||||
"-Wall",
|
"-Wall",
|
||||||
"-Werror",
|
"-Werror",
|
||||||
|
|
|
||||||
80
libprocessgroup/include/processgroup/sched_policy.h
Normal file
80
libprocessgroup/include/processgroup/sched_policy.h
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2018 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if Linux kernel enables CPUSETS feature.
|
||||||
|
*
|
||||||
|
* Return value: 1 if Linux kernel CONFIG_CPUSETS=y; 0 otherwise.
|
||||||
|
*/
|
||||||
|
extern bool cpusets_enabled();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if Linux kernel enables SCHEDTUNE feature (only available in Android
|
||||||
|
* common kernel or Linaro LSK, not in mainline Linux as of v4.9)
|
||||||
|
*
|
||||||
|
* Return value: 1 if Linux kernel CONFIG_CGROUP_SCHEDTUNE=y; 0 otherwise.
|
||||||
|
*/
|
||||||
|
extern bool schedboost_enabled();
|
||||||
|
|
||||||
|
/* Keep in sync with THREAD_GROUP_* in frameworks/base/core/java/android/os/Process.java */
|
||||||
|
typedef enum {
|
||||||
|
SP_DEFAULT = -1,
|
||||||
|
SP_BACKGROUND = 0,
|
||||||
|
SP_FOREGROUND = 1,
|
||||||
|
SP_SYSTEM = 2, // can't be used with set_sched_policy()
|
||||||
|
SP_AUDIO_APP = 3,
|
||||||
|
SP_AUDIO_SYS = 4,
|
||||||
|
SP_TOP_APP = 5,
|
||||||
|
SP_RT_APP = 6,
|
||||||
|
SP_RESTRICTED = 7,
|
||||||
|
SP_CNT,
|
||||||
|
SP_MAX = SP_CNT - 1,
|
||||||
|
SP_SYSTEM_DEFAULT = SP_FOREGROUND,
|
||||||
|
} SchedPolicy;
|
||||||
|
|
||||||
|
extern int set_cpuset_policy(int tid, SchedPolicy policy);
|
||||||
|
|
||||||
|
/* Assign thread tid to the cgroup associated with the specified policy.
|
||||||
|
* If the thread is a thread group leader, that is it's gettid() == getpid(),
|
||||||
|
* then the other threads in the same thread group are _not_ affected.
|
||||||
|
* On platforms which support gettid(), zero tid means current thread.
|
||||||
|
* Return value: 0 for success, or -errno for error.
|
||||||
|
*/
|
||||||
|
extern int set_sched_policy(int tid, SchedPolicy policy);
|
||||||
|
|
||||||
|
/* Return the policy associated with the cgroup of thread tid via policy pointer.
|
||||||
|
* On platforms which support gettid(), zero tid means current thread.
|
||||||
|
* Return value: 0 for success, or -1 for error and set errno.
|
||||||
|
*/
|
||||||
|
extern int get_sched_policy(int tid, SchedPolicy *policy);
|
||||||
|
|
||||||
|
/* Return a displayable string corresponding to policy.
|
||||||
|
* Return value: non-NULL NUL-terminated name of unspecified length;
|
||||||
|
* the caller is responsible for displaying the useful part of the string.
|
||||||
|
*/
|
||||||
|
extern const char *get_sched_policy_name(SchedPolicy policy);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
#include <android-base/properties.h>
|
#include <android-base/properties.h>
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
#include <android-base/strings.h>
|
#include <android-base/strings.h>
|
||||||
#include <private/android_filesystem_config.h>
|
#include <cutils/android_filesystem_config.h>
|
||||||
|
|
||||||
#include <processgroup/processgroup.h>
|
#include <processgroup/processgroup.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
** limitations under the License.
|
** limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cutils/sched_policy.h>
|
#include <processgroup/sched_policy.h>
|
||||||
|
|
||||||
#define LOG_TAG "SchedPolicy"
|
#define LOG_TAG "SchedPolicy"
|
||||||
|
|
||||||
|
|
@ -22,11 +22,13 @@ cc_library_headers {
|
||||||
"liblog_headers",
|
"liblog_headers",
|
||||||
"libsystem_headers",
|
"libsystem_headers",
|
||||||
"libcutils_headers",
|
"libcutils_headers",
|
||||||
|
"libprocessgroup_headers",
|
||||||
],
|
],
|
||||||
export_header_lib_headers: [
|
export_header_lib_headers: [
|
||||||
"liblog_headers",
|
"liblog_headers",
|
||||||
"libsystem_headers",
|
"libsystem_headers",
|
||||||
"libcutils_headers",
|
"libcutils_headers",
|
||||||
|
"libprocessgroup_headers",
|
||||||
],
|
],
|
||||||
export_include_dirs: ["include"],
|
export_include_dirs: ["include"],
|
||||||
|
|
||||||
|
|
@ -82,6 +84,7 @@ cc_defaults {
|
||||||
|
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
"libcutils",
|
"libcutils",
|
||||||
|
"libprocessgroup",
|
||||||
"libdl",
|
"libdl",
|
||||||
"libvndksupport",
|
"libvndksupport",
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
|
|
||||||
#include <cutils/sched_policy.h>
|
#include <processgroup/sched_policy.h>
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
#if defined(__ANDROID__)
|
||||||
# define __android_unused
|
# define __android_unused
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ cc_binary {
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
"libcutils",
|
"libcutils",
|
||||||
"liblog",
|
"liblog",
|
||||||
|
"libprocessgroup",
|
||||||
],
|
],
|
||||||
static_libs: [
|
static_libs: [
|
||||||
"libstatslogc",
|
"libstatslogc",
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ cc_defaults {
|
||||||
],
|
],
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
"libbase",
|
"libbase",
|
||||||
"libcutils",
|
|
||||||
"libpcrecpp",
|
"libpcrecpp",
|
||||||
|
"libprocessgroup",
|
||||||
],
|
],
|
||||||
static_libs: ["liblog"],
|
static_libs: ["liblog"],
|
||||||
logtags: ["event.logtags"],
|
logtags: ["event.logtags"],
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,11 @@
|
||||||
#include <android-base/properties.h>
|
#include <android-base/properties.h>
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
#include <android-base/strings.h>
|
#include <android-base/strings.h>
|
||||||
#include <cutils/sched_policy.h>
|
|
||||||
#include <cutils/sockets.h>
|
#include <cutils/sockets.h>
|
||||||
#include <log/event_tag_map.h>
|
#include <log/event_tag_map.h>
|
||||||
#include <log/logprint.h>
|
#include <log/logprint.h>
|
||||||
#include <private/android_logger.h>
|
#include <private/android_logger.h>
|
||||||
|
#include <processgroup/sched_policy.h>
|
||||||
#include <system/thread_defs.h>
|
#include <system/thread_defs.h>
|
||||||
|
|
||||||
#include <pcrecpp.h>
|
#include <pcrecpp.h>
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ cc_binary {
|
||||||
"libcutils",
|
"libcutils",
|
||||||
"libbase",
|
"libbase",
|
||||||
"libpackagelistparser",
|
"libpackagelistparser",
|
||||||
|
"libprocessgroup",
|
||||||
"libcap",
|
"libcap",
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,12 @@
|
||||||
#include <android-base/macros.h>
|
#include <android-base/macros.h>
|
||||||
#include <cutils/android_get_control_file.h>
|
#include <cutils/android_get_control_file.h>
|
||||||
#include <cutils/properties.h>
|
#include <cutils/properties.h>
|
||||||
#include <cutils/sched_policy.h>
|
|
||||||
#include <cutils/sockets.h>
|
#include <cutils/sockets.h>
|
||||||
#include <log/event_tag_map.h>
|
#include <log/event_tag_map.h>
|
||||||
#include <packagelistparser/packagelistparser.h>
|
#include <packagelistparser/packagelistparser.h>
|
||||||
#include <private/android_filesystem_config.h>
|
#include <private/android_filesystem_config.h>
|
||||||
#include <private/android_logger.h>
|
#include <private/android_logger.h>
|
||||||
|
#include <processgroup/sched_policy.h>
|
||||||
#include <utils/threads.h>
|
#include <utils/threads.h>
|
||||||
|
|
||||||
#include "CommandListener.h"
|
#include "CommandListener.h"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue