Skip to main content

ExclusiveSession

Struct ExclusiveSession 

Source
pub struct ExclusiveSession { /* private fields */ }
Expand description

A cooperatively exclusive, transactionally staged DAMON session.

The session holds the advisory lock for its entire lifetime. It verifies the staged configuration and the running kdamond identity around runtime commands, and restores the preceding stopped hierarchy on Self::close. Kernel-updated sampling and aggregation interval leaves are treated as volatile while interval auto-tuning is enabled. Runtime update and result-materialization methods require mutable access, preventing concurrent command and read sequences within one session. Controllers that ignore the advisory lock can still race this API because the kernel provides no ownership primitive.

Implementations§

Source§

impl ExclusiveSession

Source

pub fn start(&mut self) -> Result<()>

Starts the staged kdamond and records its kernel-thread identity.

Source

pub fn stop(&mut self) -> Result<()>

Stops the kdamond while retaining the staged configuration and lock.

Source

pub fn close(self) -> Result<()>

Stops the kdamond and restores the hierarchy that preceded the session.

Unlike Drop, this method reports restoration failures.

Source

pub fn is_running(&self) -> Result<bool>

Returns whether this session’s identified kdamond is still running.

Source

pub fn configuration(&self) -> Result<DamonConfig>

Reads the complete staged configuration after verifying ownership.

Source

pub fn observed_configuration(&self) -> Result<ObservedConfiguration>

Reads the known typed hierarchy and all writable values after verification.

Source

pub fn capabilities( &self, context_index: usize, scheme_index: usize, ) -> Result<Capabilities>

Discovers capabilities for a staged context and scheme without mutation.

Source

pub fn commit(&mut self) -> Result<()>

Applies the currently staged inputs to the running kdamond.

The session refuses untracked sysfs changes. Use Self::update_configuration to stage and commit a changed owned configuration while preserving rollback and ownership checks.

Source

pub fn update_configuration(&mut self, config: &DamonConfig) -> Result<()>

Transactionally stages and commits a changed running configuration.

The requested hierarchy must still contain this session’s one runnable kdamond. Obsolete targets must match the preceding target at the same index. Their one-shot markers are removed from the staged hierarchy after a successful commit, and scheme target-filter indexes refer to the retained post-commit target list. On failure, the method stages and commits the preceding owned configuration before returning the error. Controllers that ignore the advisory lock can still interfere because sysfs has no ownership or atomic-commit primitive.

Source

pub fn update_scheme_quota_goals( &mut self, context_index: usize, scheme_index: usize, goals: &[QuotaGoalConfig], ) -> Result<()>

Transactionally replaces one scheme’s quota goals and commits only quota-goal inputs to the running kdamond.

Source

pub fn pause(&mut self) -> Result<()>

Pauses the first monitoring context and commits the request.

Source

pub fn resume(&mut self) -> Result<()>

Resumes the first monitoring context and commits the request.

Source

pub fn pause_context(&mut self, context_index: usize) -> Result<()>

Pauses one monitoring context and commits the request.

Source

pub fn resume_context(&mut self, context_index: usize) -> Result<()>

Resumes one monitoring context and commits the request.

Source

pub fn scheme_stats( &mut self, context_index: usize, scheme_index: usize, ) -> Result<SchemeStats>

Refreshes and reads one scheme’s runtime statistics.

Source

pub fn cached_scheme_stats( &self, context_index: usize, scheme_index: usize, ) -> Result<SchemeStats>

Reads the last materialized scheme statistics without requesting a synchronous kernel refresh.

Source

pub fn tried_regions( &mut self, context_index: usize, scheme_index: usize, capacity_hint: usize, ) -> Result<RawSnapshot>

Materializes and reads one scheme’s tried regions in raw address units.

Source

pub fn cached_tried_regions( &self, context_index: usize, scheme_index: usize, capacity_hint: usize, ) -> Result<RawSnapshot>

Reads one scheme’s already materialized tried regions.

Source

pub fn tried_bytes_units( &mut self, context_index: usize, scheme_index: usize, ) -> Result<u64>

Refreshes and reads one scheme’s total tried size in core address units.

Source

pub fn cached_tried_bytes_units( &self, context_index: usize, scheme_index: usize, ) -> Result<u64>

Reads one scheme’s already materialized total tried units.

Source

pub fn effective_quota_units( &mut self, context_index: usize, scheme_index: usize, ) -> Result<u64>

Refreshes and reads one scheme’s effective quota in core address units.

Source

pub fn cached_effective_quota_units( &self, context_index: usize, scheme_index: usize, ) -> Result<u64>

Reads the last materialized effective quota without requesting a synchronous kernel refresh.

Source

pub fn runtime_batch<T>( &mut self, operation: impl FnOnce(&mut RuntimeBatch<'_>) -> Result<T>, ) -> Result<T>

Runs multiple runtime reads or refreshes under one pair of complete ownership checks.

Individual batch operations still verify the kdamond thread identity. The complete writable hierarchy is checked before and after the closure, reducing sysfs reads for polling loops without weakening the boundary checks. If both the closure and the final ownership check fail, the ownership error is returned because the closure’s outputs cannot be trusted.

Source

pub fn read_batch<T>( &self, operation: impl FnOnce(&mut RuntimeReadBatch<'_>) -> Result<T>, ) -> Result<T>

Runs cached reads under one pair of complete ownership checks.

Source

pub fn update_tuned_intervals(&mut self) -> Result<()>

Refreshes auto-tuned interval values for the running kdamond.

Source

pub fn clear_tried_regions(&mut self) -> Result<()>

Clears all materialized tried-region results.

Trait Implementations§

Source§

impl Debug for ExclusiveSession

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.