Skip to content
Snippets Groups Projects
Commit 47102b62 authored by Jiyong Park's avatar Jiyong Park Committed by Automerger Merge Worker
Browse files

Merge "Set task profile when running compilation VM" am: d41d2ebb am:...

Merge "Set task profile when running compilation VM" am: d41d2ebb am: d323514c am: f97c2cd6 am: bad6f570 am: a2ad75aa

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Virtualization/+/2067889



Change-Id: I6b163fe23ddbf3a613c3d133144f3a514fca949c
Ignore-AOSP-First: this is an automerge
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c14dd791 a2ad75aa
No related branches found
No related tags found
No related merge requests found
......@@ -64,6 +64,8 @@ pub struct VmParameters {
/// Comma separated list of host CPUs where vCPUs are assigned to. If None, any host CPU can be
/// used to run any vCPU.
pub cpu_set: Option<String>,
/// List of task profiles to apply to the VM
pub task_profiles: Vec<String>,
/// If present, overrides the path to the VM config JSON file
pub config_path: Option<String>,
/// If present, overrides the amount of RAM to give the VM
......@@ -137,6 +139,7 @@ impl VmInstance {
memoryMib: parameters.memory_mib.unwrap_or(0), // 0 means use the default
numCpus: parameters.cpus.map_or(1, NonZeroU32::get) as i32,
cpuAffinity: parameters.cpu_set.clone(),
taskProfiles: parameters.task_profiles.clone(),
});
let vm = service
......
......@@ -98,7 +98,14 @@ fn new_vm_parameters() -> Result<VmParameters> {
}
};
let cpu_set = system_properties::read(DEX2OAT_CPU_SET_PROP_NAME)?;
Ok(VmParameters { cpus, cpu_set, memory_mib: Some(VM_MEMORY_MIB), ..Default::default() })
let task_profiles = vec!["VMCompilationPerformance".to_string()];
Ok(VmParameters {
cpus,
cpu_set,
task_profiles,
memory_mib: Some(VM_MEMORY_MIB),
..Default::default()
})
}
// Ensures we only run one instance at a time.
......
......@@ -238,6 +238,9 @@ public final class VirtualMachineConfig {
parcel.memoryMib = mMemoryMib;
parcel.numCpus = mNumCpus;
parcel.cpuAffinity = mCpuAffinity;
// Don't allow apps to set task profiles ... at last for now. Also, don't forget to
// validate the string because these are appended to the cmdline argument.
parcel.taskProfiles = new String[0];
return parcel;
}
......
......@@ -67,4 +67,9 @@ parcelable VirtualMachineAppConfig {
* Default is no mask which means a vCPU can run on any host CPU.
*/
@nullable String cpuAffinity;
/**
* List of task profile names to apply for the VM
*/
String[] taskProfiles;
}
......@@ -63,4 +63,9 @@ parcelable VirtualMachineRawConfig {
* The format follows SemVer.
*/
@utf8InCpp String platformVersion;
/**
* List of task profile names to apply for the VM
*/
String[] taskProfiles;
}
......@@ -467,6 +467,7 @@ impl VirtualizationService {
memory_mib: config.memoryMib.try_into().ok().and_then(NonZeroU32::new),
cpus: config.numCpus.try_into().ok().and_then(NonZeroU32::new),
cpu_affinity: config.cpuAffinity.clone(),
task_profiles: config.taskProfiles.clone(),
console_fd,
log_fd,
indirect_files,
......@@ -634,6 +635,7 @@ fn load_app_config(
vm_config.protectedVm = config.protectedVm;
vm_config.numCpus = config.numCpus;
vm_config.cpuAffinity = config.cpuAffinity.clone();
vm_config.taskProfiles = config.taskProfiles.clone();
// Microdroid requires an additional payload disk image and the bootconfig partition.
if os_name == "microdroid" {
......
......@@ -64,6 +64,7 @@ pub struct CrosvmConfig {
pub memory_mib: Option<NonZeroU32>,
pub cpus: Option<NonZeroU32>,
pub cpu_affinity: Option<String>,
pub task_profiles: Vec<String>,
pub console_fd: Option<File>,
pub log_fd: Option<File>,
pub indirect_files: Vec<File>,
......@@ -326,6 +327,10 @@ fn run_vm(config: CrosvmConfig, failure_pipe_write: File) -> Result<SharedChild,
command.arg("--cpu-affinity").arg(cpu_affinity);
}
if !config.task_profiles.is_empty() {
command.arg("--task-profiles").arg(config.task_profiles.join(","));
}
// Keep track of what file descriptors should be mapped to the crosvm process.
let mut preserved_fds = config.indirect_files.iter().map(|file| file.as_raw_fd()).collect();
......
......@@ -92,6 +92,10 @@ enum Opt {
#[structopt(long)]
cpu_affinity: Option<String>,
/// Comma separated list of task profile names to apply to the VM
#[structopt(long)]
task_profiles: Vec<String>,
/// Paths to extra idsig files.
#[structopt(long = "extra-idsig")]
extra_idsigs: Vec<PathBuf>,
......@@ -118,6 +122,10 @@ enum Opt {
#[structopt(long)]
cpu_affinity: Option<String>,
/// Comma separated list of task profile names to apply to the VM
#[structopt(long)]
task_profiles: Vec<String>,
/// Path to file for VM console output.
#[structopt(long)]
console: Option<PathBuf>,
......@@ -200,6 +208,7 @@ fn main() -> Result<(), Error> {
mem,
cpus,
cpu_affinity,
task_profiles,
extra_idsigs,
} => command_run_app(
service,
......@@ -215,9 +224,10 @@ fn main() -> Result<(), Error> {
mem,
cpus,
cpu_affinity,
task_profiles,
&extra_idsigs,
),
Opt::Run { config, daemonize, cpus, cpu_affinity, console, log } => {
Opt::Run { config, daemonize, cpus, cpu_affinity, task_profiles, console, log } => {
command_run(
service,
&config,
......@@ -227,6 +237,7 @@ fn main() -> Result<(), Error> {
/* mem */ None,
cpus,
cpu_affinity,
task_profiles,
)
}
Opt::Stop { cid } => command_stop(service, cid),
......
......@@ -54,6 +54,7 @@ pub fn command_run_app(
mem: Option<u32>,
cpus: Option<u32>,
cpu_affinity: Option<String>,
task_profiles: Vec<String>,
extra_idsigs: &[PathBuf],
) -> Result<(), Error> {
let extra_apks = parse_extra_apk_list(apk, config_path)?;
......@@ -105,6 +106,7 @@ pub fn command_run_app(
memoryMib: mem.unwrap_or(0) as i32, // 0 means use the VM default
numCpus: cpus.unwrap_or(1) as i32,
cpuAffinity: cpu_affinity,
taskProfiles: task_profiles,
});
run(
service,
......@@ -127,6 +129,7 @@ pub fn command_run(
mem: Option<u32>,
cpus: Option<u32>,
cpu_affinity: Option<String>,
task_profiles: Vec<String>,
) -> Result<(), Error> {
let config_file = File::open(config_path).context("Failed to open config file")?;
let mut config =
......@@ -138,6 +141,7 @@ pub fn command_run(
config.numCpus = cpus as i32;
}
config.cpuAffinity = cpu_affinity;
config.taskProfiles = task_profiles;
run(
service,
&VirtualMachineConfig::RawConfig(config),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment