Commit 2d6322d7 authored by Daniel Leung's avatar Daniel Leung Committed by Anas Nashif
Browse files

demand_paging: eviction/nru: fix incorrect dirty bit return val



In k_mem_paging_eviction_select(), the returned dirty bit value
may not be actually associated with the page selected, but
rather the last page examined. So fix this.

Signed-off-by: default avatarDaniel Leung <daniel.leung@intel.com>
parent 25771e69
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ 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;
	bool accessed;
	bool last_dirty = false;
	bool dirty = false;
	uintptr_t flags, phys;

@@ -71,18 +72,20 @@ struct z_page_frame *k_mem_paging_eviction_select(bool *dirty_ptr)
		if (prec == 0) {
			/* If we find a not accessed, clean page we're done */
			last_pf = pf;
			last_dirty = dirty;
			break;
		}

		if (prec < last_prec) {
			last_prec = prec;
			last_pf = pf;
			last_dirty = dirty;
		}
	}
	/* Shouldn't ever happen unless every page is pinned */
	__ASSERT(last_pf != NULL, "no page to evict");

	*dirty_ptr = dirty;
	*dirty_ptr = last_dirty;

	return last_pf;
}