mprotect.c (b3bbcc5d1da1b654091dad15980b3d58fdae0fc6) mprotect.c (467b171af881282fc627328e6c164f044a6df888)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * mm/mprotect.c
4 *
5 * (C) Copyright 1994 Linus Torvalds
6 * (C) Copyright 2002 Christoph Hellwig
7 *
8 * Address space accounting code <alan@lxorguk.ukuu.org.uk>

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

26#include <linux/perf_event.h>
27#include <linux/pkeys.h>
28#include <linux/ksm.h>
29#include <linux/uaccess.h>
30#include <linux/mm_inline.h>
31#include <linux/pgtable.h>
32#include <linux/sched/sysctl.h>
33#include <linux/userfaultfd_k.h>
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * mm/mprotect.c
4 *
5 * (C) Copyright 1994 Linus Torvalds
6 * (C) Copyright 2002 Christoph Hellwig
7 *
8 * Address space accounting code <alan@lxorguk.ukuu.org.uk>

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

26#include <linux/perf_event.h>
27#include <linux/pkeys.h>
28#include <linux/ksm.h>
29#include <linux/uaccess.h>
30#include <linux/mm_inline.h>
31#include <linux/pgtable.h>
32#include <linux/sched/sysctl.h>
33#include <linux/userfaultfd_k.h>
34#include <linux/memory-tiers.h>
34#include <asm/cacheflush.h>
35#include <asm/mmu_context.h>
36#include <asm/tlbflush.h>
37#include <asm/tlb.h>
38
39#include "internal.h"
40
41static inline bool can_change_pte_writable(struct vm_area_struct *vma,

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

116
117 /*
118 * Avoid trapping faults against the zero or KSM
119 * pages. See similar comment in change_huge_pmd.
120 */
121 if (prot_numa) {
122 struct page *page;
123 int nid;
35#include <asm/cacheflush.h>
36#include <asm/mmu_context.h>
37#include <asm/tlbflush.h>
38#include <asm/tlb.h>
39
40#include "internal.h"
41
42static inline bool can_change_pte_writable(struct vm_area_struct *vma,

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

117
118 /*
119 * Avoid trapping faults against the zero or KSM
120 * pages. See similar comment in change_huge_pmd.
121 */
122 if (prot_numa) {
123 struct page *page;
124 int nid;
125 bool toptier;
124
125 /* Avoid TLB flush if possible */
126 if (pte_protnone(oldpte))
127 continue;
128
129 page = vm_normal_page(vma, addr, oldpte);
130 if (!page || is_zone_device_page(page) || PageKsm(page))
131 continue;

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

145
146 /*
147 * Don't mess with PTEs if page is already on the node
148 * a single-threaded process is running on.
149 */
150 nid = page_to_nid(page);
151 if (target_node == nid)
152 continue;
126
127 /* Avoid TLB flush if possible */
128 if (pte_protnone(oldpte))
129 continue;
130
131 page = vm_normal_page(vma, addr, oldpte);
132 if (!page || is_zone_device_page(page) || PageKsm(page))
133 continue;

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

147
148 /*
149 * Don't mess with PTEs if page is already on the node
150 * a single-threaded process is running on.
151 */
152 nid = page_to_nid(page);
153 if (target_node == nid)
154 continue;
155 toptier = node_is_toptier(nid);
153
154 /*
155 * Skip scanning top tier node if normal numa
156 * balancing is disabled
157 */
158 if (!(sysctl_numa_balancing_mode & NUMA_BALANCING_NORMAL) &&
156
157 /*
158 * Skip scanning top tier node if normal numa
159 * balancing is disabled
160 */
161 if (!(sysctl_numa_balancing_mode & NUMA_BALANCING_NORMAL) &&
159 node_is_toptier(nid))
162 toptier)
160 continue;
163 continue;
164 if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING &&
165 !toptier)
166 xchg_page_access_time(page,
167 jiffies_to_msecs(jiffies));
161 }
162
163 oldpte = ptep_modify_prot_start(vma, addr, pte);
164 ptent = pte_modify(oldpte, newprot);
165 if (preserve_write)
166 ptent = pte_mk_savedwrite(ptent);
167
168 if (uffd_wp) {

--- 696 unchanged lines hidden ---
168 }
169
170 oldpte = ptep_modify_prot_start(vma, addr, pte);
171 ptent = pte_modify(oldpte, newprot);
172 if (preserve_write)
173 ptent = pte_mk_savedwrite(ptent);
174
175 if (uffd_wp) {

--- 696 unchanged lines hidden ---