kernel: mmu: rename z_eviction* to k_mem_paging_eviction*
These functions and data structures are those that need to be implemented by eviction algorithm and application outside kernel. Promote them from z_* so these can be included in documentation. Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
231a1e75ab
commit
31c362d966
|
@ -742,7 +742,7 @@ config DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS
|
||||||
Defines the number of bins (buckets) in the histogram used for
|
Defines the number of bins (buckets) in the histogram used for
|
||||||
gathering execution timing information for demand paging.
|
gathering execution timing information for demand paging.
|
||||||
|
|
||||||
This requires z_eviction_histogram_bounds[] and
|
This requires k_mem_paging_eviction_histogram_bounds[] and
|
||||||
z_backing_store_histogram_bounds[] to define the upper bounds
|
z_backing_store_histogram_bounds[] to define the upper bounds
|
||||||
for each bin. See kernel/statistics.c for information.
|
for each bin. See kernel/statistics.c for information.
|
||||||
|
|
||||||
|
|
|
@ -503,6 +503,40 @@ __syscall void k_mem_paging_histogram_backing_store_page_out_get(
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Eviction algorithm APIs
|
||||||
|
*
|
||||||
|
* @defgroup mem-demand-paging-eviction Eviction Algorithm APIs
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select a page frame for eviction
|
||||||
|
*
|
||||||
|
* The kernel will invoke this to choose a page frame to evict if there
|
||||||
|
* are no free page frames.
|
||||||
|
*
|
||||||
|
* This function will never be called before the initial
|
||||||
|
* k_mem_paging_eviction_init().
|
||||||
|
*
|
||||||
|
* This function is invoked with interrupts locked.
|
||||||
|
*
|
||||||
|
* @param [out] Whether the page to evict is dirty
|
||||||
|
* @return The page frame to evict
|
||||||
|
*/
|
||||||
|
struct z_page_frame *k_mem_paging_eviction_select(bool *dirty);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialization function
|
||||||
|
*
|
||||||
|
* Called at POST_KERNEL to perform any necessary initialization tasks for the
|
||||||
|
* eviction algorithm. k_mem_paging_eviction_select() is guaranteed to never be
|
||||||
|
* called until this has returned, and this will only be called once.
|
||||||
|
*/
|
||||||
|
void k_mem_paging_eviction_init(void);
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -230,34 +230,6 @@ extern size_t z_free_page_count;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_DEMAND_PAGING
|
#ifdef CONFIG_DEMAND_PAGING
|
||||||
/*
|
|
||||||
* Eviction algorihm APIs
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Select a page frame for eviction
|
|
||||||
*
|
|
||||||
* The kernel will invoke this to choose a page frame to evict if there
|
|
||||||
* are no free page frames.
|
|
||||||
*
|
|
||||||
* This function will never be called before the initial z_eviction_init().
|
|
||||||
*
|
|
||||||
* This function is invoked with interrupts locked.
|
|
||||||
*
|
|
||||||
* @param [out] Whether the page to evict is dirty
|
|
||||||
* @return The page frame to evict
|
|
||||||
*/
|
|
||||||
struct z_page_frame *z_eviction_select(bool *dirty);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialization function
|
|
||||||
*
|
|
||||||
* Called at POST_KERNEL to perform any necessary initialization tasks for the
|
|
||||||
* eviction algorithm. z_eviction_select() is guaranteed to never be called
|
|
||||||
* until this has returned, and this will only be called once.
|
|
||||||
*/
|
|
||||||
void z_eviction_init(void);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Backing store APIs
|
* Backing store APIs
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -430,7 +430,7 @@ static int map_anon_page(void *addr, uint32_t flags)
|
||||||
bool dirty;
|
bool dirty;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
pf = z_eviction_select(&dirty);
|
pf = k_mem_paging_eviction_select(&dirty);
|
||||||
__ASSERT(pf != NULL, "failed to get a page frame");
|
__ASSERT(pf != NULL, "failed to get a page frame");
|
||||||
LOG_DBG("evicting %p at 0x%lx", pf->addr,
|
LOG_DBG("evicting %p at 0x%lx", pf->addr,
|
||||||
z_page_frame_to_phys(pf));
|
z_page_frame_to_phys(pf));
|
||||||
|
@ -791,7 +791,7 @@ void z_mem_manage_init(void)
|
||||||
z_paging_histogram_init();
|
z_paging_histogram_init();
|
||||||
#endif
|
#endif
|
||||||
z_backing_store_init();
|
z_backing_store_init();
|
||||||
z_eviction_init();
|
k_mem_paging_eviction_init();
|
||||||
#endif
|
#endif
|
||||||
#if __ASSERT_ON
|
#if __ASSERT_ON
|
||||||
page_frames_initialized = true;
|
page_frames_initialized = true;
|
||||||
|
@ -1162,7 +1162,7 @@ static inline struct z_page_frame *do_eviction_select(bool *dirty)
|
||||||
#endif /* CONFIG_DEMAND_PAGING_STATS_USING_TIMING_FUNCTIONS */
|
#endif /* CONFIG_DEMAND_PAGING_STATS_USING_TIMING_FUNCTIONS */
|
||||||
#endif /* CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM */
|
#endif /* CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM */
|
||||||
|
|
||||||
pf = z_eviction_select(dirty);
|
pf = k_mem_paging_eviction_select(dirty);
|
||||||
|
|
||||||
#ifdef CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM
|
#ifdef CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM
|
||||||
#ifdef CONFIG_DEMAND_PAGING_STATS_USING_TIMING_FUNCTIONS
|
#ifdef CONFIG_DEMAND_PAGING_STATS_USING_TIMING_FUNCTIONS
|
||||||
|
@ -1195,7 +1195,7 @@ static bool do_page_fault(void *addr, bool pin)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: Add performance accounting:
|
* TODO: Add performance accounting:
|
||||||
* - z_eviction_select() metrics
|
* - k_mem_paging_eviction_select() metrics
|
||||||
* * periodic timer execution time histogram (if implemented)
|
* * periodic timer execution time histogram (if implemented)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,8 @@ struct k_mem_paging_histogram_t z_paging_histogram_backing_store_page_out;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern unsigned long
|
extern unsigned long
|
||||||
z_eviction_histogram_bounds[CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS];
|
k_mem_paging_eviction_histogram_bounds[
|
||||||
|
CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS];
|
||||||
|
|
||||||
extern unsigned long
|
extern unsigned long
|
||||||
z_backing_store_histogram_bounds[CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS];
|
z_backing_store_histogram_bounds[CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS];
|
||||||
|
@ -40,7 +41,7 @@ z_backing_store_histogram_bounds[CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS]
|
||||||
* This provides the upper bounds of the bins in eviction timing histogram.
|
* This provides the upper bounds of the bins in eviction timing histogram.
|
||||||
*/
|
*/
|
||||||
__weak unsigned long
|
__weak unsigned long
|
||||||
z_eviction_histogram_bounds[CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS] = {
|
k_mem_paging_eviction_histogram_bounds[CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS] = {
|
||||||
NS_TO_CYC(1),
|
NS_TO_CYC(1),
|
||||||
NS_TO_CYC(5),
|
NS_TO_CYC(5),
|
||||||
NS_TO_CYC(10),
|
NS_TO_CYC(10),
|
||||||
|
@ -142,7 +143,8 @@ void z_paging_histogram_init(void)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
memset(&z_paging_histogram_eviction, 0, sizeof(z_paging_histogram_eviction));
|
memset(&z_paging_histogram_eviction, 0, sizeof(z_paging_histogram_eviction));
|
||||||
memcpy(z_paging_histogram_eviction.bounds, z_eviction_histogram_bounds,
|
memcpy(z_paging_histogram_eviction.bounds,
|
||||||
|
k_mem_paging_eviction_histogram_bounds,
|
||||||
sizeof(z_paging_histogram_eviction.bounds));
|
sizeof(z_paging_histogram_eviction.bounds));
|
||||||
|
|
||||||
memset(&z_paging_histogram_backing_store_page_in, 0,
|
memset(&z_paging_histogram_backing_store_page_in, 0,
|
||||||
|
|
|
@ -40,7 +40,7 @@ static void nru_periodic_update(struct k_timer *timer)
|
||||||
irq_unlock(key);
|
irq_unlock(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct z_page_frame *z_eviction_select(bool *dirty_ptr)
|
struct z_page_frame *k_mem_paging_eviction_select(bool *dirty_ptr)
|
||||||
{
|
{
|
||||||
unsigned int last_prec = 4U;
|
unsigned int last_prec = 4U;
|
||||||
struct z_page_frame *last_pf = NULL, *pf;
|
struct z_page_frame *last_pf = NULL, *pf;
|
||||||
|
@ -89,7 +89,7 @@ struct z_page_frame *z_eviction_select(bool *dirty_ptr)
|
||||||
|
|
||||||
static K_TIMER_DEFINE(nru_timer, nru_periodic_update, NULL);
|
static K_TIMER_DEFINE(nru_timer, nru_periodic_update, NULL);
|
||||||
|
|
||||||
void z_eviction_init(void)
|
void k_mem_paging_eviction_init(void)
|
||||||
{
|
{
|
||||||
k_timer_start(&nru_timer, K_NO_WAIT,
|
k_timer_start(&nru_timer, K_NO_WAIT,
|
||||||
K_MSEC(CONFIG_EVICTION_NRU_PERIOD));
|
K_MSEC(CONFIG_EVICTION_NRU_PERIOD));
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
|
|
||||||
#ifdef CONFIG_BOARD_QEMU_X86
|
#ifdef CONFIG_BOARD_QEMU_X86
|
||||||
unsigned long
|
unsigned long
|
||||||
z_eviction_histogram_bounds[CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS] = {
|
k_mem_paging_eviction_histogram_bounds[
|
||||||
|
CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS] = {
|
||||||
10000,
|
10000,
|
||||||
20000,
|
20000,
|
||||||
30000,
|
30000,
|
||||||
|
|
Loading…
Reference in a new issue