Re: [PATCH v9 3/5] ksm: add ksm zero pages for each process

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 24.05.23 07:58, Yang Yang wrote:
From: xu xin <xu.xin16@xxxxxxxxxx>

As the number of ksm zero pages is not included in ksm_merging_pages per
process when enabling use_zero_pages, it's unclear of how many actual
pages are merged by KSM. To let users accurately estimate their memory
demands when unsharing KSM zero-pages, it's necessary to show KSM zero-
pages per process. In addition, it help users to know the actual KSM
profit because KSM-placed zero pages are also benefit from KSM.

since unsharing zero pages placed by KSM accurately is achieved, then
tracking empty pages merging and unmerging is not a difficult thing any
longer.

Since we already have /proc/<pid>/ksm_stat, just add the information of
'ksm_zero_pages' in it.

Signed-off-by: xu xin <xu.xin16@xxxxxxxxxx>
Cc: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx>
Cc: David Hildenbrand <david@xxxxxxxxxx>
Cc: Xuexin Jiang <jiang.xuexin@xxxxxxxxxx>
Cc: Xiaokai Ran <ran.xiaokai@xxxxxxxxxx>
Cc: Yang Yang <yang.yang29@xxxxxxxxxx>
---

[...]

  static inline int ksm_fork(struct mm_struct *mm, struct mm_struct *oldmm)
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 306a3d1a0fa6..14f781509812 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -777,7 +777,7 @@ struct mm_struct {
  #ifdef CONFIG_KSM
  		/*
  		 * Represent how many pages of this process are involved in KSM
-		 * merging.
+		 * merging (not including ksm_zero_pages).
  		 */
  		unsigned long ksm_merging_pages;
  		/*
@@ -785,7 +785,12 @@ struct mm_struct {
  		 * including merged and not merged.
  		 */
  		unsigned long ksm_rmap_items;
-#endif
+		/*
+		 * Represent how many empty pages are merged with kernel zero
+		 * pages when enabling KSM use_zero_pages.

"zero page" ? Only some archs have multiple ones, and it's rather an implementation detail.

+		 */
+		unsigned long ksm_zero_pages;
+#endif /* CONFIG_KSM */
  #ifdef CONFIG_LRU_GEN
  		struct {

Reviewed-by: David Hildenbrand <david@xxxxxxxxxx>

--
Thanks,

David / dhildenb





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux