Re: [PATCH v4 2/2] ksm: add profit monitoring documentation

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

 



On 8/24/22 19:48, xu xin wrote:
> +Monitoring KSM profit
> +=====================
> +
> +KSM can save memory by merging identical pages, but also can consume
> +additional memory, because it needs to generate a number of rmap_items to
> +save each scanned page's brief rmap information. Some of these pages may
> +be merged, but some may not be abled to be merged after being checked
> +several times, which are unprofitable memory consumed.
> +
> +1) How to determine whether KSM save memory or consume memory in system-wide
> +   range? Here is a simple approximate calculation for reference::
> +
> +	general_profit =~ pages_sharing * sizeof(page) - (all_rmap_items) *
> +			  sizeof(rmap_item);
> +
> +   where all_rmap_items can be easily obtained by summing ``pages_sharing``,
> +   ``pages_shared``, ``pages_unshared`` and ``pages_volatile``.
> +
> +2) The KSM profit inner a single process can be similarly obtained by the
> +   following approximate calculation::
> +
> +	process_profit =~ ksm_merging_pages * sizeof(page) -
> +			  ksm_rmp_items * sizeof(rmap_item).
> +
> +   where both ksm_merging_pages and ksm_rmp_items are shown under the
> +   directory ``/proc/<pid>/``.
> +
> +From the perspective of application, a high ratio of ``ksm_rmp_items`` to
> +``ksm_merging_pages`` means a bad madvise-applied policy, so developers or
> +administrators have to rethink how to change madvise policy. Giving an example
> +for reference, a page's size is usually 4K, and the rmap_item's size is
> +separately 32B on 32-bit CPU architecture and 64B on 64-bit CPU architecture.
> +so if the ``ksm_rmp_items/ksm_merging_pages`` ratio exceeds 64 on 64-bit CPU
> +or exceeds 128 on 32-bit CPU, then the app's madvise policy should be dropped,
> +because the ksm profit is approximately zero or negative.
> +
>  Monitoring KSM events
>  =====================
>  

LGTM.

Reviewed-by: Bagas Sanjaya <bagasdotme@xxxxxxxxx>

-- 
An old man doll... just what I always wanted! - Clara



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux