Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kernel/src/arch/x86/pmu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ use ostd::{
},
path,
};
use serde::Serialize;
use snafu::Whatever;

use crate::util::timer::TimerServer;

/// Data TLB Misses instance struct
#[derive(Debug, Clone, Copy)]
#[expect(dead_code)]
#[derive(Debug, Clone, Copy, Serialize)]
struct DtlbMisses {
timestamp: Instant,
miss_l1_tlb: u64,
Expand Down
3 changes: 2 additions & 1 deletion kernel/src/thread/exception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use aster_rights::Full;
use ostd::cpu::context::{CpuExceptionInfo, UserContext};
use serde::Serialize;

use crate::{
current_userspace,
Expand All @@ -17,7 +18,7 @@ use crate::{
/// `From<CpuExceptionInfo>` should be implemented for this struct.
/// If `CpuExceptionInfo` is a page fault, `try_from` should return `Ok(PageFaultInfo)`,
/// or `Err(())` (no error information) otherwise.
#[derive(Clone, Copy)]
#[derive(Clone, Copy, Serialize)]
pub struct PageFaultInfo {
/// The virtual address where a page fault occurred.
pub address: Vaddr,
Expand Down
2 changes: 1 addition & 1 deletion kernel/src/vm/hugepaged.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use ostd::orpc::{
};
use snafu::Whatever;

use super::{promote_hugepages, vmar::PageFaultOQueueMessage};
use super::{promote_hugepages, vmar::oqueues::PageFaultOQueueMessage};
use crate::{process::Process, util::timer::TimerServer, vm::vmar};

#[orpc_trait]
Expand Down
5 changes: 4 additions & 1 deletion kernel/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ use ostd::{
mm::{FrameAllocOptions, PageFlags, PageProperty, PagingConsts, UFrame, UntypedMem, page_size},
task::disable_preempt,
};
use vmar::{PageFaultOQueueMessage, RssType};
use vmar::RssType;

use crate::{
INITPROC, Vec,
process::{PauseProcGuard, Process},
};
#[cfg(not(baseline_asterinas))]
pub mod hugepaged;
#[cfg(not(baseline_asterinas))]
use vmar::oqueues::PageFaultOQueueMessage;

pub mod page_fault_handler;
pub mod perms;
Expand Down Expand Up @@ -108,6 +110,7 @@ pub fn num_anon_hugepages() -> i32 {
count
}

#[cfg(not(baseline_asterinas))]
fn promote_hugepages(
proc: &Arc<Process>,
fault_hint: Option<PageFaultOQueueMessage>,
Expand Down
2 changes: 2 additions & 0 deletions kernel/src/vm/perms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
use aster_rights::Rights;
use bitflags::bitflags;
use ostd::mm::PageFlags;
use serde::Serialize;

bitflags! {
/// The memory access permissions of memory mappings.
#[derive(Serialize)]
pub struct VmPerms: u32 {
/// Readable.
const READ = 1 << 0;
Expand Down
47 changes: 25 additions & 22 deletions kernel/src/vm/vmar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,35 +188,35 @@ impl<R> Vmar<R> {
}
}

// TODO(aneesh) can this just be PageFaultInfo directly?
/// Notification message to inform policies about a page fault
#[derive(Clone, Copy)]
pub struct PageFaultOQueueMessage {
/// Opaque identifier for which vm_space the fault corresponds to
pub vm_space_id: u64,
/// The fault information provided to the page fault handler
pub fault_info: PageFaultInfo,
}

#[cfg(not(baseline_asterinas))]
pub mod oqueues {
use alloc::sync::Arc;
use core::{sync::atomic::AtomicUsize, time::Duration};

use ostd::orpc::legacy_oqueue::ringbuffer::MPMCOQueue;
use serde::Serialize;
use spin::Once;

use super::PageFaultOQueueMessage;
use crate::{Clock, time::clocks::MonotonicRawClock};

// TODO(aneesh) can this just be PageFaultInfo directly?
/// Notification message to inform policies about a page fault
#[derive(Clone, Copy, Serialize)]
pub struct PageFaultOQueueMessage {
/// Opaque identifier for which vm_space the fault corresponds to
pub vm_space_id: u64,
/// The fault information provided to the page fault handler
pub fault_info: super::PageFaultInfo,
}

// TODO(aneesh): Move this somewhere more generic
#[derive(Clone, Copy)]
pub struct ObservableEvent<T> {
#[derive(Clone, Copy, Serialize)]
pub struct ObservableEvent<T: Serialize> {
pub event: T,
pub timestamp: Duration,
}

impl<T> ObservableEvent<T> {
impl<T: Serialize> ObservableEvent<T> {
pub fn new(event: T) -> Self {
Self {
event,
Expand Down Expand Up @@ -245,9 +245,9 @@ pub mod oqueues {
pub fn init() {
#[cfg(not(baseline_asterinas))]
{
// Only support a single strong observer for now - hugepaged.
oqueues::PAGE_FAULT_OQUEUE.call_once(|| MPMCOQueue::new(64, 1));
oqueues::RSS_DELTA_OQUEUE.call_once(|| MPMCOQueue::new(64, 1));
// Supports two strong observers for now - hugepaged and data collection.
oqueues::PAGE_FAULT_OQUEUE.call_once(|| MPMCOQueue::new(1024, 2));
oqueues::RSS_DELTA_OQUEUE.call_once(|| MPMCOQueue::new(1024, 2));
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why you needed to increase these sizes? It's fine, I just want to understand to help me make decisions as the framework solidifies over the summer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things were filling up and blocking with the smaller capacity.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any more specifics on why they were filling up?

}

Expand All @@ -266,7 +266,8 @@ pub(super) struct Vmar_ {

/// OQueue Producer to notify policies about page fault events
#[cfg(not(baseline_asterinas))]
page_fault_oqueue_producer: OQueueRef<oqueues::ObservableEvent<PageFaultOQueueMessage>>,
page_fault_oqueue_producer:
OQueueRef<oqueues::ObservableEvent<oqueues::PageFaultOQueueMessage>>,
}

struct VmarInner {
Expand Down Expand Up @@ -661,10 +662,12 @@ impl Vmar_ {
#[cfg(not(baseline_asterinas))]
if res.is_ok() {
self.page_fault_oqueue_producer
.produce(oqueues::ObservableEvent::new(PageFaultOQueueMessage {
vm_space_id: self.vm_space.id(),
fault_info: *page_fault_info,
}))?;
.produce(oqueues::ObservableEvent::new(
oqueues::PageFaultOQueueMessage {
vm_space_id: self.vm_space.id(),
fault_info: *page_fault_info,
},
))?;
}
return res;
}
Expand Down
3 changes: 2 additions & 1 deletion test/benchmark/common/prepare_host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ prepare_ycsb() {
fi

if [ ! -d "$YCSB_PATH" ]; then
git clone https://github.com/brianfrankcooper/YCSB --depth=1 $YCSB_PATH
# Use custom fork of YCSB with delete support
git clone https://github.com/tewaro/YCSB.git -b tewaro/quickfix-coreworkload-deletes-master --depth=1 $YCSB_PATH

# Build
pushd $YCSB_PATH
Expand Down
37 changes: 35 additions & 2 deletions test/benchmark/redis/ycsb/host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ set -e
# Function to stop the guest VM
stop_guest() {
echo "Stopping guest VM..."
# The message doesn't matter here, any data will make the vm exit
echo stop | nc 10.0.2.15 5201
sleep 15
# `-r` means if there's no qemu, the kill won't be executed
pgrep qemu | xargs -r kill
}
Expand All @@ -22,7 +25,37 @@ echo "Running YCSB bench connected to $GUEST_SERVER_IP_ADDRESS"
export JAVA_HOME=$(realpath ".cache/jdk-25.0.2")

cd $YCSB_PATH/
./bin/ycsb load redis -p redis.host="$GUEST_SERVER_IP_ADDRESS" -p redis.port="6379" -P ./workloads/workloada
./bin/ycsb run redis -p redis.host="$GUEST_SERVER_IP_ADDRESS" -p redis.port="6379" -P ./workloads/workloada

FIELDLENGTH=4096



./bin/ycsb load redis -p redis.host="$GUEST_SERVER_IP_ADDRESS" -p redis.port="6379" -P ./workloads/workloada \
-p recordcount=4096 \
-p fieldcount=1 \
-p fieldlength=$FIELDLENGTH \
-p minfieldlength=4096 \
-p insertstart=0 \
-p fieldlengthdistribution=uniform

# Run many times to stress memory allocation
for _ in $(seq 1 4096); do
Comment thread
aneeshdurg marked this conversation as resolved.
./bin/ycsb run redis -p redis.host="$GUEST_SERVER_IP_ADDRESS" -p redis.port="6379" -P ./workloads/workloada \
-p operationcount=4096 \
-p recordcount=4096 \
-p workload=site.ycsb.workloads.CoreWorkload \
-p readproportion=0.05 \
-p updateproportion=0.00 \
-p scanproportion=0.00 \
-p insertproportion=0.00 \
-p readmodifywriteproportion=0.00 \
-p scanproportion=0.00 \
-p deleteproportion=0.95 \
-p threadcount=16 \
-p fieldcount=1 \
-p fieldlength=$FIELDLENGTH \
-p minfieldlength=4096 \
-p fieldlengthdistribution=uniform
done

# The trap will automatically stop the guest VM when the script exits
7 changes: 4 additions & 3 deletions test/benchmark/redis/ycsb/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

# SPDX-License-Identifier: MPL-2.0

set -e

echo "Running redis server"
/usr/local/redis/bin/redis-server /benchmark/redis/ycsb/ycsb.conf
/usr/local/redis/bin/redis-server /benchmark/redis/ycsb/ycsb.conf &
echo "waiting for stop message"
/bin/nc -l -s 10.0.2.15 -p 5201 -e true
echo "done"
Comment thread
arthurp marked this conversation as resolved.
3 changes: 3 additions & 0 deletions tools/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ RUN apt update && apt-get install -y --no-install-recommends \
unzip \
zip

# Install netcat for clean shutdown of benchmarks
# see test/benchmark/redis/ycsb/host.sh for example usage
RUN apt-get install -y --no-install -recommends netcat-openbsd
Comment thread
arthurp marked this conversation as resolved.

#= Install linux-modules for vdso and linux config =================================
# TODO: This is very wasteful and maybe fragile. We should have our own custom vDSO.
Expand Down
Loading