vma.c (2f1c6611b0a89afcb8641471af5f223c9caa01e0) vma.c (3e01310d29a700b99067cb0d6ba21284f2389308)
1// SPDX-License-Identifier: GPL-2.0-or-later
2
3/*
4 * VMA-specific functions.
5 */
6
7#include "vma_internal.h"
8#include "vma.h"

--- 5 unchanged lines hidden (view full) ---

14 * If the vma has a ->close operation then the driver probably needs to
15 * release per-vma resources, so we don't attempt to merge those if the
16 * caller indicates the current vma may be removed as part of the merge,
17 * which is the case if we are attempting to merge the next VMA into
18 * this one.
19 */
20 bool may_remove_vma = merge_next;
21
1// SPDX-License-Identifier: GPL-2.0-or-later
2
3/*
4 * VMA-specific functions.
5 */
6
7#include "vma_internal.h"
8#include "vma.h"

--- 5 unchanged lines hidden (view full) ---

14 * If the vma has a ->close operation then the driver probably needs to
15 * release per-vma resources, so we don't attempt to merge those if the
16 * caller indicates the current vma may be removed as part of the merge,
17 * which is the case if we are attempting to merge the next VMA into
18 * this one.
19 */
20 bool may_remove_vma = merge_next;
21
22 if (!mpol_equal(vmg->policy, vma_policy(vma)))
23 return false;
22 /*
23 * VM_SOFTDIRTY should not prevent from VMA merging, if we
24 * match the flags but dirty bit -- the caller should mark
25 * merged VMA as dirty. If dirty bit won't be excluded from
26 * comparison, we increase pressure on the memory system forcing
27 * the kernel to generate new VMAs when old one could be
28 * extended instead.
29 */

--- 1018 unchanged lines hidden (view full) ---

1048 else
1049 next = vmg->next = NULL; /* case 5 */
1050
1051 if (prev) {
1052 vma_start = prev->vm_start;
1053 vma_pgoff = prev->vm_pgoff;
1054
1055 /* Can we merge the predecessor? */
24 /*
25 * VM_SOFTDIRTY should not prevent from VMA merging, if we
26 * match the flags but dirty bit -- the caller should mark
27 * merged VMA as dirty. If dirty bit won't be excluded from
28 * comparison, we increase pressure on the memory system forcing
29 * the kernel to generate new VMAs when old one could be
30 * extended instead.
31 */

--- 1018 unchanged lines hidden (view full) ---

1050 else
1051 next = vmg->next = NULL; /* case 5 */
1052
1053 if (prev) {
1054 vma_start = prev->vm_start;
1055 vma_pgoff = prev->vm_pgoff;
1056
1057 /* Can we merge the predecessor? */
1056 if (addr == prev->vm_end && mpol_equal(vma_policy(prev), vmg->policy)
1057 && can_vma_merge_after(vmg)) {
1058
1058 if (addr == prev->vm_end && can_vma_merge_after(vmg)) {
1059 merge_prev = true;
1060 vma_prev(vmg->vmi);
1061 }
1062 }
1063
1064 /* Can we merge the successor? */
1059 merge_prev = true;
1060 vma_prev(vmg->vmi);
1061 }
1062 }
1063
1064 /* Can we merge the successor? */
1065 if (next && mpol_equal(vmg->policy, vma_policy(next)) &&
1066 can_vma_merge_before(vmg)) {
1065 if (next && can_vma_merge_before(vmg)) {
1067 merge_next = true;
1068 }
1069
1070 /* Verify some invariant that must be enforced by the caller. */
1071 VM_WARN_ON(prev && addr <= prev->vm_start);
1072 VM_WARN_ON(curr && (addr != curr->vm_start || end > curr->vm_end));
1073 VM_WARN_ON(addr >= end);
1074

--- 804 unchanged lines hidden ---
1066 merge_next = true;
1067 }
1068
1069 /* Verify some invariant that must be enforced by the caller. */
1070 VM_WARN_ON(prev && addr <= prev->vm_start);
1071 VM_WARN_ON(curr && (addr != curr->vm_start || end > curr->vm_end));
1072 VM_WARN_ON(addr >= end);
1073

--- 804 unchanged lines hidden ---