Re: [PATCH v8 1/3] mm: add new api to enable ksm per process

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

 



+static void __ksm_add_vma(struct vm_area_struct *vma)
+{
+	unsigned long vm_flags = vma->vm_flags;
+
+	if (vm_flags & VM_MERGEABLE)
+		return;
+
+	if (vma_ksm_compatible(vma)) {
+		vm_flags |= VM_MERGEABLE;
+		vm_flags_reset(vma, vm_flags);
+	}
+}

We can do the following simplification on top:

diff --git a/mm/ksm.c b/mm/ksm.c
index 905c8edce5cf..26e7f585d65d 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -2511,15 +2511,11 @@ static int ksm_scan_thread(void *nothing)

 static void __ksm_add_vma(struct vm_area_struct *vma)
 {
-	unsigned long vm_flags = vma->vm_flags;
-
-	if (vm_flags & VM_MERGEABLE)
+	if (vma->vm_flags & VM_MERGEABLE)
 		return;

-	if (vma_ksm_compatible(vma)) {
-		vm_flags |= VM_MERGEABLE;
-		vm_flags_reset(vma, vm_flags);
-	}
+	if (vma_ksm_compatible(vma))
+		vm_flags_set(vma, VM_MERGEABLE);
 }

 /**
--
2.39.2


I have some patches based on your patch set (handling/testing unmerging whens setting PR_SET_MEMORY_MERGE=0. Will send out once you changes are queued.

--
Thanks,

David / dhildenb




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux