pub struct EXAMPLE_PERCPU_DATA_WRAPPER {}Expand description
Wrapper struct for the per-CPU data EXAMPLE_PERCPU_DATA
Implementations§
Source§impl EXAMPLE_PERCPU_DATA_WRAPPER
impl EXAMPLE_PERCPU_DATA_WRAPPER
Sourcepub fn symbol_vma(&self) -> usize
pub fn symbol_vma(&self) -> usize
Returns the virtual memory address of this per-CPU static
variable in the .percpu section.
It’s same across all CPUs, and also the same as offset if the
“non-zero-vma” feature is not enabled.
Sourcepub unsafe fn current_ptr(&self) -> *const usize
pub unsafe fn current_ptr(&self) -> *const usize
Returns the raw pointer of this per-CPU static variable on the current CPU.
§Safety
Caller must ensure that preemption is disabled on the current CPU.
Sourcepub unsafe fn current_ref_raw(&self) -> &usize
pub unsafe fn current_ref_raw(&self) -> &usize
Returns the reference of the per-CPU static variable on the current CPU.
§Safety
Caller must ensure that preemption is disabled on the current CPU.
Sourcepub unsafe fn current_ref_mut_raw(&self) -> &mut usize
pub unsafe fn current_ref_mut_raw(&self) -> &mut usize
Returns the mutable reference of the per-CPU static variable on the current CPU.
§Safety
Caller must ensure that preemption is disabled on the current CPU.
Sourcepub fn with_current<F, T>(&self, f: F) -> T
pub fn with_current<F, T>(&self, f: F) -> T
Manipulate the per-CPU data on the current CPU in the given closure. Preemption will be disabled during the call.
Sourcepub unsafe fn remote_ptr(&self, cpu_id: usize) -> *const usize
pub unsafe fn remote_ptr(&self, cpu_id: usize) -> *const usize
Returns the raw pointer of this per-CPU static variable on the given CPU.
§Safety
Caller must ensure that
- the CPU ID is valid, and
- data races will not happen.
Sourcepub unsafe fn remote_ref_raw(&self, cpu_id: usize) -> &usize
pub unsafe fn remote_ref_raw(&self, cpu_id: usize) -> &usize
Returns the reference of the per-CPU static variable on the given CPU.
§Safety
Caller must ensure that
- the CPU ID is valid, and
- data races will not happen.
Sourcepub unsafe fn remote_ref_mut_raw(&self, cpu_id: usize) -> &mut usize
pub unsafe fn remote_ref_mut_raw(&self, cpu_id: usize) -> &mut usize
Returns the mutable reference of the per-CPU static variable on the given CPU.
§Safety
Caller must ensure that
- the CPU ID is valid, and
- data races will not happen.
Sourcepub unsafe fn read_current_raw(&self) -> usize
pub unsafe fn read_current_raw(&self) -> usize
Returns the value of the per-CPU static variable on the current CPU.
§Safety
Caller must ensure that preemption is disabled on the current CPU.
Sourcepub unsafe fn write_current_raw(&self, val: usize)
pub unsafe fn write_current_raw(&self, val: usize)
Set the value of the per-CPU static variable on the current CPU.
§Safety
Caller must ensure that preemption is disabled on the current CPU.
Sourcepub fn read_current(&self) -> usize
pub fn read_current(&self) -> usize
Returns the value of the per-CPU static variable on the current CPU. Preemption will be disabled during the call.
Sourcepub fn write_current(&self, val: usize)
pub fn write_current(&self, val: usize)
Set the value of the per-CPU static variable on the current CPU. Preemption will be disabled during the call.