From 0cbdb05a46492b215fed1c5b7087f69709bea08a Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 4 Sep 2016 22:08:04 +0000 Subject: [PATCH] Replace the number 4 in pmap_ts_referenced() by PMAP_TS_REFERENCED_MAX, like we've done elsewhere, e.g., amd64. As an optimization to the machine-independent layer, change the machine- dependent pmap_ts_referenced() so that it updates the page's dirty field if a modified bit is found while counting reference bits. This opportunistic update can be performed at low cost and can eliminate the need for some future calls to pmap_is_modified() by the machine- independent layer. MFC after: 3 weeks --- sys/sparc64/sparc64/pmap.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sys/sparc64/sparc64/pmap.c b/sys/sparc64/sparc64/pmap.c index a82e046ae42..71a21720776 100644 --- a/sys/sparc64/sparc64/pmap.c +++ b/sys/sparc64/sparc64/pmap.c @@ -2073,6 +2073,8 @@ pmap_page_is_mapped(vm_page_t m) return (rv); } +#define PMAP_TS_REFERENCED_MAX 5 + /* * Return a count of reference bits for a page, clearing those bits. * It is not necessary for every reference bit to be cleared, but it @@ -2082,6 +2084,14 @@ pmap_page_is_mapped(vm_page_t m) * XXX: The exact number of bits to check and clear is a matter that * should be tested and standardized at some point in the future for * optimal aging of shared pages. + * + * As an optimization, update the page's dirty field if a modified bit is + * found while counting reference bits. This opportunistic update can be + * performed at low cost and can eliminate the need for some future calls + * to pmap_is_modified(). However, since this function stops after + * finding PMAP_TS_REFERENCED_MAX reference bits, it may not detect some + * dirty pages. Those dirty pages will only be detected by a future call + * to pmap_is_modified(). */ int pmap_ts_referenced(vm_page_t m) @@ -2105,7 +2115,10 @@ pmap_ts_referenced(vm_page_t m) if ((tp->tte_data & TD_PV) == 0) continue; data = atomic_clear_long(&tp->tte_data, TD_REF); - if ((data & TD_REF) != 0 && ++count > 4) + if ((data & TD_W) != 0) + vm_page_dirty(m); + if ((data & TD_REF) != 0 && ++count >= + PMAP_TS_REFERENCED_MAX) break; } while ((tp = tpn) != NULL && tp != tpf); }