* Re: [RFC PATCH v2 4/5] mm/autonuma: call .numa_protect() when page is protected for NUMA migrate
[not found] <20230810090048.26184-1-yan.y.zhao@intel.com>
@ 2023-08-10 13:45 ` kernel test robot
2023-08-10 13:55 ` kernel test robot
1 sibling, 0 replies; 2+ messages in thread
From: kernel test robot @ 2023-08-10 13:45 UTC (permalink / raw)
To: Yan Zhao; +Cc: llvm, oe-kbuild-all
Hi Yan,
[This is a private test report for your RFC patch.]
kernel test robot noticed the following build errors:
[auto build test ERROR on kvm/queue]
[also build test ERROR on mst-vhost/linux-next linus/master v6.5-rc5 next-20230809]
[cannot apply to akpm-mm/mm-everything kvm/linux-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Yan-Zhao/mm-mmu_notifier-introduce-a-new-mmu-notifier-flag-MMU_NOTIFIER_RANGE_NUMA/20230810-172955
base: https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue
patch link: https://lore.kernel.org/r/20230810090048.26184-1-yan.y.zhao%40intel.com
patch subject: [RFC PATCH v2 4/5] mm/autonuma: call .numa_protect() when page is protected for NUMA migrate
config: um-allnoconfig (https://download.01.org/0day-ci/archive/20230810/202308102134.oBT4eoMN-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce: (https://download.01.org/0day-ci/archive/20230810/202308102134.oBT4eoMN-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308102134.oBT4eoMN-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from mm/mprotect.c:13:
In file included from include/linux/hugetlb.h:10:
In file included from include/linux/cgroup.h:26:
In file included from include/linux/kernel_stat.h:9:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
547 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
560 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
| ^
In file included from mm/mprotect.c:13:
In file included from include/linux/hugetlb.h:10:
In file included from include/linux/cgroup.h:26:
In file included from include/linux/kernel_stat.h:9:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
573 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
In file included from mm/mprotect.c:13:
In file included from include/linux/hugetlb.h:10:
In file included from include/linux/cgroup.h:26:
In file included from include/linux/kernel_stat.h:9:
In file included from include/linux/interrupt.h:11:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
584 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
594 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
604 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
692 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
700 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
708 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
717 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
726 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
735 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
>> mm/mprotect.c:167:5: error: call to undeclared function 'mmu_notifier_numa_protect'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
167 | mmu_notifier_numa_protect(vma->vm_mm, addr, addr + PAGE_SIZE);
| ^
12 warnings and 1 error generated.
vim +/mmu_notifier_numa_protect +167 mm/mprotect.c
82
83 static long change_pte_range(struct mmu_gather *tlb,
84 struct vm_area_struct *vma, pmd_t *pmd, unsigned long addr,
85 unsigned long end, pgprot_t newprot, unsigned long cp_flags)
86 {
87 pte_t *pte, oldpte;
88 spinlock_t *ptl;
89 long pages = 0;
90 int target_node = NUMA_NO_NODE;
91 bool prot_numa = cp_flags & MM_CP_PROT_NUMA;
92 bool uffd_wp = cp_flags & MM_CP_UFFD_WP;
93 bool uffd_wp_resolve = cp_flags & MM_CP_UFFD_WP_RESOLVE;
94
95 tlb_change_page_size(tlb, PAGE_SIZE);
96 pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
97 if (!pte)
98 return -EAGAIN;
99
100 /* Get target node for single threaded private VMAs */
101 if (prot_numa && !(vma->vm_flags & VM_SHARED) &&
102 atomic_read(&vma->vm_mm->mm_users) == 1)
103 target_node = numa_node_id();
104
105 flush_tlb_batched_pending(vma->vm_mm);
106 arch_enter_lazy_mmu_mode();
107 do {
108 oldpte = ptep_get(pte);
109 if (pte_present(oldpte)) {
110 pte_t ptent;
111
112 /*
113 * Avoid trapping faults against the zero or KSM
114 * pages. See similar comment in change_huge_pmd.
115 */
116 if (prot_numa) {
117 struct page *page;
118 int nid;
119 bool toptier;
120
121 /* Avoid TLB flush if possible */
122 if (pte_protnone(oldpte))
123 continue;
124
125 page = vm_normal_page(vma, addr, oldpte);
126 if (!page || is_zone_device_page(page) || PageKsm(page))
127 continue;
128
129 /* Also skip shared copy-on-write pages */
130 if (is_cow_mapping(vma->vm_flags) &&
131 page_count(page) != 1)
132 continue;
133
134 /*
135 * While migration can move some dirty pages,
136 * it cannot move them all from MIGRATE_ASYNC
137 * context.
138 */
139 if (page_is_file_lru(page) && PageDirty(page))
140 continue;
141
142 /*
143 * Don't mess with PTEs if page is already on the node
144 * a single-threaded process is running on.
145 */
146 nid = page_to_nid(page);
147 if (target_node == nid)
148 continue;
149
150 if (PageAnon(page) && PageAnonExclusive(page) &&
151 page_maybe_dma_pinned(page))
152 continue;
153
154 toptier = node_is_toptier(nid);
155
156 /*
157 * Skip scanning top tier node if normal numa
158 * balancing is disabled
159 */
160 if (!(sysctl_numa_balancing_mode & NUMA_BALANCING_NORMAL) &&
161 toptier)
162 continue;
163 if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING &&
164 !toptier)
165 xchg_page_access_time(page,
166 jiffies_to_msecs(jiffies));
> 167 mmu_notifier_numa_protect(vma->vm_mm, addr, addr + PAGE_SIZE);
168 }
169
170 oldpte = ptep_modify_prot_start(vma, addr, pte);
171 ptent = pte_modify(oldpte, newprot);
172
173 if (uffd_wp)
174 ptent = pte_mkuffd_wp(ptent);
175 else if (uffd_wp_resolve)
176 ptent = pte_clear_uffd_wp(ptent);
177
178 /*
179 * In some writable, shared mappings, we might want
180 * to catch actual write access -- see
181 * vma_wants_writenotify().
182 *
183 * In all writable, private mappings, we have to
184 * properly handle COW.
185 *
186 * In both cases, we can sometimes still change PTEs
187 * writable and avoid the write-fault handler, for
188 * example, if a PTE is already dirty and no other
189 * COW or special handling is required.
190 */
191 if ((cp_flags & MM_CP_TRY_CHANGE_WRITABLE) &&
192 !pte_write(ptent) &&
193 can_change_pte_writable(vma, addr, ptent))
194 ptent = pte_mkwrite(ptent);
195
196 ptep_modify_prot_commit(vma, addr, pte, oldpte, ptent);
197 if (pte_needs_flush(oldpte, ptent))
198 tlb_flush_pte_range(tlb, addr, PAGE_SIZE);
199 pages++;
200 } else if (is_swap_pte(oldpte)) {
201 swp_entry_t entry = pte_to_swp_entry(oldpte);
202 pte_t newpte;
203
204 if (is_writable_migration_entry(entry)) {
205 struct page *page = pfn_swap_entry_to_page(entry);
206
207 /*
208 * A protection check is difficult so
209 * just be safe and disable write
210 */
211 if (PageAnon(page))
212 entry = make_readable_exclusive_migration_entry(
213 swp_offset(entry));
214 else
215 entry = make_readable_migration_entry(swp_offset(entry));
216 newpte = swp_entry_to_pte(entry);
217 if (pte_swp_soft_dirty(oldpte))
218 newpte = pte_swp_mksoft_dirty(newpte);
219 } else if (is_writable_device_private_entry(entry)) {
220 /*
221 * We do not preserve soft-dirtiness. See
222 * copy_one_pte() for explanation.
223 */
224 entry = make_readable_device_private_entry(
225 swp_offset(entry));
226 newpte = swp_entry_to_pte(entry);
227 if (pte_swp_uffd_wp(oldpte))
228 newpte = pte_swp_mkuffd_wp(newpte);
229 } else if (is_writable_device_exclusive_entry(entry)) {
230 entry = make_readable_device_exclusive_entry(
231 swp_offset(entry));
232 newpte = swp_entry_to_pte(entry);
233 if (pte_swp_soft_dirty(oldpte))
234 newpte = pte_swp_mksoft_dirty(newpte);
235 if (pte_swp_uffd_wp(oldpte))
236 newpte = pte_swp_mkuffd_wp(newpte);
237 } else if (is_pte_marker_entry(entry)) {
238 /*
239 * Ignore swapin errors unconditionally,
240 * because any access should sigbus anyway.
241 */
242 if (is_swapin_error_entry(entry))
243 continue;
244 /*
245 * If this is uffd-wp pte marker and we'd like
246 * to unprotect it, drop it; the next page
247 * fault will trigger without uffd trapping.
248 */
249 if (uffd_wp_resolve) {
250 pte_clear(vma->vm_mm, addr, pte);
251 pages++;
252 }
253 continue;
254 } else {
255 newpte = oldpte;
256 }
257
258 if (uffd_wp)
259 newpte = pte_swp_mkuffd_wp(newpte);
260 else if (uffd_wp_resolve)
261 newpte = pte_swp_clear_uffd_wp(newpte);
262
263 if (!pte_same(oldpte, newpte)) {
264 set_pte_at(vma->vm_mm, addr, pte, newpte);
265 pages++;
266 }
267 } else {
268 /* It must be an none page, or what else?.. */
269 WARN_ON_ONCE(!pte_none(oldpte));
270
271 /*
272 * Nobody plays with any none ptes besides
273 * userfaultfd when applying the protections.
274 */
275 if (likely(!uffd_wp))
276 continue;
277
278 if (userfaultfd_wp_use_markers(vma)) {
279 /*
280 * For file-backed mem, we need to be able to
281 * wr-protect a none pte, because even if the
282 * pte is none, the page/swap cache could
283 * exist. Doing that by install a marker.
284 */
285 set_pte_at(vma->vm_mm, addr, pte,
286 make_pte_marker(PTE_MARKER_UFFD_WP));
287 pages++;
288 }
289 }
290 } while (pte++, addr += PAGE_SIZE, addr != end);
291 arch_leave_lazy_mmu_mode();
292 pte_unmap_unlock(pte - 1, ptl);
293
294 return pages;
295 }
296
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFC PATCH v2 4/5] mm/autonuma: call .numa_protect() when page is protected for NUMA migrate
[not found] <20230810090048.26184-1-yan.y.zhao@intel.com>
2023-08-10 13:45 ` [RFC PATCH v2 4/5] mm/autonuma: call .numa_protect() when page is protected for NUMA migrate kernel test robot
@ 2023-08-10 13:55 ` kernel test robot
1 sibling, 0 replies; 2+ messages in thread
From: kernel test robot @ 2023-08-10 13:55 UTC (permalink / raw)
To: Yan Zhao; +Cc: oe-kbuild-all
Hi Yan,
[This is a private test report for your RFC patch.]
kernel test robot noticed the following build errors:
[auto build test ERROR on kvm/queue]
[also build test ERROR on mst-vhost/linux-next linus/master]
[cannot apply to akpm-mm/mm-everything kvm/linux-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Yan-Zhao/mm-mmu_notifier-introduce-a-new-mmu-notifier-flag-MMU_NOTIFIER_RANGE_NUMA/20230810-172955
base: https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue
patch link: https://lore.kernel.org/r/20230810090048.26184-1-yan.y.zhao%40intel.com
patch subject: [RFC PATCH v2 4/5] mm/autonuma: call .numa_protect() when page is protected for NUMA migrate
config: x86_64-buildonly-randconfig-r003-20230809 (https://download.01.org/0day-ci/archive/20230810/202308102157.wk3FSpe2-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230810/202308102157.wk3FSpe2-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308102157.wk3FSpe2-lkp@intel.com/
All errors (new ones prefixed by >>):
mm/huge_memory.c: In function 'change_huge_pmd':
>> mm/huge_memory.c:1895:17: error: implicit declaration of function 'mmu_notifier_numa_protect' [-Werror=implicit-function-declaration]
1895 | mmu_notifier_numa_protect(vma->vm_mm, addr, addr + PMD_SIZE);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/mmu_notifier_numa_protect +1895 mm/huge_memory.c
1862
1863 if (prot_numa) {
1864 struct page *page;
1865 bool toptier;
1866 /*
1867 * Avoid trapping faults against the zero page. The read-only
1868 * data is likely to be read-cached on the local CPU and
1869 * local/remote hits to the zero page are not interesting.
1870 */
1871 if (is_huge_zero_pmd(*pmd))
1872 goto unlock;
1873
1874 if (pmd_protnone(*pmd))
1875 goto unlock;
1876
1877 page = pmd_page(*pmd);
1878
1879 if (PageAnon(page) && PageAnonExclusive(page) &&
1880 page_maybe_dma_pinned(page))
1881 goto unlock;
1882
1883 toptier = node_is_toptier(page_to_nid(page));
1884 /*
1885 * Skip scanning top tier node if normal numa
1886 * balancing is disabled
1887 */
1888 if (!(sysctl_numa_balancing_mode & NUMA_BALANCING_NORMAL) &&
1889 toptier)
1890 goto unlock;
1891
1892 if (sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING &&
1893 !toptier)
1894 xchg_page_access_time(page, jiffies_to_msecs(jiffies));
> 1895 mmu_notifier_numa_protect(vma->vm_mm, addr, addr + PMD_SIZE);
1896 }
1897 /*
1898 * In case prot_numa, we are under mmap_read_lock(mm). It's critical
1899 * to not clear pmd intermittently to avoid race with MADV_DONTNEED
1900 * which is also under mmap_read_lock(mm):
1901 *
1902 * CPU0: CPU1:
1903 * change_huge_pmd(prot_numa=1)
1904 * pmdp_huge_get_and_clear_notify()
1905 * madvise_dontneed()
1906 * zap_pmd_range()
1907 * pmd_trans_huge(*pmd) == 0 (without ptl)
1908 * // skip the pmd
1909 * set_pmd_at();
1910 * // pmd is re-established
1911 *
1912 * The race makes MADV_DONTNEED miss the huge pmd and don't clear it
1913 * which may break userspace.
1914 *
1915 * pmdp_invalidate_ad() is required to make sure we don't miss
1916 * dirty/young flags set by hardware.
1917 */
1918 oldpmd = pmdp_invalidate_ad(vma, addr, pmd);
1919
1920 entry = pmd_modify(oldpmd, newprot);
1921 if (uffd_wp)
1922 entry = pmd_mkuffd_wp(entry);
1923 else if (uffd_wp_resolve)
1924 /*
1925 * Leave the write bit to be handled by PF interrupt
1926 * handler, then things like COW could be properly
1927 * handled.
1928 */
1929 entry = pmd_clear_uffd_wp(entry);
1930
1931 /* See change_pte_range(). */
1932 if ((cp_flags & MM_CP_TRY_CHANGE_WRITABLE) && !pmd_write(entry) &&
1933 can_change_pmd_writable(vma, addr, entry))
1934 entry = pmd_mkwrite(entry);
1935
1936 ret = HPAGE_PMD_NR;
1937 set_pmd_at(mm, addr, pmd, entry);
1938
1939 if (huge_pmd_needs_flush(oldpmd, entry))
1940 tlb_flush_pmd_range(tlb, addr, HPAGE_PMD_SIZE);
1941 unlock:
1942 spin_unlock(ptl);
1943 return ret;
1944 }
1945
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-10 14:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20230810090048.26184-1-yan.y.zhao@intel.com>
2023-08-10 13:45 ` [RFC PATCH v2 4/5] mm/autonuma: call .numa_protect() when page is protected for NUMA migrate kernel test robot
2023-08-10 13:55 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).