Loading fs_mgr/libsnapshot/partition_cow_creator.cpp +17 −4 Original line number Diff line number Diff line Loading @@ -131,15 +131,28 @@ bool OptimizeSourceCopyOperation(const InstallOperation& operation, InstallOpera return is_optimized; } void WriteExtent(DmSnapCowSizeCalculator* sc, const chromeos_update_engine::Extent& de, bool WriteExtent(DmSnapCowSizeCalculator* sc, const chromeos_update_engine::Extent& de, unsigned int sectors_per_block) { const auto block_boundary = de.start_block() + de.num_blocks(); for (auto b = de.start_block(); b < block_boundary; ++b) { for (unsigned int s = 0; s < sectors_per_block; ++s) { const auto sector_id = b * sectors_per_block + s; // sector_id = b * sectors_per_block + s; uint64_t block_start_sector_id; if (__builtin_mul_overflow(b, sectors_per_block, &block_start_sector_id)) { LOG(ERROR) << "Integer overflow when calculating sector id (" << b << " * " << sectors_per_block << ")"; return false; } uint64_t sector_id; if (__builtin_add_overflow(block_start_sector_id, s, §or_id)) { LOG(ERROR) << "Integer overflow when calculating sector id (" << block_start_sector_id << " + " << s << ")"; return false; } sc->WriteSector(sector_id); } } return true; } std::optional<uint64_t> PartitionCowCreator::GetCowSize() { Loading Loading @@ -167,7 +180,7 @@ std::optional<uint64_t> PartitionCowCreator::GetCowSize() { // Allocate space for extra extents (if any). These extents are those that can be // used for error corrections or to store verity hash trees. for (const auto& de : extra_extents) { WriteExtent(&sc, de, sectors_per_block); if (!WriteExtent(&sc, de, sectors_per_block)) return std::nullopt; } if (update == nullptr) return sc.cow_size_bytes(); Loading @@ -182,7 +195,7 @@ std::optional<uint64_t> PartitionCowCreator::GetCowSize() { } for (const auto& de : written_op->dst_extents()) { WriteExtent(&sc, de, sectors_per_block); if (!WriteExtent(&sc, de, sectors_per_block)) return std::nullopt; } } Loading libprocessgroup/profiles/cgroups.json +7 −6 Original line number Diff line number Diff line { "Cgroups": [ { "Controller": "blkio", "Path": "/dev/blkio", "Mode": "0775", "UID": "system", "GID": "system" }, { "Controller": "cpu", "Path": "/dev/cpuctl", Loading Loading @@ -32,12 +39,6 @@ { "Controller": "freezer", "Path": "." }, { "Controller": "io", "Path": ".", "NeedsActivation": true, "Optional": true } ] } Loading libprocessgroup/profiles/task_profiles.json +12 −106 Original line number Diff line number Diff line Loading @@ -76,24 +76,6 @@ "Name": "FreezerState", "Controller": "freezer", "File": "cgroup.freeze" }, { "Name": "BfqWeight", "Controller": "io", "File": "blkio.bfq.weight", "FileV2": "io.bfq.weight" }, { "Name": "CfqGroupIdle", "Controller": "io", "File": "blkio.group_idle", "FileV2": "io.group_idle" }, { "Name": "CfqWeight", "Controller": "io", "File": "blkio.weight", "FileV2": "io.weight" } ], Loading Loading @@ -457,30 +439,11 @@ "Name": "LowIoPriority", "Actions": [ { "Name": "SetAttribute", "Params": { "Name": "BfqWeight", "Value": "10", "Optional": "true" } }, { "Name": "SetAttribute", "Params": { "Name": "CfqGroupIdle", "Value": "0", "Optional": "true" } }, { "Name": "SetAttribute", "Name": "JoinCgroup", "Params": { "Name": "CfqWeight", "Value": "200", "Optional": "true" "Controller": "blkio", "Path": "background" } } ] Loading @@ -489,30 +452,11 @@ "Name": "NormalIoPriority", "Actions": [ { "Name": "SetAttribute", "Params": { "Name": "BfqWeight", "Value": "100", "Optional": "true" } }, { "Name": "SetAttribute", "Params": { "Name": "CfqGroupIdle", "Value": "0", "Optional": "true" } }, { "Name": "SetAttribute", "Name": "JoinCgroup", "Params": { "Name": "CfqWeight", "Value": "1000", "Optional": "true" "Controller": "blkio", "Path": "" } } ] Loading @@ -521,30 +465,11 @@ "Name": "HighIoPriority", "Actions": [ { "Name": "SetAttribute", "Params": { "Name": "BfqWeight", "Value": "100", "Optional": "true" } }, { "Name": "SetAttribute", "Params": { "Name": "CfqGroupIdle", "Value": "0", "Optional": "true" } }, { "Name": "SetAttribute", "Name": "JoinCgroup", "Params": { "Name": "CfqWeight", "Value": "1000", "Optional": "true" "Controller": "blkio", "Path": "" } } ] Loading @@ -553,30 +478,11 @@ "Name": "MaxIoPriority", "Actions": [ { "Name": "SetAttribute", "Params": { "Name": "BfqWeight", "Value": "100", "Optional": "true" } }, { "Name": "SetAttribute", "Params": { "Name": "CfqGroupIdle", "Value": "0", "Optional": "true" } }, { "Name": "SetAttribute", "Name": "JoinCgroup", "Params": { "Name": "CfqWeight", "Value": "1000", "Optional": "true" "Controller": "blkio", "Path": "" } } ] Loading rootdir/init.rc +20 −0 Original line number Diff line number Diff line Loading @@ -219,6 +219,26 @@ on init 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. mkdir /dev/blkio/background chown system system /dev/blkio chown system system /dev/blkio/background chown system system /dev/blkio/tasks chown system system /dev/blkio/background/tasks chown system system /dev/blkio/cgroup.procs chown system system /dev/blkio/background/cgroup.procs chmod 0664 /dev/blkio/tasks chmod 0664 /dev/blkio/background/tasks chmod 0664 /dev/blkio/cgroup.procs chmod 0664 /dev/blkio/background/cgroup.procs write /dev/blkio/blkio.weight 1000 write /dev/blkio/background/blkio.weight 200 write /dev/blkio/background/blkio.bfq.weight 10 write /dev/blkio/blkio.group_idle 0 write /dev/blkio/background/blkio.group_idle 0 restorecon_recursive /mnt mount configfs none /config nodev noexec nosuid Loading Loading
fs_mgr/libsnapshot/partition_cow_creator.cpp +17 −4 Original line number Diff line number Diff line Loading @@ -131,15 +131,28 @@ bool OptimizeSourceCopyOperation(const InstallOperation& operation, InstallOpera return is_optimized; } void WriteExtent(DmSnapCowSizeCalculator* sc, const chromeos_update_engine::Extent& de, bool WriteExtent(DmSnapCowSizeCalculator* sc, const chromeos_update_engine::Extent& de, unsigned int sectors_per_block) { const auto block_boundary = de.start_block() + de.num_blocks(); for (auto b = de.start_block(); b < block_boundary; ++b) { for (unsigned int s = 0; s < sectors_per_block; ++s) { const auto sector_id = b * sectors_per_block + s; // sector_id = b * sectors_per_block + s; uint64_t block_start_sector_id; if (__builtin_mul_overflow(b, sectors_per_block, &block_start_sector_id)) { LOG(ERROR) << "Integer overflow when calculating sector id (" << b << " * " << sectors_per_block << ")"; return false; } uint64_t sector_id; if (__builtin_add_overflow(block_start_sector_id, s, §or_id)) { LOG(ERROR) << "Integer overflow when calculating sector id (" << block_start_sector_id << " + " << s << ")"; return false; } sc->WriteSector(sector_id); } } return true; } std::optional<uint64_t> PartitionCowCreator::GetCowSize() { Loading Loading @@ -167,7 +180,7 @@ std::optional<uint64_t> PartitionCowCreator::GetCowSize() { // Allocate space for extra extents (if any). These extents are those that can be // used for error corrections or to store verity hash trees. for (const auto& de : extra_extents) { WriteExtent(&sc, de, sectors_per_block); if (!WriteExtent(&sc, de, sectors_per_block)) return std::nullopt; } if (update == nullptr) return sc.cow_size_bytes(); Loading @@ -182,7 +195,7 @@ std::optional<uint64_t> PartitionCowCreator::GetCowSize() { } for (const auto& de : written_op->dst_extents()) { WriteExtent(&sc, de, sectors_per_block); if (!WriteExtent(&sc, de, sectors_per_block)) return std::nullopt; } } Loading
libprocessgroup/profiles/cgroups.json +7 −6 Original line number Diff line number Diff line { "Cgroups": [ { "Controller": "blkio", "Path": "/dev/blkio", "Mode": "0775", "UID": "system", "GID": "system" }, { "Controller": "cpu", "Path": "/dev/cpuctl", Loading Loading @@ -32,12 +39,6 @@ { "Controller": "freezer", "Path": "." }, { "Controller": "io", "Path": ".", "NeedsActivation": true, "Optional": true } ] } Loading
libprocessgroup/profiles/task_profiles.json +12 −106 Original line number Diff line number Diff line Loading @@ -76,24 +76,6 @@ "Name": "FreezerState", "Controller": "freezer", "File": "cgroup.freeze" }, { "Name": "BfqWeight", "Controller": "io", "File": "blkio.bfq.weight", "FileV2": "io.bfq.weight" }, { "Name": "CfqGroupIdle", "Controller": "io", "File": "blkio.group_idle", "FileV2": "io.group_idle" }, { "Name": "CfqWeight", "Controller": "io", "File": "blkio.weight", "FileV2": "io.weight" } ], Loading Loading @@ -457,30 +439,11 @@ "Name": "LowIoPriority", "Actions": [ { "Name": "SetAttribute", "Params": { "Name": "BfqWeight", "Value": "10", "Optional": "true" } }, { "Name": "SetAttribute", "Params": { "Name": "CfqGroupIdle", "Value": "0", "Optional": "true" } }, { "Name": "SetAttribute", "Name": "JoinCgroup", "Params": { "Name": "CfqWeight", "Value": "200", "Optional": "true" "Controller": "blkio", "Path": "background" } } ] Loading @@ -489,30 +452,11 @@ "Name": "NormalIoPriority", "Actions": [ { "Name": "SetAttribute", "Params": { "Name": "BfqWeight", "Value": "100", "Optional": "true" } }, { "Name": "SetAttribute", "Params": { "Name": "CfqGroupIdle", "Value": "0", "Optional": "true" } }, { "Name": "SetAttribute", "Name": "JoinCgroup", "Params": { "Name": "CfqWeight", "Value": "1000", "Optional": "true" "Controller": "blkio", "Path": "" } } ] Loading @@ -521,30 +465,11 @@ "Name": "HighIoPriority", "Actions": [ { "Name": "SetAttribute", "Params": { "Name": "BfqWeight", "Value": "100", "Optional": "true" } }, { "Name": "SetAttribute", "Params": { "Name": "CfqGroupIdle", "Value": "0", "Optional": "true" } }, { "Name": "SetAttribute", "Name": "JoinCgroup", "Params": { "Name": "CfqWeight", "Value": "1000", "Optional": "true" "Controller": "blkio", "Path": "" } } ] Loading @@ -553,30 +478,11 @@ "Name": "MaxIoPriority", "Actions": [ { "Name": "SetAttribute", "Params": { "Name": "BfqWeight", "Value": "100", "Optional": "true" } }, { "Name": "SetAttribute", "Params": { "Name": "CfqGroupIdle", "Value": "0", "Optional": "true" } }, { "Name": "SetAttribute", "Name": "JoinCgroup", "Params": { "Name": "CfqWeight", "Value": "1000", "Optional": "true" "Controller": "blkio", "Path": "" } } ] Loading
rootdir/init.rc +20 −0 Original line number Diff line number Diff line Loading @@ -219,6 +219,26 @@ on init 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. mkdir /dev/blkio/background chown system system /dev/blkio chown system system /dev/blkio/background chown system system /dev/blkio/tasks chown system system /dev/blkio/background/tasks chown system system /dev/blkio/cgroup.procs chown system system /dev/blkio/background/cgroup.procs chmod 0664 /dev/blkio/tasks chmod 0664 /dev/blkio/background/tasks chmod 0664 /dev/blkio/cgroup.procs chmod 0664 /dev/blkio/background/cgroup.procs write /dev/blkio/blkio.weight 1000 write /dev/blkio/background/blkio.weight 200 write /dev/blkio/background/blkio.bfq.weight 10 write /dev/blkio/blkio.group_idle 0 write /dev/blkio/background/blkio.group_idle 0 restorecon_recursive /mnt mount configfs none /config nodev noexec nosuid Loading