Merge "init: Issue a wipe on boot if trade-in mode was active." into main
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..c77a803
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,5 @@
+dirgroup {
+ name: "trusty_dirgroup_system_core",
+ dirs: ["."],
+ visibility: ["//trusty/vendor/google/aosp/scripts"],
+}
diff --git a/fs_mgr/libfiemap/fiemap_writer_test.cpp b/fs_mgr/libfiemap/fiemap_writer_test.cpp
index c37329c..115f53e 100644
--- a/fs_mgr/libfiemap/fiemap_writer_test.cpp
+++ b/fs_mgr/libfiemap/fiemap_writer_test.cpp
@@ -66,7 +66,11 @@
testfile = gTestDir + "/"s + tinfo->name();
}
- void TearDown() override { unlink(testfile.c_str()); }
+ void TearDown() override {
+ truncate(testfile.c_str(), 0);
+ unlink(testfile.c_str());
+ sync();
+ }
// name of the file we use for testing
std::string testfile;
diff --git a/fs_mgr/libfiemap/split_fiemap_writer.cpp b/fs_mgr/libfiemap/split_fiemap_writer.cpp
index 0df6125..1f32d2f 100644
--- a/fs_mgr/libfiemap/split_fiemap_writer.cpp
+++ b/fs_mgr/libfiemap/split_fiemap_writer.cpp
@@ -196,10 +196,13 @@
if (access(file.c_str(), F_OK) != 0 && (errno == ENOENT || errno == ENAMETOOLONG)) {
continue;
}
+ truncate(file.c_str(), 0);
ok &= android::base::RemoveFileIfExists(file, message);
}
}
+ truncate(file_path.c_str(), 0);
ok &= android::base::RemoveFileIfExists(file_path, message);
+ sync();
return ok;
}
diff --git a/fs_mgr/liblp/super_layout_builder.cpp b/fs_mgr/liblp/super_layout_builder.cpp
index fd7416b..bff26ea 100644
--- a/fs_mgr/liblp/super_layout_builder.cpp
+++ b/fs_mgr/liblp/super_layout_builder.cpp
@@ -184,7 +184,7 @@
return {};
}
- size_t size = e.num_sectors * LP_SECTOR_SIZE;
+ uint64_t size = e.num_sectors * LP_SECTOR_SIZE;
uint64_t super_offset = e.target_data * LP_SECTOR_SIZE;
extents.emplace_back(super_offset, size, image_name, image_offset);
diff --git a/fs_mgr/libsnapshot/android/snapshot/snapshot.proto b/fs_mgr/libsnapshot/android/snapshot/snapshot.proto
index 62f9901..5fb71a3 100644
--- a/fs_mgr/libsnapshot/android/snapshot/snapshot.proto
+++ b/fs_mgr/libsnapshot/android/snapshot/snapshot.proto
@@ -233,6 +233,8 @@
// Number of cow operations to be merged at once
uint32 cow_op_merge_size = 13;
+ // Number of worker threads to serve I/O from dm-user
+ uint32 num_worker_threads = 14;
}
// Next: 10
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h b/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h
index 7ae55db..8ff41db 100644
--- a/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h
+++ b/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h
@@ -838,6 +838,10 @@
// Get value of maximum cow op merge size
uint32_t GetUpdateCowOpMergeSize(LockedFile* lock);
+
+ // Get number of threads to perform post OTA boot verification
+ uint32_t GetUpdateWorkerCount(LockedFile* lock);
+
// Wrapper around libdm, with diagnostics.
bool DeleteDeviceIfExists(const std::string& name,
const std::chrono::milliseconds& timeout_ms = {});
diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp
index 6c3bedd..05dec68 100644
--- a/fs_mgr/libsnapshot/snapshot.cpp
+++ b/fs_mgr/libsnapshot/snapshot.cpp
@@ -1235,8 +1235,8 @@
wrong_phase = true;
break;
default:
- LOG(ERROR) << "Unknown merge status for \"" << snapshot << "\": "
- << "\"" << result.state << "\"";
+ LOG(ERROR) << "Unknown merge status for \"" << snapshot << "\": " << "\""
+ << result.state << "\"";
if (failure_code == MergeFailureCode::Ok) {
failure_code = MergeFailureCode::UnexpectedMergeState;
}
@@ -1725,6 +1725,10 @@
if (cow_op_merge_size != 0) {
snapuserd_argv->emplace_back("-cow_op_merge_size=" + std::to_string(cow_op_merge_size));
}
+ uint32_t worker_count = GetUpdateWorkerCount(lock.get());
+ if (worker_count != 0) {
+ snapuserd_argv->emplace_back("-worker_count=" + std::to_string(worker_count));
+ }
}
size_t num_cows = 0;
@@ -2152,6 +2156,11 @@
return update_status.cow_op_merge_size();
}
+uint32_t SnapshotManager::GetUpdateWorkerCount(LockedFile* lock) {
+ SnapshotUpdateStatus update_status = ReadSnapshotUpdateStatus(lock);
+ return update_status.num_worker_threads();
+}
+
bool SnapshotManager::MarkSnapuserdFromSystem() {
auto path = GetSnapuserdFromSystemPath();
@@ -3140,6 +3149,7 @@
status.set_legacy_snapuserd(old_status.legacy_snapuserd());
status.set_o_direct(old_status.o_direct());
status.set_cow_op_merge_size(old_status.cow_op_merge_size());
+ status.set_num_worker_threads(old_status.num_worker_threads());
}
return WriteSnapshotUpdateStatus(lock, status);
}
@@ -3524,6 +3534,9 @@
}
status.set_cow_op_merge_size(
android::base::GetUintProperty<uint32_t>("ro.virtual_ab.cow_op_merge_size", 0));
+ status.set_num_worker_threads(
+ android::base::GetUintProperty<uint32_t>("ro.virtual_ab.num_worker_threads", 0));
+
} else if (legacy_compression) {
LOG(INFO) << "Virtual A/B using legacy snapuserd";
} else {
@@ -3960,6 +3973,7 @@
ss << "Using io_uring: " << update_status.io_uring_enabled() << std::endl;
ss << "Using o_direct: " << update_status.o_direct() << std::endl;
ss << "Cow op merge size (0 for uncapped): " << update_status.cow_op_merge_size() << std::endl;
+ ss << "Worker thread count: " << update_status.num_worker_threads() << std::endl;
ss << "Using XOR compression: " << GetXorCompressionEnabledProperty() << std::endl;
ss << "Current slot: " << device_->GetSlotSuffix() << std::endl;
ss << "Boot indicator: booting from " << GetCurrentSlot() << " slot" << std::endl;
@@ -4576,8 +4590,7 @@
}
}
- LOG(ERROR) << "Device-mapper device " << name << "(" << full_path << ")"
- << " still in use."
+ LOG(ERROR) << "Device-mapper device " << name << "(" << full_path << ")" << " still in use."
<< " Probably a file descriptor was leaked or held open, or a loop device is"
<< " attached.";
return false;
diff --git a/fs_mgr/libsnapshot/snapshotctl.cpp b/fs_mgr/libsnapshot/snapshotctl.cpp
index 97a8cb2..46de991 100644
--- a/fs_mgr/libsnapshot/snapshotctl.cpp
+++ b/fs_mgr/libsnapshot/snapshotctl.cpp
@@ -105,7 +105,7 @@
bool FinishSnapshotWrites();
bool UnmapCowImagePath(std::string& name);
bool DeleteSnapshots();
- bool CleanupSnapshot() { return sm_->PrepareDeviceToBootWithoutSnapshot(); }
+ bool CleanupSnapshot();
bool BeginUpdate();
bool ApplyUpdate();
@@ -495,6 +495,11 @@
return sm_->UnmapCowImage(name);
}
+bool MapSnapshots::CleanupSnapshot() {
+ sm_ = SnapshotManager::New();
+ return sm_->PrepareDeviceToBootWithoutSnapshot();
+}
+
bool MapSnapshots::DeleteSnapshots() {
sm_ = SnapshotManager::New();
lock_ = sm_->LockExclusive();
diff --git a/fs_mgr/libsnapshot/snapuserd/snapuserd_daemon.cpp b/fs_mgr/libsnapshot/snapuserd/snapuserd_daemon.cpp
index dd2dd56..32e16cc 100644
--- a/fs_mgr/libsnapshot/snapuserd/snapuserd_daemon.cpp
+++ b/fs_mgr/libsnapshot/snapuserd/snapuserd_daemon.cpp
@@ -31,6 +31,7 @@
DEFINE_bool(io_uring, false, "If true, io_uring feature is enabled");
DEFINE_bool(o_direct, false, "If true, enable direct reads on source device");
DEFINE_int32(cow_op_merge_size, 0, "number of operations to be processed at once");
+DEFINE_int32(worker_count, 4, "number of worker threads used to serve I/O requests to dm-user");
namespace android {
namespace snapshot {
@@ -114,8 +115,9 @@
LOG(ERROR) << "Malformed message, expected at least four sub-arguments.";
return false;
}
- auto handler = user_server_.AddHandler(parts[0], parts[1], parts[2], parts[3],
- FLAGS_o_direct, FLAGS_cow_op_merge_size);
+ auto handler =
+ user_server_.AddHandler(parts[0], parts[1], parts[2], parts[3], FLAGS_worker_count,
+ FLAGS_o_direct, FLAGS_cow_op_merge_size);
if (!handler || !user_server_.StartHandler(parts[0])) {
return false;
}
diff --git a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_server.cpp b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_server.cpp
index 013df35..3bb8a30 100644
--- a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_server.cpp
+++ b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_server.cpp
@@ -35,6 +35,7 @@
#include <snapuserd/dm_user_block_server.h>
#include <snapuserd/snapuserd_client.h>
#include "snapuserd_server.h"
+#include "user-space-merge/snapuserd_core.h"
namespace android {
namespace snapshot {
@@ -125,7 +126,7 @@
return Sendmsg(fd, "fail");
}
- auto handler = AddHandler(out[1], out[2], out[3], out[4]);
+ auto handler = AddHandler(out[1], out[2], out[3], out[4], std::nullopt);
if (!handler) {
return Sendmsg(fd, "fail");
}
@@ -341,12 +342,11 @@
SetTerminating();
}
-std::shared_ptr<HandlerThread> UserSnapshotServer::AddHandler(const std::string& misc_name,
- const std::string& cow_device_path,
- const std::string& backing_device,
- const std::string& base_path_merge,
- const bool o_direct,
- uint32_t cow_op_merge_size) {
+std::shared_ptr<HandlerThread> UserSnapshotServer::AddHandler(
+ const std::string& misc_name, const std::string& cow_device_path,
+ const std::string& backing_device, const std::string& base_path_merge,
+ std::optional<uint32_t> num_worker_threads, const bool o_direct,
+ uint32_t cow_op_merge_size) {
// We will need multiple worker threads only during
// device boot after OTA. For all other purposes,
// one thread is sufficient. We don't want to consume
@@ -355,7 +355,9 @@
//
// During boot up, we need multiple threads primarily for
// update-verification.
- int num_worker_threads = kNumWorkerThreads;
+ if (!num_worker_threads.has_value()) {
+ num_worker_threads = kNumWorkerThreads;
+ }
if (is_socket_present_) {
num_worker_threads = 1;
}
@@ -368,7 +370,7 @@
auto opener = block_server_factory_->CreateOpener(misc_name);
return handlers_->AddHandler(misc_name, cow_device_path, backing_device, base_path_merge,
- opener, num_worker_threads, io_uring_enabled_, o_direct,
+ opener, num_worker_threads.value(), io_uring_enabled_, o_direct,
cow_op_merge_size);
}
diff --git a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_server.h b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_server.h
index ceea36a..f002e8d 100644
--- a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_server.h
+++ b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_server.h
@@ -87,6 +87,7 @@
const std::string& cow_device_path,
const std::string& backing_device,
const std::string& base_path_merge,
+ std::optional<uint32_t> num_worker_threads,
bool o_direct = false,
uint32_t cow_op_merge_size = 0);
bool StartHandler(const std::string& misc_name);
diff --git a/init/epoll.cpp b/init/epoll.cpp
index cd73a0c..719a532 100644
--- a/init/epoll.cpp
+++ b/init/epoll.cpp
@@ -47,8 +47,8 @@
auto [it, inserted] = epoll_handlers_.emplace(
fd, Info{
- .events = events,
.handler = std::move(handler),
+ .events = events,
});
if (!inserted) {
return Error() << "Cannot specify two epoll handlers for a given FD";
diff --git a/init/first_stage_mount.cpp b/init/first_stage_mount.cpp
index f303815..4f1af30 100644
--- a/init/first_stage_mount.cpp
+++ b/init/first_stage_mount.cpp
@@ -313,11 +313,6 @@
return false;
}
}
-
- if (IsArcvm() && !block_dev_init_.InitHvcDevice("hvc1")) {
- return false;
- }
-
return true;
}
diff --git a/init/selinux.cpp b/init/selinux.cpp
index 01af2b6..c2d9b8d 100644
--- a/init/selinux.cpp
+++ b/init/selinux.cpp
@@ -474,8 +474,6 @@
RestoreconIfExists(SnapshotManager::GetGlobalRollbackIndicatorPath().c_str(), 0);
RestoreconIfExists("/metadata/gsi",
SELINUX_ANDROID_RESTORECON_RECURSE | SELINUX_ANDROID_RESTORECON_SKIP_SEHASH);
-
- RestoreconIfExists("/dev/hvc1", 0);
}
int SelinuxKlogCallback(int type, const char* fmt, ...) {
diff --git a/init/service_parser.cpp b/init/service_parser.cpp
index e6f3af6..ec3b176 100644
--- a/init/service_parser.cpp
+++ b/init/service_parser.cpp
@@ -538,12 +538,9 @@
// when we migrate to cgroups v2 while these hardcoded paths stay the same.
static std::optional<const std::string> ConvertTaskFileToProfile(const std::string& file) {
static const std::map<const std::string, const std::string> map = {
- {"/dev/stune/top-app/tasks", "MaxPerformance"},
- {"/dev/stune/foreground/tasks", "HighPerformance"},
{"/dev/cpuset/camera-daemon/tasks", "CameraServiceCapacity"},
{"/dev/cpuset/foreground/tasks", "ProcessCapacityHigh"},
{"/dev/cpuset/system-background/tasks", "ServiceCapacityLow"},
- {"/dev/stune/nnapi-hal/tasks", "NNApiHALPerformance"},
{"/dev/blkio/background/tasks", "LowIoPriority"},
};
auto iter = map.find(file);
diff --git a/init/util.h b/init/util.h
index 0565391..aa24123 100644
--- a/init/util.h
+++ b/init/util.h
@@ -18,7 +18,6 @@
#include <sys/stat.h>
#include <sys/types.h>
-#include <sys/unistd.h>
#include <chrono>
#include <functional>
@@ -109,10 +108,6 @@
#endif
}
-inline bool IsArcvm() {
- return !access("/is_arcvm", F_OK);
-}
-
bool Has32BitAbi();
std::string GetApexNameFromFileName(const std::string& path);
diff --git a/libcutils/sched_policy_test.cpp b/libcutils/sched_policy_test.cpp
index 50bd6d0..2641743 100644
--- a/libcutils/sched_policy_test.cpp
+++ b/libcutils/sched_policy_test.cpp
@@ -67,13 +67,6 @@
}
TEST(SchedPolicy, set_sched_policy) {
- if (!schedboost_enabled()) {
- // schedboost_enabled() (i.e. CONFIG_CGROUP_SCHEDTUNE) is optional;
- // it's only needed on devices using energy-aware scheduler.
- GTEST_LOG_(INFO) << "skipping test that requires CONFIG_CGROUP_SCHEDTUNE";
- return;
- }
-
ASSERT_EQ(0, set_sched_policy(0, SP_BACKGROUND));
ASSERT_EQ(0, set_cpuset_policy(0, SP_BACKGROUND));
AssertPolicy(SP_BACKGROUND);
diff --git a/libprocessgroup/include/processgroup/sched_policy.h b/libprocessgroup/include/processgroup/sched_policy.h
index 1b6ea66..92cd367 100644
--- a/libprocessgroup/include/processgroup/sched_policy.h
+++ b/libprocessgroup/include/processgroup/sched_policy.h
@@ -29,14 +29,6 @@
*/
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,
diff --git a/libprocessgroup/profiles/Android.bp b/libprocessgroup/profiles/Android.bp
index 885971a..1ec9f7f 100644
--- a/libprocessgroup/profiles/Android.bp
+++ b/libprocessgroup/profiles/Android.bp
@@ -19,11 +19,6 @@
prebuilt_etc {
name: "cgroups.json",
src: "cgroups.json",
- required: [
- "cgroups_28.json",
- "cgroups_29.json",
- "cgroups_30.json",
- ],
}
prebuilt_etc {
@@ -34,49 +29,8 @@
}
prebuilt_etc {
- name: "cgroups_28.json",
- src: "cgroups_28.json",
- sub_dir: "task_profiles",
-}
-
-prebuilt_etc {
- name: "cgroups_29.json",
- src: "cgroups_29.json",
- sub_dir: "task_profiles",
-}
-
-prebuilt_etc {
- name: "cgroups_30.json",
- src: "cgroups_30.json",
- sub_dir: "task_profiles",
-}
-
-prebuilt_etc {
name: "task_profiles.json",
src: "task_profiles.json",
- required: [
- "task_profiles_28.json",
- "task_profiles_29.json",
- "task_profiles_30.json",
- ],
-}
-
-prebuilt_etc {
- name: "task_profiles_28.json",
- src: "task_profiles_28.json",
- sub_dir: "task_profiles",
-}
-
-prebuilt_etc {
- name: "task_profiles_29.json",
- src: "task_profiles_29.json",
- sub_dir: "task_profiles",
-}
-
-prebuilt_etc {
- name: "task_profiles_30.json",
- src: "task_profiles_30.json",
- sub_dir: "task_profiles",
}
cc_defaults {
diff --git a/libprocessgroup/profiles/cgroups_28.json b/libprocessgroup/profiles/cgroups_28.json
deleted file mode 100644
index 17d4929..0000000
--- a/libprocessgroup/profiles/cgroups_28.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "Cgroups": [
- {
- "Controller": "schedtune",
- "Path": "/dev/stune",
- "Mode": "0755",
- "UID": "system",
- "GID": "system"
- }
- ]
-}
diff --git a/libprocessgroup/profiles/cgroups_29.json b/libprocessgroup/profiles/cgroups_29.json
deleted file mode 100644
index 17d4929..0000000
--- a/libprocessgroup/profiles/cgroups_29.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "Cgroups": [
- {
- "Controller": "schedtune",
- "Path": "/dev/stune",
- "Mode": "0755",
- "UID": "system",
- "GID": "system"
- }
- ]
-}
diff --git a/libprocessgroup/profiles/cgroups_30.json b/libprocessgroup/profiles/cgroups_30.json
deleted file mode 100644
index 80a074b..0000000
--- a/libprocessgroup/profiles/cgroups_30.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "Cgroups": [
- {
- "Controller": "schedtune",
- "Path": "/dev/stune",
- "Mode": "0755",
- "UID": "system",
- "GID": "system",
- "Optional": true
- }
- ]
-}
diff --git a/libprocessgroup/profiles/task_profiles.json b/libprocessgroup/profiles/task_profiles.json
index 411c38c..feda3b4 100644
--- a/libprocessgroup/profiles/task_profiles.json
+++ b/libprocessgroup/profiles/task_profiles.json
@@ -572,33 +572,6 @@
},
{
- "Name": "PerfBoost",
- "Actions": [
- {
- "Name": "SetClamps",
- "Params":
- {
- "Boost": "50%",
- "Clamp": "0"
- }
- }
- ]
- },
- {
- "Name": "PerfClamp",
- "Actions": [
- {
- "Name": "SetClamps",
- "Params":
- {
- "Boost": "0",
- "Clamp": "30%"
- }
- }
- ]
- },
-
- {
"Name": "LowMemoryUsage",
"Actions": [
{
diff --git a/libprocessgroup/profiles/task_profiles_28.json b/libprocessgroup/profiles/task_profiles_28.json
deleted file mode 100644
index e7be548..0000000
--- a/libprocessgroup/profiles/task_profiles_28.json
+++ /dev/null
@@ -1,160 +0,0 @@
-{
- "Attributes": [
- {
- "Name": "STuneBoost",
- "Controller": "schedtune",
- "File": "schedtune.boost"
- },
- {
- "Name": "STunePreferIdle",
- "Controller": "schedtune",
- "File": "schedtune.prefer_idle"
- }
- ],
-
- "Profiles": [
- {
- "Name": "HighEnergySaving",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "NormalPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": ""
- }
- }
- ]
- },
- {
- "Name": "ServicePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "HighPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "foreground"
- }
- }
- ]
- },
- {
- "Name": "MaxPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "top-app"
- }
- }
- ]
- },
- {
- "Name": "RealtimePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "rt"
- }
- }
- ]
- },
- {
- "Name": "CameraServicePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "camera-daemon"
- }
- }
- ]
- },
- {
- "Name": "NNApiHALPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "nnapi-hal"
- }
- }
- ]
- },
- {
- "Name": "Dex2oatPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "CpuPolicySpread",
- "Actions": [
- {
- "Name": "SetAttribute",
- "Params":
- {
- "Name": "STunePreferIdle",
- "Value": "1"
- }
- }
- ]
- },
- {
- "Name": "CpuPolicyPack",
- "Actions": [
- {
- "Name": "SetAttribute",
- "Params":
- {
- "Name": "STunePreferIdle",
- "Value": "0"
- }
- }
- ]
- }
- ]
-}
diff --git a/libprocessgroup/profiles/task_profiles_29.json b/libprocessgroup/profiles/task_profiles_29.json
deleted file mode 100644
index 6174c8d..0000000
--- a/libprocessgroup/profiles/task_profiles_29.json
+++ /dev/null
@@ -1,160 +0,0 @@
-{
- "Attributes": [
- {
- "Name": "STuneBoost",
- "Controller": "schedtune",
- "File": "schedtune.boost"
- },
- {
- "Name": "STunePreferIdle",
- "Controller": "schedtune",
- "File": "schedtune.prefer_idle"
- }
- ],
-
- "Profiles": [
- {
- "Name": "HighEnergySaving",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "NormalPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": ""
- }
- }
- ]
- },
- {
- "Name": "HighPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "foreground"
- }
- }
- ]
- },
- {
- "Name": "ServicePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "MaxPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "top-app"
- }
- }
- ]
- },
- {
- "Name": "RealtimePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "rt"
- }
- }
- ]
- },
- {
- "Name": "CameraServicePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "camera-daemon"
- }
- }
- ]
- },
- {
- "Name": "NNApiHALPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "nnapi-hal"
- }
- }
- ]
- },
- {
- "Name": "Dex2oatPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "CpuPolicySpread",
- "Actions": [
- {
- "Name": "SetAttribute",
- "Params":
- {
- "Name": "STunePreferIdle",
- "Value": "1"
- }
- }
- ]
- },
- {
- "Name": "CpuPolicyPack",
- "Actions": [
- {
- "Name": "SetAttribute",
- "Params":
- {
- "Name": "STunePreferIdle",
- "Value": "0"
- }
- }
- ]
- }
- ]
-}
diff --git a/libprocessgroup/profiles/task_profiles_30.json b/libprocessgroup/profiles/task_profiles_30.json
deleted file mode 100644
index e7be548..0000000
--- a/libprocessgroup/profiles/task_profiles_30.json
+++ /dev/null
@@ -1,160 +0,0 @@
-{
- "Attributes": [
- {
- "Name": "STuneBoost",
- "Controller": "schedtune",
- "File": "schedtune.boost"
- },
- {
- "Name": "STunePreferIdle",
- "Controller": "schedtune",
- "File": "schedtune.prefer_idle"
- }
- ],
-
- "Profiles": [
- {
- "Name": "HighEnergySaving",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "NormalPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": ""
- }
- }
- ]
- },
- {
- "Name": "ServicePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "HighPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "foreground"
- }
- }
- ]
- },
- {
- "Name": "MaxPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "top-app"
- }
- }
- ]
- },
- {
- "Name": "RealtimePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "rt"
- }
- }
- ]
- },
- {
- "Name": "CameraServicePerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "camera-daemon"
- }
- }
- ]
- },
- {
- "Name": "NNApiHALPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "nnapi-hal"
- }
- }
- ]
- },
- {
- "Name": "Dex2oatPerformance",
- "Actions": [
- {
- "Name": "JoinCgroup",
- "Params":
- {
- "Controller": "schedtune",
- "Path": "background"
- }
- }
- ]
- },
- {
- "Name": "CpuPolicySpread",
- "Actions": [
- {
- "Name": "SetAttribute",
- "Params":
- {
- "Name": "STunePreferIdle",
- "Value": "1"
- }
- }
- ]
- },
- {
- "Name": "CpuPolicyPack",
- "Actions": [
- {
- "Name": "SetAttribute",
- "Params":
- {
- "Name": "STunePreferIdle",
- "Value": "0"
- }
- }
- ]
- }
- ]
-}
diff --git a/libprocessgroup/sched_policy.cpp b/libprocessgroup/sched_policy.cpp
index 042bcd2..5a53c35 100644
--- a/libprocessgroup/sched_policy.cpp
+++ b/libprocessgroup/sched_policy.cpp
@@ -148,20 +148,10 @@
return enabled;
}
-static bool schedtune_enabled() {
- return (CgroupMap::GetInstance().FindController("schedtune").IsUsable());
-}
-
static bool cpuctl_enabled() {
return (CgroupMap::GetInstance().FindController("cpu").IsUsable());
}
-bool schedboost_enabled() {
- static bool enabled = schedtune_enabled() || cpuctl_enabled();
-
- return enabled;
-}
-
static int getCGroupSubsys(pid_t tid, const char* subsys, std::string& subgroup) {
auto controller = CgroupMap::GetInstance().FindController(subsys);
@@ -201,9 +191,8 @@
}
std::string group;
- if (schedboost_enabled()) {
- if ((getCGroupSubsys(tid, "schedtune", group) < 0) &&
- (getCGroupSubsys(tid, "cpu", group) < 0)) {
+ if (cpuctl_enabled()) {
+ if (getCGroupSubsys(tid, "cpu", group) < 0) {
LOG(ERROR) << "Failed to find cpu cgroup for tid " << tid;
return -1;
}
diff --git a/libprocessgroup/task_profiles.cpp b/libprocessgroup/task_profiles.cpp
index 67ecc1d..cc675b3 100644
--- a/libprocessgroup/task_profiles.cpp
+++ b/libprocessgroup/task_profiles.cpp
@@ -17,11 +17,16 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "libprocessgroup"
+#include <task_profiles.h>
+
+#include <map>
+#include <string>
+
#include <dirent.h>
#include <fcntl.h>
+#include <sched.h>
+#include <sys/resource.h>
#include <unistd.h>
-#include <task_profiles.h>
-#include <string>
#include <android-base/file.h>
#include <android-base/logging.h>
@@ -30,18 +35,13 @@
#include <android-base/strings.h>
#include <android-base/threads.h>
+#include <build_flags.h>
+
#include <cutils/android_filesystem_config.h>
#include <json/reader.h>
#include <json/value.h>
-#include <build_flags.h>
-
-// To avoid issues in sdk_mac build
-#if defined(__ANDROID__)
-#include <sys/prctl.h>
-#endif
-
using android::base::GetThreadId;
using android::base::GetUintProperty;
using android::base::StringPrintf;
@@ -188,48 +188,18 @@
return true;
}
-bool SetClampsAction::ExecuteForProcess(uid_t, pid_t) const {
- // TODO: add support when kernel supports util_clamp
- LOG(WARNING) << "SetClampsAction::ExecuteForProcess is not supported";
- return false;
-}
-
-bool SetClampsAction::ExecuteForTask(int) const {
- // TODO: add support when kernel supports util_clamp
- LOG(WARNING) << "SetClampsAction::ExecuteForTask is not supported";
- return false;
-}
-
// To avoid issues in sdk_mac build
#if defined(__ANDROID__)
-bool SetTimerSlackAction::IsTimerSlackSupported(pid_t tid) {
- auto file = StringPrintf("/proc/%d/timerslack_ns", tid);
-
- return (access(file.c_str(), W_OK) == 0);
-}
-
bool SetTimerSlackAction::ExecuteForTask(pid_t tid) const {
- static bool sys_supports_timerslack = IsTimerSlackSupported(tid);
-
- // v4.6+ kernels support the /proc/<tid>/timerslack_ns interface.
- // TODO: once we've backported this, log if the open(2) fails.
- if (sys_supports_timerslack) {
- auto file = StringPrintf("/proc/%d/timerslack_ns", tid);
- if (!WriteStringToFile(std::to_string(slack_), file)) {
- if (errno == ENOENT) {
- // This happens when process is already dead
- return true;
- }
- PLOG(ERROR) << "set_timerslack_ns write failed";
+ const auto file = StringPrintf("/proc/%d/timerslack_ns", tid);
+ if (!WriteStringToFile(std::to_string(slack_), file)) {
+ if (errno == ENOENT) {
+ // This happens when process is already dead
+ return true;
}
- }
-
- // TODO: Remove when /proc/<tid>/timerslack_ns interface is backported.
- if (tid == 0 || tid == GetThreadId()) {
- if (prctl(PR_SET_TIMERSLACK, slack_) == -1) {
- PLOG(ERROR) << "set_timerslack_ns prctl failed";
- }
+ PLOG(ERROR) << "set_timerslack_ns write failed";
+ return false;
}
return true;
@@ -672,6 +642,57 @@
return access(task_path_.c_str(), W_OK) == 0;
}
+bool SetSchedulerPolicyAction::isNormalPolicy(int policy) {
+ return policy == SCHED_OTHER || policy == SCHED_BATCH || policy == SCHED_IDLE;
+}
+
+bool SetSchedulerPolicyAction::toPriority(int policy, int virtual_priority, int& priority_out) {
+ constexpr int VIRTUAL_PRIORITY_MIN = 1;
+ constexpr int VIRTUAL_PRIORITY_MAX = 99;
+
+ if (virtual_priority < VIRTUAL_PRIORITY_MIN || virtual_priority > VIRTUAL_PRIORITY_MAX) {
+ LOG(WARNING) << "SetSchedulerPolicy: invalid priority (" << virtual_priority
+ << ") for policy (" << policy << ")";
+ return false;
+ }
+
+ const int min = sched_get_priority_min(policy);
+ if (min == -1) {
+ PLOG(ERROR) << "SetSchedulerPolicy: Cannot get min sched priority for policy " << policy;
+ return false;
+ }
+
+ const int max = sched_get_priority_max(policy);
+ if (max == -1) {
+ PLOG(ERROR) << "SetSchedulerPolicy: Cannot get max sched priority for policy " << policy;
+ return false;
+ }
+
+ priority_out = min + (virtual_priority - VIRTUAL_PRIORITY_MIN) * (max - min) /
+ (VIRTUAL_PRIORITY_MAX - VIRTUAL_PRIORITY_MIN);
+
+ return true;
+}
+
+bool SetSchedulerPolicyAction::ExecuteForTask(pid_t tid) const {
+ struct sched_param param = {};
+ param.sched_priority = isNormalPolicy(policy_) ? 0 : *priority_or_nice_;
+ if (sched_setscheduler(tid, policy_, ¶m) == -1) {
+ PLOG(WARNING) << "SetSchedulerPolicy: Failed to apply scheduler policy (" << policy_
+ << ") with priority (" << *priority_or_nice_ << ") to tid " << tid;
+ return false;
+ }
+
+ if (isNormalPolicy(policy_) && priority_or_nice_ &&
+ setpriority(PRIO_PROCESS, tid, *priority_or_nice_) == -1) {
+ PLOG(WARNING) << "SetSchedulerPolicy: Failed to apply nice (" << *priority_or_nice_
+ << ") to tid " << tid;
+ return false;
+ }
+
+ return true;
+}
+
bool ApplyProfileAction::ExecuteForProcess(uid_t uid, pid_t pid) const {
for (const auto& profile : profiles_) {
profile->ExecuteForProcess(uid, pid);
@@ -925,23 +946,6 @@
} else {
LOG(WARNING) << "SetAttribute: unknown attribute: " << attr_name;
}
- } else if (action_name == "SetClamps") {
- std::string boost_value = params_val["Boost"].asString();
- std::string clamp_value = params_val["Clamp"].asString();
- char* end;
- unsigned long boost;
-
- boost = strtoul(boost_value.c_str(), &end, 10);
- if (end > boost_value.c_str()) {
- unsigned long clamp = strtoul(clamp_value.c_str(), &end, 10);
- if (end > clamp_value.c_str()) {
- profile->Add(std::make_unique<SetClampsAction>(boost, clamp));
- } else {
- LOG(WARNING) << "SetClamps: invalid parameter " << clamp_value;
- }
- } else {
- LOG(WARNING) << "SetClamps: invalid parameter: " << boost_value;
- }
} else if (action_name == "WriteFile") {
std::string attr_filepath = params_val["FilePath"].asString();
std::string attr_procfilepath = params_val["ProcFilePath"].asString();
@@ -959,6 +963,62 @@
LOG(WARNING) << "WriteFile: invalid parameter: "
<< "empty value";
}
+ } else if (action_name == "SetSchedulerPolicy") {
+ const std::map<std::string, int> POLICY_MAP = {
+ {"SCHED_OTHER", SCHED_OTHER},
+ {"SCHED_BATCH", SCHED_BATCH},
+ {"SCHED_IDLE", SCHED_IDLE},
+ {"SCHED_FIFO", SCHED_FIFO},
+ {"SCHED_RR", SCHED_RR},
+ };
+ const std::string policy_str = params_val["Policy"].asString();
+
+ const auto it = POLICY_MAP.find(policy_str);
+ if (it == POLICY_MAP.end()) {
+ LOG(WARNING) << "SetSchedulerPolicy: invalid policy " << policy_str;
+ continue;
+ }
+
+ const int policy = it->second;
+
+ if (SetSchedulerPolicyAction::isNormalPolicy(policy)) {
+ if (params_val.isMember("Priority")) {
+ LOG(WARNING) << "SetSchedulerPolicy: Normal policies (" << policy_str
+ << ") use Nice values, not Priority values";
+ }
+
+ if (params_val.isMember("Nice")) {
+ // If present, this optional value will be passed in an additional syscall
+ // to setpriority(), since the sched_priority value must be 0 for calls to
+ // sched_setscheduler() with "normal" policies.
+ const int nice = params_val["Nice"].asInt();
+
+ const int LINUX_MIN_NICE = -20;
+ const int LINUX_MAX_NICE = 19;
+ if (nice < LINUX_MIN_NICE || nice > LINUX_MAX_NICE) {
+ LOG(WARNING) << "SetSchedulerPolicy: Provided nice (" << nice
+ << ") appears out of range.";
+ }
+ profile->Add(std::make_unique<SetSchedulerPolicyAction>(policy, nice));
+ } else {
+ profile->Add(std::make_unique<SetSchedulerPolicyAction>(policy));
+ }
+ } else {
+ if (params_val.isMember("Nice")) {
+ LOG(WARNING) << "SetSchedulerPolicy: Real-time policies (" << policy_str
+ << ") use Priority values, not Nice values";
+ }
+
+ // This is a "virtual priority" as described by `man 2 sched_get_priority_min`
+ // that will be mapped onto the following range for the provided policy:
+ // [sched_get_priority_min(), sched_get_priority_max()]
+ const int virtual_priority = params_val["Priority"].asInt();
+
+ int priority;
+ if (SetSchedulerPolicyAction::toPriority(policy, virtual_priority, priority)) {
+ profile->Add(std::make_unique<SetSchedulerPolicyAction>(policy, priority));
+ }
+ }
} else {
LOG(WARNING) << "Unknown profile action: " << action_name;
}
diff --git a/libprocessgroup/task_profiles.h b/libprocessgroup/task_profiles.h
index abb3ca5..d0b5043 100644
--- a/libprocessgroup/task_profiles.h
+++ b/libprocessgroup/task_profiles.h
@@ -21,6 +21,7 @@
#include <map>
#include <memory>
#include <mutex>
+#include <optional>
#include <span>
#include <string>
#include <string_view>
@@ -77,7 +78,7 @@
// Default implementations will fail
virtual bool ExecuteForProcess(uid_t, pid_t) const { return false; }
- virtual bool ExecuteForTask(int) const { return false; }
+ virtual bool ExecuteForTask(pid_t) const { return false; }
virtual bool ExecuteForUID(uid_t) const { return false; }
virtual void EnableResourceCaching(ResourceCacheType) {}
@@ -90,19 +91,6 @@
};
// Profile actions
-class SetClampsAction : public ProfileAction {
- public:
- SetClampsAction(int boost, int clamp) noexcept : boost_(boost), clamp_(clamp) {}
-
- const char* Name() const override { return "SetClamps"; }
- bool ExecuteForProcess(uid_t uid, pid_t pid) const override;
- bool ExecuteForTask(pid_t tid) const override;
-
- protected:
- int boost_;
- int clamp_;
-};
-
class SetTimerSlackAction : public ProfileAction {
public:
SetTimerSlackAction(unsigned long slack) noexcept : slack_(slack) {}
@@ -114,8 +102,6 @@
private:
unsigned long slack_;
-
- static bool IsTimerSlackSupported(pid_t tid);
};
// Set attribute profile element
@@ -189,6 +175,25 @@
CacheUseResult UseCachedFd(ResourceCacheType cache_type, const std::string& value) const;
};
+// Set scheduler policy action
+class SetSchedulerPolicyAction : public ProfileAction {
+ public:
+ SetSchedulerPolicyAction(int policy)
+ : policy_(policy) {}
+ SetSchedulerPolicyAction(int policy, int priority_or_nice)
+ : policy_(policy), priority_or_nice_(priority_or_nice) {}
+
+ const char* Name() const override { return "SetSchedulerPolicy"; }
+ bool ExecuteForTask(pid_t tid) const override;
+
+ static bool isNormalPolicy(int policy);
+ static bool toPriority(int policy, int virtual_priority, int& priority_out);
+
+ private:
+ int policy_;
+ std::optional<int> priority_or_nice_;
+};
+
class TaskProfile {
public:
TaskProfile(const std::string& name) : name_(name), res_cached_(false) {}
diff --git a/libstats/pull_lazy/Android.bp b/libstats/pull_lazy/Android.bp
index 65dce26..71af170 100644
--- a/libstats/pull_lazy/Android.bp
+++ b/libstats/pull_lazy/Android.bp
@@ -32,7 +32,7 @@
"-Wall",
"-Werror",
],
- test_suites: ["device-tests", "mts-statsd"],
+ test_suites: ["device-tests"],
test_config: "libstatspull_lazy_test.xml",
// TODO(b/153588990): Remove when the build system properly separates.
// 32bit and 64bit architectures.
diff --git a/libstats/socket_lazy/Android.bp b/libstats/socket_lazy/Android.bp
index 241e87a..945a7c4 100644
--- a/libstats/socket_lazy/Android.bp
+++ b/libstats/socket_lazy/Android.bp
@@ -36,7 +36,6 @@
],
test_suites: [
"device-tests",
- "mts-statsd",
],
test_config: "libstatssocket_lazy_test.xml",
// TODO(b/153588990): Remove when the build system properly separates.
diff --git a/libutils/binder/VectorImpl.cpp b/libutils/binder/VectorImpl.cpp
index d951b8b..a62664f 100644
--- a/libutils/binder/VectorImpl.cpp
+++ b/libutils/binder/VectorImpl.cpp
@@ -463,7 +463,8 @@
size_t new_size;
LOG_ALWAYS_FATAL_IF(__builtin_sub_overflow(mCount, amount, &new_size));
- if (new_size < (capacity() / 2)) {
+ const size_t prev_capacity = capacity();
+ if (new_size < (prev_capacity / 2) && prev_capacity > kMinVectorCapacity) {
// NOTE: (new_size * 2) is safe because capacity didn't overflow and
// new_size < (capacity / 2)).
const size_t new_capacity = max(kMinVectorCapacity, new_size * 2);
diff --git a/libvendorsupport/include_llndk/android/llndk-versioning.h b/libvendorsupport/include_llndk/android/llndk-versioning.h
index cf82fb7..81d165f 100644
--- a/libvendorsupport/include_llndk/android/llndk-versioning.h
+++ b/libvendorsupport/include_llndk/android/llndk-versioning.h
@@ -25,15 +25,15 @@
__attribute__((annotate("introduced_in_llndk=" #vendor_api_level)))
#endif
-#if defined(__ANDROID_VENDOR__)
-
+#if defined(__ANDROID_VENDOR_API__)
+// __ANDROID_VENDOR_API__ is defined only for vendor or product variant modules.
// Use this macro as an `if` statement to call an API that are available to both NDK and LLNDK.
-// This returns true for the vendor modules if the vendor_api_level is less than or equal to the
-// ro.board.api_level.
+// This returns true for vendor or product modules if the vendor_api_level is less than or equal to
+// the ro.board.api_level.
#define API_LEVEL_AT_LEAST(sdk_api_level, vendor_api_level) \
constexpr(__ANDROID_VENDOR_API__ >= vendor_api_level)
-#else // __ANDROID_VENDOR__
+#else // __ANDROID_VENDOR_API__
// For non-vendor modules, API_LEVEL_AT_LEAST is replaced with __builtin_available(sdk_api_level) to
// guard the API for __INTRODUCED_IN.
@@ -42,4 +42,4 @@
(__builtin_available(android sdk_api_level, *))
#endif
-#endif // __ANDROID_VENDOR__
+#endif // __ANDROID_VENDOR_API__
diff --git a/rootdir/init.rc b/rootdir/init.rc
index f43c718..12d9c43 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -112,37 +112,6 @@
# Create socket dir for ot-daemon
mkdir /dev/socket/ot-daemon 0770 thread_network thread_network
- # Create energy-aware scheduler tuning nodes
- mkdir /dev/stune/foreground
- mkdir /dev/stune/background
- mkdir /dev/stune/top-app
- mkdir /dev/stune/rt
- chown system system /dev/stune
- chown system system /dev/stune/foreground
- chown system system /dev/stune/background
- chown system system /dev/stune/top-app
- chown system system /dev/stune/rt
- chown system system /dev/stune/tasks
- chown system system /dev/stune/foreground/tasks
- chown system system /dev/stune/background/tasks
- chown system system /dev/stune/top-app/tasks
- chown system system /dev/stune/rt/tasks
- chown system system /dev/stune/cgroup.procs
- chown system system /dev/stune/foreground/cgroup.procs
- chown system system /dev/stune/background/cgroup.procs
- chown system system /dev/stune/top-app/cgroup.procs
- chown system system /dev/stune/rt/cgroup.procs
- chmod 0664 /dev/stune/tasks
- chmod 0664 /dev/stune/foreground/tasks
- chmod 0664 /dev/stune/background/tasks
- chmod 0664 /dev/stune/top-app/tasks
- chmod 0664 /dev/stune/rt/tasks
- chmod 0664 /dev/stune/cgroup.procs
- chmod 0664 /dev/stune/foreground/cgroup.procs
- chmod 0664 /dev/stune/background/cgroup.procs
- chmod 0664 /dev/stune/top-app/cgroup.procs
- chmod 0664 /dev/stune/rt/cgroup.procs
-
# cpuctl hierarchy for devices using utilclamp
mkdir /dev/cpuctl/foreground
mkdir /dev/cpuctl/foreground_window
@@ -216,24 +185,6 @@
chmod 0664 /dev/cpuctl/camera-daemon/tasks
chmod 0664 /dev/cpuctl/camera-daemon/cgroup.procs
- # Create an stune group for camera-specific processes
- mkdir /dev/stune/camera-daemon
- chown system system /dev/stune/camera-daemon
- chown system system /dev/stune/camera-daemon/tasks
- chown system system /dev/stune/camera-daemon/cgroup.procs
- chmod 0664 /dev/stune/camera-daemon/tasks
- chmod 0664 /dev/stune/camera-daemon/cgroup.procs
-
- # Create an stune group for NNAPI HAL processes
- mkdir /dev/stune/nnapi-hal
- chown system system /dev/stune/nnapi-hal
- chown system system /dev/stune/nnapi-hal/tasks
- chown system system /dev/stune/nnapi-hal/cgroup.procs
- chmod 0664 /dev/stune/nnapi-hal/tasks
- chmod 0664 /dev/stune/nnapi-hal/cgroup.procs
- write /dev/stune/nnapi-hal/schedtune.boost 1
- write /dev/stune/nnapi-hal/schedtune.prefer_idle 1
-
# Create blkio group and apply initial settings.
# This feature needs kernel to support it, and the
# device's init.rc must actually set the correct values.
@@ -1244,6 +1195,9 @@
chown system system /sys/kernel/ipv4/tcp_rmem_min
chown system system /sys/kernel/ipv4/tcp_rmem_def
chown system system /sys/kernel/ipv4/tcp_rmem_max
+ chown system system /sys/firmware/acpi/tables
+ chown system system /sys/firmware/acpi/tables/BERT
+ chown system system /sys/firmware/acpi/tables/data/BERT
chown root radio /proc/cmdline
chown root system /proc/bootconfig
diff --git a/trusty/libtrusty/tipc-test/tipc_test.c b/trusty/libtrusty/tipc-test/tipc_test.c
index 3cf0c05..121837d 100644
--- a/trusty/libtrusty/tipc-test/tipc_test.c
+++ b/trusty/libtrusty/tipc-test/tipc_test.c
@@ -67,7 +67,7 @@
static const char* receiver_name = "com.android.trusty.memref.receiver";
static const size_t memref_chunk_size = 4096;
-static const char* _sopts = "hsvDS:t:r:m:b:B:";
+static const char* _sopts = "hsvD:S:t:r:m:b:B:";
/* clang-format off */
static const struct option _lopts[] = {
{"help", no_argument, 0, 'h'},
diff --git a/trusty/utils/trusty-ut-ctrl/ut-ctrl.c b/trusty/utils/trusty-ut-ctrl/ut-ctrl.c
index 6cc6670..31cfd4c 100644
--- a/trusty/utils/trusty-ut-ctrl/ut-ctrl.c
+++ b/trusty/utils/trusty-ut-ctrl/ut-ctrl.c
@@ -95,12 +95,26 @@
TEST_FAILED = 1,
TEST_MESSAGE = 2,
TEST_TEXT = 3,
+ TEST_OPCODE_COUNT,
};
+static int get_msg_len(const char* buf, int max_buf_len) {
+ int buf_len;
+ for (buf_len = 0; buf_len < max_buf_len; buf_len++) {
+ if ((unsigned char)buf[buf_len] < TEST_OPCODE_COUNT) {
+ break;
+ }
+ }
+ return buf_len;
+}
+
static int run_trusty_unitest(const char* utapp) {
int fd;
- int rc;
- char rx_buf[1024];
+ char read_buf[1024];
+ int read_len;
+ char* rx_buf;
+ int rx_buf_len;
+ int cmd = -1;
/* connect to unitest app */
fd = tipc_connect(dev_name, utapp);
@@ -110,22 +124,39 @@
}
/* wait for test to complete */
+ rx_buf_len = 0;
for (;;) {
- rc = read(fd, rx_buf, sizeof(rx_buf));
- if (rc <= 0 || rc >= (int)sizeof(rx_buf)) {
- fprintf(stderr, "%s: Read failed: %d\n", __func__, rc);
- tipc_close(fd);
- return -1;
+ if (rx_buf_len == 0) {
+ read_len = read(fd, read_buf, sizeof(read_buf));
+ if (read_len <= 0 || read_len > (int)sizeof(read_buf)) {
+ fprintf(stderr, "%s: Read failed: %d, %s\n", __func__, read_len,
+ read_len < 0 ? strerror(errno) : "");
+ tipc_close(fd);
+ return -1;
+ }
+ rx_buf = read_buf;
+ rx_buf_len = read_len;
}
- if (rx_buf[0] == TEST_PASSED) {
+ int msg_len = get_msg_len(rx_buf, rx_buf_len);
+ if (msg_len == 0) {
+ cmd = rx_buf[0];
+ rx_buf++;
+ rx_buf_len--;
+ }
+
+ if (cmd == TEST_PASSED) {
break;
- } else if (rx_buf[0] == TEST_FAILED) {
+ } else if (cmd == TEST_FAILED) {
break;
- } else if (rx_buf[0] == TEST_MESSAGE || rx_buf[0] == TEST_TEXT) {
- write(STDOUT_FILENO, rx_buf + 1, rc - 1);
+ } else if (cmd == TEST_MESSAGE || cmd == TEST_TEXT) {
+ if (msg_len) {
+ write(STDOUT_FILENO, rx_buf, msg_len);
+ rx_buf += msg_len;
+ rx_buf_len -= msg_len;
+ }
} else {
- fprintf(stderr, "%s: Bad message header: %d\n", __func__, rx_buf[0]);
+ fprintf(stderr, "%s: Bad message header: %d\n", __func__, cmd);
break;
}
}
@@ -133,7 +164,7 @@
/* close connection to unitest app */
tipc_close(fd);
- return rx_buf[0] == TEST_PASSED ? 0 : -1;
+ return cmd == TEST_PASSED ? 0 : -1;
}
int main(int argc, char** argv) {