Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
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
36#if defined(CONFIG_DEMAND_PAGING_STATS) || defined(__DOXYGEN__)
37 struct {
39 unsigned long cnt;
40
42 unsigned long irq_locked;
43
45 unsigned long irq_unlocked;
46
47#if !defined(CONFIG_DEMAND_PAGING_ALLOW_IRQ) || defined(__DOXYGEN__)
49 unsigned long in_isr;
50#endif /* !CONFIG_DEMAND_PAGING_ALLOW_IRQ */
52
53 struct {
55 unsigned long clean;
56
58 unsigned long dirty;
60#endif /* CONFIG_DEMAND_PAGING_STATS */
61};
62
67#if defined(CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM) || defined(__DOXYGEN__)
68 /* Counts for each bin in timing histogram */
69 unsigned long counts[CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS];
70
71 /* Bounds for the bins in timing histogram,
72 * excluding the first and last (hence, NUM_SLOTS - 1).
73 */
74 unsigned long bounds[CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS];
75#endif /* CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM */
76};
77
78#ifdef __cplusplus
79extern "C" {
80#endif
81
105int k_mem_page_out(void *addr, size_t size);
106
120void k_mem_page_in(void *addr, size_t size);
121
135void k_mem_pin(void *addr, size_t size);
136
147void k_mem_unpin(void *addr, size_t size);
148
157__syscall void k_mem_paging_stats_get(struct k_mem_paging_stats_t *stats);
158
159struct k_thread;
169__syscall
171 struct k_mem_paging_stats_t *stats);
172
182 struct k_mem_paging_histogram_t *hist);
183
193 struct k_mem_paging_histogram_t *hist);
194
204 struct k_mem_paging_histogram_t *hist);
205
206#include <syscalls/demand_paging.h>
207
232struct z_page_frame *k_mem_paging_eviction_select(bool *dirty);
233
242
288int k_mem_paging_backing_store_location_get(struct z_page_frame *pf,
289 uintptr_t *location,
290 bool page_fault);
291
303
316
329
350void k_mem_paging_backing_store_page_finalize(struct z_page_frame *pf,
351 uintptr_t location);
352
367
370#ifdef __cplusplus
371}
372#endif
373
374#endif /* !_ASMLANGUAGE */
375#endif /* ZEPHYR_INCLUDE_KERNEL_MM_DEMAND_PAGING_H */
void k_mem_paging_backing_store_page_finalize(struct z_page_frame *pf, uintptr_t location)
Update internal accounting after a page-in.
void k_mem_paging_backing_store_page_out(uintptr_t location)
Copy a data page from Z_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_in(uintptr_t location)
Copy a data page from the provided location to Z_SCRATCH_PAGE.
int k_mem_paging_backing_store_location_get(struct z_page_frame *pf, uintptr_t *location, bool page_fault)
Reserve or fetch a storage location for a data page loaded into a page frame.
struct z_page_frame * k_mem_paging_eviction_select(bool *dirty)
Select a page frame for eviction.
void k_mem_paging_eviction_init(void)
Initialization function.
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:66
unsigned long counts[CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS]
Definition: demand_paging.h:69
unsigned long bounds[CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS]
Definition: demand_paging.h:74
Paging Statistics.
Definition: demand_paging.h:35
unsigned long in_isr
Number of page faults while in ISR.
Definition: demand_paging.h:49
unsigned long irq_unlocked
Number of page faults with IRQ unlocked.
Definition: demand_paging.h:45
unsigned long cnt
Number of page faults.
Definition: demand_paging.h:39
unsigned long dirty
Number of dirty pages selected for eviction.
Definition: demand_paging.h:58
unsigned long clean
Number of clean pages selected for eviction.
Definition: demand_paging.h:55
struct k_mem_paging_stats_t::@253 pagefaults
struct k_mem_paging_stats_t::@254 eviction
unsigned long irq_locked
Number of page faults with IRQ locked.
Definition: demand_paging.h:42
Thread Structure.
Definition: thread.h:259
Macros to abstract toolchain specific capabilities.
Misc utilities.