Skip to content
This repository was archived by the owner on Jul 17, 2025. It is now read-only.

Commit b2981bd

Browse files
Erika Hunhoffhunhoffe
authored andcommitted
create polling method for client to ask for core requests from
controller, added integration test for remote core request
1 parent d8fc894 commit b2981bd

14 files changed

Lines changed: 438 additions & 103 deletions

File tree

kernel/run.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ def get_network_config(workers):
8080
# General build arguments
8181
parser.add_argument("-v", "--verbose", action="store_true",
8282
help="increase output verbosity")
83-
parser.add_argument("-n", "--norun", action="store_true",
84-
help="Only build, don't run")
83+
8584
parser.add_argument("-r", "--release", action="store_true",
8685
help="Do a release build.")
8786
parser.add_argument("--kfeatures", type=str, nargs='+', default=[],
@@ -97,6 +96,12 @@ def get_network_config(workers):
9796
parser.add_argument("--machine",
9897
help='Which machine to run on (defaults to qemu)', required=False, default='qemu')
9998

99+
parser_tasks_mut = parser.add_mutually_exclusive_group(required=False)
100+
parser_tasks_mut.add_argument("-n", "--norun", action="store_true", default=False,
101+
help="Only build, don't run")
102+
parser_tasks_mut.add_argument("-b", "--nobuild", action="store_true", default=False,
103+
help="Only run, don't build")
104+
100105

101106
# DCM Scheduler arguments
102107
parser.add_argument("--dcm-path",
@@ -812,11 +817,12 @@ def configure_dcm_scheduler(args):
812817
# Minimize python exception backtraces
813818
sys.excepthook = exception_handler
814819

815-
# Build
816-
build_bootloader(args)
817-
build_kernel(args)
818-
build_user_libraries(args)
819-
build_userspace(args)
820+
if not args.nobuild:
821+
# Build
822+
build_bootloader(args)
823+
build_kernel(args)
824+
build_user_libraries(args)
825+
build_userspace(args)
820826

821827
# Deploy
822828
deploy(args)

kernel/src/arch/x86_64/irq.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,16 @@ unsafe fn timer_handler(_a: &ExceptionArguments) {
503503
nrproc::NrProcess::<Ring3Process>::synchronize(pid);
504504
}
505505

506+
// If this is a rackscale client, check for work from the controller
507+
#[cfg(feature = "rackscale")]
508+
if crate::CMDLINE
509+
.get()
510+
.map_or(false, |c| c.mode == crate::cmdline::Mode::Client)
511+
{
512+
use crate::arch::rackscale::client::client_get_work;
513+
client_get_work();
514+
}
515+
506516
if super::process::has_executor() {
507517
// TODO(process-mgmt): Ensures that we still periodically
508518
// check and advance replicas even on cores that have a core.
@@ -529,7 +539,7 @@ unsafe fn timer_handler(_a: &ExceptionArguments) {
529539
r.resume()
530540
} else {
531541
// Go to scheduler instead
532-
//warn!("got a timer on core {}", *crate::kcb::CORE_ID);
542+
//warn!("got a timer on core {}", *crate::environment::CORE_ID);
533543
crate::scheduler::schedule()
534544
}
535545
}

kernel/src/arch/x86_64/rackscale/client.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use rpc::api::{RPCClient, RPCHandler, RegistrationHandler};
1111
use rpc::client::Client;
1212
use rpc::rpc::{ClientId, RPCError, RPCHeader};
1313

14+
use crate::arch::rackscale::processops::request_core::request_core_work;
1415
use crate::cmdline::Transport;
1516
use crate::error::KError;
1617
use crate::fs::NrLock;
@@ -68,3 +69,8 @@ pub(crate) fn get_num_clients() -> u64 {
6869
pub(crate) fn get_local_client_id() -> u64 {
6970
(crate::CMDLINE.get().map_or(1, |c| c.machine_id) - 1) as u64
7071
}
72+
73+
pub(crate) fn client_get_work() -> () {
74+
let mut client = RPC_CLIENT.lock();
75+
request_core_work(&mut **client);
76+
}

kernel/src/arch/x86_64/rackscale/controller.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33

44
use alloc::boxed::Box;
5+
use alloc::collections::vec_deque::VecDeque;
56
use alloc::sync::Arc;
67
use alloc::vec::Vec;
78
use core::cell::Cell;
@@ -20,6 +21,7 @@ use rpc::server::Server;
2021
use crate::arch::debug::shutdown;
2122
use crate::arch::rackscale::client::get_num_clients;
2223
use crate::arch::rackscale::dcm::*;
24+
use crate::arch::rackscale::processops::request_core::RequestCoreReq;
2325
use crate::cmdline::Transport;
2426
use crate::error::KError;
2527
use crate::fs::{cnrfs, NrLock};
@@ -62,6 +64,20 @@ lazy_static! {
6264
};
6365
}
6466

67+
// Keep track of unfulfilled core assignments
68+
lazy_static! {
69+
pub(crate) static ref UNFULFILLED_CORE_ASSIGNMENTS: Arc<Mutex<Vec<Box<VecDeque<RequestCoreReq>>>>> = {
70+
let mut core_assignments = Vec::try_with_capacity(get_num_clients() as usize)
71+
.expect("Failed to create vector for core requests");
72+
for i in 0..get_num_clients() {
73+
// TODO: how to size vector appropriately? No try method for VecDeque
74+
let mut client_core_assignments = VecDeque::with_capacity(3 as usize);
75+
core_assignments.push(Box::new(client_core_assignments))
76+
}
77+
Arc::new(Mutex::new(core_assignments))
78+
};
79+
}
80+
6581
/// Test TCP RPC-based controller
6682
pub(crate) fn run() {
6783
// Create network interface and clock
@@ -192,7 +208,14 @@ fn register_rpcs(server: &mut Box<dyn RPCServer>) {
192208
)
193209
.unwrap();
194210
server
195-
.register(KernelRpc::RequestCore as RPCType, &CORE_HANDLER)
211+
.register(KernelRpc::RequestCore as RPCType, &REQUEST_CORE_HANDLER)
212+
.unwrap();
213+
214+
server
215+
.register(
216+
KernelRpc::RequestWork as RPCType,
217+
&REQUEST_CORE_WORK_HANDLER,
218+
)
196219
.unwrap();
197220
}
198221

kernel/src/arch/x86_64/rackscale/kernelrpc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ pub(crate) enum KernelRpc {
5252
ReleasePhysical = 14,
5353
/// Allocate a core for a process
5454
RequestCore = 15,
55+
/// Request work (e.g., request cores) - used by client to ask controller for tasks
56+
RequestWork = 16,
5557
}
5658

5759
impl TryFrom<RPCType> for KernelRpc {
@@ -76,6 +78,7 @@ impl TryFrom<RPCType> for KernelRpc {
7678
13 => Ok(KernelRpc::AllocatePhysical),
7779
15 => Ok(KernelRpc::ReleasePhysical),
7880
15 => Ok(KernelRpc::RequestCore),
81+
16 => Ok(KernelRpc::RequestWork),
7982
_ => Err(KError::InvalidRpcType),
8083
}
8184
}

kernel/src/arch/x86_64/rackscale/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ pub(crate) const READ_HANDLER: RPCHandler = fileops::rw::handle_read;
3333
pub(crate) const WRITE_HANDLER: RPCHandler = fileops::rw::handle_write;
3434

3535
// Re-export handdlers: process operations
36-
pub(crate) const CORE_HANDLER: RPCHandler = processops::core::handle_request_core;
36+
pub(crate) const REQUEST_CORE_HANDLER: RPCHandler = processops::request_core::handle_request_core;
3737
pub(crate) const ALLOCATE_PHYSICAL_HANDLER: RPCHandler =
3838
processops::allocate_physical::handle_allocate_physical;
3939
pub(crate) const RELEASE_PHYSICAL_HANDLER: RPCHandler =
4040
processops::release_physical::handle_release_physical;
4141
pub(crate) const LOG_HANDLER: RPCHandler = processops::print::handle_log;
42+
43+
// Client polls for work
44+
pub(crate) const REQUEST_CORE_WORK_HANDLER: RPCHandler =
45+
processops::request_core::handle_request_core_work;

kernel/src/arch/x86_64/rackscale/processops/core.rs

Lines changed: 0 additions & 86 deletions
This file was deleted.

kernel/src/arch/x86_64/rackscale/processops/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
// SPDX-License-Identifier: Apache-2.0 OR MIT
33

44
pub mod allocate_physical;
5-
pub mod core;
65
pub mod print;
76
pub mod release_physical;
7+
pub mod request_core;

0 commit comments

Comments
 (0)