Skip to content

Commit

Permalink
Set TaskInner.pinned_cpu when spawning pinned tasks (#1044)
Browse files Browse the repository at this point in the history
* When spawning a pinned task, `spawn` didn't previously set
  `inner.pinned_cpu` for the newly-created `Task`.

* This is not currently a problem because the scheduler doesn't perform
  task migration across CPUs, but when that gets enabled (in #1042),
  it would cause the pinning choice to be ignore by the scheduler.

Signed-off-by: Klimenty Tsoutsman <klim@tsoutsman.com>
  • Loading branch information
tsoutsman authored Sep 19, 2023
1 parent 7a8d64a commit cae8ca8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions kernel/spawn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ stack = { path = "../stack" }
cpu = { path = "../cpu" }
preemption = { path = "../preemption" }
task = { path = "../task" }
task_struct = { path = "../task_struct" }
runqueue = { path = "../runqueue" }
scheduler = { path = "../scheduler" }
mod_mgmt = { path = "../mod_mgmt" }
Expand Down
7 changes: 6 additions & 1 deletion kernel/spawn/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use spin::Mutex;
use memory::{get_kernel_mmi_ref, MmiRef};
use stack::Stack;
use task::{Task, TaskRef, RestartInfo, RunState, JoinableTaskRef, ExitableTaskRef, FailureCleanupFunction};
use task_struct::ExposedTask;
use mod_mgmt::{CrateNamespace, SectionType, SECTION_HASH_DELIMITER};
use path::Path;
use fs_node::FileOrDir;
Expand Down Expand Up @@ -381,7 +382,11 @@ impl<F, A, R> TaskBuilder<F, A, R>
)?;
// If a Task name wasn't provided, then just use the function's name.
new_task.name = self.name.unwrap_or_else(|| String::from(core::any::type_name::<F>()));


let exposed = ExposedTask { task: new_task };
exposed.inner().lock().pinned_cpu = self.pin_on_cpu;
let ExposedTask { task: mut new_task } = exposed;

#[cfg(simd_personality)] {
new_task.simd = self.simd;
}
Expand Down

0 comments on commit cae8ca8

Please sign in to comment.