]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ksm-abstract-the-function-try_to_get_old_rmap_item-v6
authorxu xin <xu.xin16@zte.com.cn>
Fri, 10 Feb 2023 01:16:42 +0000 (09:16 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 10 Feb 2023 23:36:02 +0000 (15:36 -0800)
modify some comments according to David's suggestions.

Link: https://lkml.kernel.org/r/202302100916423431376@zte.com.cn
Signed-off-by: xu xin <xu.xin16@zte.com.cn>
Reviewed-by: Xiaokai Ran <ran.xiaokai@zte.com.cn>
Reviewed-by: Yang Yang <yang.yang29@zte.com.cn>
Cc: David Hildenbrand <david@redhat.com>
Cc: Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: Xuexin Jiang <jiang.xuexin@zte.com.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/ksm.c

index 79ffadd18f8af2cf97dc0e3f2b378ff4cf788947..39a71bd25e4c410872e8ca9c0527757491ec8c94 100644 (file)
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -2218,12 +2218,16 @@ static struct ksm_rmap_item *try_to_get_old_rmap_item(unsigned long addr,
 {
        while (*rmap_list) {
                struct ksm_rmap_item *rmap_item = *rmap_list;
+
                if ((rmap_item->address & PAGE_MASK) == addr)
                        return rmap_item;
                if (rmap_item->address > addr)
                        break;
                *rmap_list = rmap_item->rmap_list;
-               /* Running here indicates it's vma has been UNMERGEABLE */
+               /*
+                * If we end up here, the VMA is MADV_UNMERGEABLE or its page
+                * is ineligible or discarded, e.g. MADV_DONTNEED.
+                */
                remove_rmap_item_from_tree(rmap_item);
                free_rmap_item(rmap_item);
        }
@@ -2237,12 +2241,10 @@ static struct ksm_rmap_item *get_next_rmap_item(struct ksm_mm_slot *mm_slot,
 {
        struct ksm_rmap_item *rmap_item;
 
-       /* lookup if we have a old rmap_item matching the addr*/
        rmap_item = try_to_get_old_rmap_item(addr, rmap_list);
        if (rmap_item)
                return rmap_item;
 
-       /* Need to allocate a new rmap_item */
        rmap_item = alloc_rmap_item();
        if (rmap_item) {
                /* It has already been zeroed */