Zephyr API 3.6.99
Loading...
Searching...
No Matches
demand_paging.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_KERNEL_MM_DEMAND_PAGING_H
8#define ZEPHYR_INCLUDE_KERNEL_MM_DEMAND_PAGING_H
9
10#include <zephyr/kernel/mm.h>
11
12#include <zephyr/sys/util.h>
13#include <zephyr/toolchain.h>
14
26#ifndef _ASMLANGUAGE
27#include <stdint.h>
28#include <stddef.h>
29#include <inttypes.h>
30#include <zephyr/sys/__assert.h>
31
32struct k_mem_page_frame;
33
38#if defined(CONFIG_DEMAND_PAGING_STATS) || defined(__DOXYGEN__)
39 struct {
41 unsigned long cnt;
42
44 unsigned long irq_locked;
45
47 unsigned long irq_unlocked;
48
49#if !defined(CONFIG_DEMAND_PAGING_ALLOW_IRQ) || defined(__DOXYGEN__)
51 unsigned long in_isr;
52#endif /* !CONFIG_DEMAND_PAGING_ALLOW_IRQ */
54
55 struct {
57 unsigned long clean;
58
60 unsigned long dirty;
62#endif /* CONFIG_DEMAND_PAGING_STATS */
63};
64
69#if defined(CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM) || defined(__DOXYGEN__)
70 /* Counts for each bin in timing histogram */
71 unsigned long counts[CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS];
72
73 /* Bounds for the bins in timing histogram,
74 * excluding the first and last (hence, NUM_SLOTS - 1).
75 */
76 unsigned long bounds[CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS];
77#endif /* CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM */
78};
79
80#ifdef __cplusplus
81extern "C" {
82#endif
83
107int k_mem_page_out(void *addr, size_t size);
108
122void k_mem_page_in(void *addr, size_t size);
123
137void k_mem_pin(void *addr, size_t size);
138
149void k_mem_unpin(void *addr, size_t size);
150
159__syscall void k_mem_paging_stats_get(struct k_mem_paging_stats_t *stats);
160
161struct k_thread;
171__syscall
173 struct k_mem_paging_stats_t *stats);
174
184 struct k_mem_paging_histogram_t *hist);
185
195 struct k_mem_paging_histogram_t *hist);
196
206 struct k_mem_paging_histogram_t *hist);
207
208#include <zephyr/syscalls/demand_paging.h>
209
233void k_mem_paging_eviction_add(struct k_mem_page_frame *pf);
234
248void k_mem_paging_eviction_remove(struct k_mem_page_frame *pf);
249
263
280struct k_mem_page_frame *k_mem_paging_eviction_select(bool *dirty);
281
290
336int k_mem_paging_backing_store_location_get(struct k_mem_page_frame *pf,
337 uintptr_t *location,
338 bool page_fault);
339
351
367
380
393
414void k_mem_paging_backing_store_page_finalize(struct k_mem_page_frame *pf,
415 uintptr_t location);
416
431
434#ifdef __cplusplus
435}
436#endif
437
438#endif /* !_ASMLANGUAGE */
439#endif /* ZEPHYR_INCLUDE_KERNEL_MM_DEMAND_PAGING_H */
int k_mem_paging_backing_store_location_get(struct k_mem_page_frame *pf, uintptr_t *location, bool page_fault)
Reserve or fetch a storage location for a data page loaded into a page frame.
int k_mem_paging_backing_store_location_query(void *addr, uintptr_t *location)
Obtain persistent location token for on-demand content.
void k_mem_paging_backing_store_page_out(uintptr_t location)
Copy a data page from K_MEM_SCRATCH_PAGE to the specified location.
void k_mem_paging_backing_store_location_free(uintptr_t location)
Free a backing store location.
void k_mem_paging_backing_store_init(void)
Backing store initialization function.
void k_mem_paging_backing_store_page_finalize(struct k_mem_page_frame *pf, uintptr_t location)
Update internal accounting after a page-in.
void k_mem_paging_backing_store_page_in(uintptr_t location)
Copy a data page from the provided location to K_MEM_SCRATCH_PAGE.
void k_mem_paging_eviction_remove(struct k_mem_page_frame *pf)
Remove a page frame from potential eviction candidates.
void k_mem_paging_eviction_accessed(uintptr_t phys)
Process a page frame as being newly accessed.
void k_mem_paging_eviction_init(void)
Initialization function.
void k_mem_paging_eviction_add(struct k_mem_page_frame *pf)
Submit a page frame for eviction candidate tracking.
struct k_mem_page_frame * k_mem_paging_eviction_select(bool *dirty)
Select a page frame for eviction.
int k_mem_page_out(void *addr, size_t size)
Evict a page-aligned virtual memory region to the backing store.
void k_mem_paging_histogram_backing_store_page_in_get(struct k_mem_paging_histogram_t *hist)
Get the backing store page-in timing histogram.
void k_mem_unpin(void *addr, size_t size)
Un-pin an aligned virtual data region.
void k_mem_paging_stats_get(struct k_mem_paging_stats_t *stats)
Get the paging statistics since system startup.
void k_mem_pin(void *addr, size_t size)
Pin an aligned virtual data region, paging in as necessary.
void k_mem_page_in(void *addr, size_t size)
Load a virtual data region into memory.
void k_mem_paging_histogram_backing_store_page_out_get(struct k_mem_paging_histogram_t *hist)
Get the backing store page-out timing histogram.
void k_mem_paging_histogram_eviction_get(struct k_mem_paging_histogram_t *hist)
Get the eviction timing histogram.
void k_mem_paging_thread_stats_get(struct k_thread *thread, struct k_mem_paging_stats_t *stats)
Get the paging statistics since system startup for a thread.
__UINTPTR_TYPE__ uintptr_t
Definition stdint.h:105
Paging Statistics Histograms.
Definition demand_paging.h:68
unsigned long counts[CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS]
Definition demand_paging.h:71
unsigned long bounds[CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS]
Definition demand_paging.h:76
Paging Statistics.
Definition demand_paging.h:37
struct k_mem_paging_stats_t::@309 eviction
unsigned long in_isr
Number of page faults while in ISR.
Definition demand_paging.h:51
unsigned long irq_unlocked
Number of page faults with IRQ unlocked.
Definition demand_paging.h:47
unsigned long cnt
Number of page faults.
Definition demand_paging.h:41
unsigned long dirty
Number of dirty pages selected for eviction.
Definition demand_paging.h:60
unsigned long clean
Number of clean pages selected for eviction.
Definition demand_paging.h:57
struct k_mem_paging_stats_t::@308 pagefaults
unsigned long irq_locked
Number of page faults with IRQ locked.
Definition demand_paging.h:44
Thread Structure.
Definition thread.h:259
Misc utilities.
Macros to abstract toolchain specific capabilities.