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:
Daniel Leung 2021-05-13 11:02:56 -07:00 committed by Anas Nashif
parent 231a1e75ab
commit 31c362d966
7 changed files with 48 additions and 39 deletions

View file

@ -742,7 +742,7 @@ config DEMAND_PAGING_TIMING_HISTOGRAM_NUM_BINS
Defines the number of bins (buckets) in the histogram used for
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
for each bin. See kernel/statistics.c for information.

View file

@ -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
}
#endif

View file

@ -230,34 +230,6 @@ extern size_t z_free_page_count;
#endif
#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
*/

View file

@ -430,7 +430,7 @@ static int map_anon_page(void *addr, uint32_t flags)
bool dirty;
int ret;
pf = z_eviction_select(&dirty);
pf = k_mem_paging_eviction_select(&dirty);
__ASSERT(pf != NULL, "failed to get a page frame");
LOG_DBG("evicting %p at 0x%lx", pf->addr,
z_page_frame_to_phys(pf));
@ -791,7 +791,7 @@ void z_mem_manage_init(void)
z_paging_histogram_init();
#endif
z_backing_store_init();
z_eviction_init();
k_mem_paging_eviction_init();
#endif
#if __ASSERT_ON
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_TIMING_HISTOGRAM */
pf = z_eviction_select(dirty);
pf = k_mem_paging_eviction_select(dirty);
#ifdef CONFIG_DEMAND_PAGING_TIMING_HISTOGRAM
#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:
* - z_eviction_select() metrics
* - k_mem_paging_eviction_select() metrics
* * periodic timer execution time histogram (if implemented)
*/

View file

@ -28,7 +28,8 @@ struct k_mem_paging_histogram_t z_paging_histogram_backing_store_page_out;
*/
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
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.
*/
__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(5),
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));
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));
memset(&z_paging_histogram_backing_store_page_in, 0,

View file

@ -40,7 +40,7 @@ static void nru_periodic_update(struct k_timer *timer)
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;
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);
void z_eviction_init(void)
void k_mem_paging_eviction_init(void)
{
k_timer_start(&nru_timer, K_NO_WAIT,
K_MSEC(CONFIG_EVICTION_NRU_PERIOD));

View file

@ -20,7 +20,8 @@
#ifdef CONFIG_BOARD_QEMU_X86
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,
20000,
30000,