Re: [PATCH v9 2/5] ksm: count all zero pages placed by KSM

From: David Hildenbrand
Date: Wed May 24 2023 - 04:28:47 EST


On 24.05.23 09:55, xu xin wrote:
+extern unsigned long ksm_zero_pages;
+
+static inline void ksm_notify_unmap_zero_page(pte_t pte)
+{
+ if (is_ksm_zero_pte(pte))
+ ksm_zero_pages--;
+}
+
static inline int ksm_fork(struct mm_struct *mm, struct mm_struct *oldmm)
{
int ret;
@@ -103,6 +111,10 @@ static inline void ksm_exit(struct mm_struct *mm)
#define is_ksm_zero_pte(pte) 0
+static inline void ksm_notify_unmap_zero_page(pte_t pte)
+{
+}
+

Having proposed that name ... I realize that we call this function
whenever there might be a zeropage mapped (when we have !page after
vm_normal_page()) -- but it could also not be the zeropage.

Not really able to come up with a better name :)

ksm_notify_maybe_unmap_zero_page ?

ksm_maybe_unmap_zero_page ?


Analogous to the existing name of ksm_might_need_to_copy, so maybe we can use
'ksm_might_unmap_zero_page',

Yes, that should work :)

--
Thanks,

David / dhildenb