Hi Muchun,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on hnaz-mm/master]
url:
https://github.com/0day-ci/linux/commits/Muchun-Song/mm-rmap-fix-cache-fl...
base:
https://github.com/hnaz/linux-mm master
config: powerpc-allnoconfig
(
https://download.01.org/0day-ci/archive/20220125/202201250022.zqRQezMj-lk...)
compiler: powerpc-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O
~/bin/make.cross
chmod +x ~/bin/make.cross
#
https://github.com/0day-ci/linux/commit/0c83393977dfe53edadec9793328b7281...
git remote add linux-review
https://github.com/0day-ci/linux
git fetch --no-tags linux-review
Muchun-Song/mm-rmap-fix-cache-flush-on-THP-pages/20220121-160020
git checkout 0c83393977dfe53edadec9793328b7281e8af7aa
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir
ARCH=powerpc SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All errors (new ones prefixed by >>):
mm/page_vma_mapped.c: In function 'page_vma_mapped_walk':
> mm/page_vma_mapped.c:246:37: error: implicit declaration of
function 'pmd_pfn'; did you mean 'pmd_off'?
[-Werror=implicit-function-declaration]
246 |
if (pmd_pfn(pmde) != pfn)
| ^~~~~~~
| pmd_off
cc1: some warnings being treated as errors
vim +246 mm/page_vma_mapped.c
134
135 /**
136 * page_vma_mapped_walk - check if @pvmw->page or @pvmw->pfn is mapped in
137 * @pvmw->vma at @pvmw->address
138 * @pvmw: pointer to struct page_vma_mapped_walk. page (or pfn and nr and
139 * index), vma, address and flags must be set. pmd, pte and ptl must be NULL.
140 *
141 * Returns true if the page or pfn is mapped in the vma. @pvmw->pmd and
142 * @pvmw->pte point to relevant page table entries. @pvmw->ptl is locked.
143 * @pvmw->address is adjusted if needed (for PTE-mapped THPs).
144 *
145 * If @pvmw->pmd is set but @pvmw->pte is not, you have found PMD-mapped
page
146 * (usually THP or Huge DEVMAP). For PMD-mapped page, you should run
147 * page_vma_mapped_walk() in a loop to find all PTEs that map the huge page.
148 *
149 * For HugeTLB pages, @pvmw->pte is set to the relevant page table entry
150 * regardless of which page table level the page is mapped at. @pvmw->pmd is
151 * NULL.
152 *
153 * Returns false if there are no more page table entries for the page or pfn in
154 * the vma. @pvmw->ptl is unlocked and @pvmw->pte is unmapped.
155 *
156 * If you need to stop the walk before page_vma_mapped_walk() returned false,
157 * use page_vma_mapped_walk_done(). It will do the housekeeping.
158 */
159 bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
160 {
161 struct mm_struct *mm = pvmw->vma->vm_mm;
162 struct page *page;
163 unsigned long end;
164 unsigned long pfn;
165 pgd_t *pgd;
166 p4d_t *p4d;
167 pud_t *pud;
168 pmd_t pmde;
169
170 if (pvmw->flags & PVMW_PFN_WALK) {
171 page = NULL;
172 pfn = pvmw->pfn;
173 } else {
174 page = pvmw->page;
175 pfn = page_to_pfn(page);
176 }
177
178 /* The only possible pmd mapping has been handled on last iteration */
179 if (pvmw->pmd && !pvmw->pte)
180 return not_found(pvmw);
181
182 if (unlikely(page && PageHuge(page))) {
183 /* The only possible mapping was handled on last iteration */
184 if (pvmw->pte)
185 return not_found(pvmw);
186
187 /* when pud is not present, pte will be NULL */
188 pvmw->pte = huge_pte_offset(mm, pvmw->address, page_size(page));
189 if (!pvmw->pte)
190 return false;
191
192 pvmw->ptl = huge_pte_lockptr(page_hstate(page), mm, pvmw->pte);
193 spin_lock(pvmw->ptl);
194 if (!check_pte(pvmw))
195 return not_found(pvmw);
196 return true;
197 }
198
199 /*
200 * Seek to next pte only makes sense for THP.
201 * But more important than that optimization, is to filter out
202 * any PageKsm page: whose page->index misleads vma_address()
203 * and vma_address_end() to disaster.
204 */
205 if (page)
206 end = PageTransCompound(page) ?
207 vma_address_end(page, pvmw->vma) :
208 pvmw->address + PAGE_SIZE;
209 else
210 end = vma_pgoff_address_end(pvmw->index, pvmw->nr, pvmw->vma);
211
212 if (pvmw->pte)
213 goto next_pte;
214 restart:
215 do {
216 pgd = pgd_offset(mm, pvmw->address);
217 if (!pgd_present(*pgd)) {
218 step_forward(pvmw, PGDIR_SIZE);
219 continue;
220 }
221 p4d = p4d_offset(pgd, pvmw->address);
222 if (!p4d_present(*p4d)) {
223 step_forward(pvmw, P4D_SIZE);
224 continue;
225 }
226 pud = pud_offset(p4d, pvmw->address);
227 if (!pud_present(*pud)) {
228 step_forward(pvmw, PUD_SIZE);
229 continue;
230 }
231
232 pvmw->pmd = pmd_offset(pud, pvmw->address);
233 /*
234 * Make sure the pmd value isn't cached in a register by the
235 * compiler and used as a stale value after we've observed a
236 * subsequent update.
237 */
238 pmde = READ_ONCE(*pvmw->pmd);
239
240 if (pmd_leaf(pmde) || is_pmd_migration_entry(pmde)) {
241 pvmw->ptl = pmd_lock(mm, pvmw->pmd);
242 pmde = *pvmw->pmd;
243 if (likely(pmd_leaf(pmde))) {
244 if (pvmw->flags & PVMW_MIGRATION)
245 return not_found(pvmw);
246 if (pmd_pfn(pmde) != pfn)
247 return
not_found(pvmw);
248 return true;
249 }
250 if (!pmd_present(pmde)) {
251 swp_entry_t entry;
252
253 if (!thp_migration_supported() ||
254 !(pvmw->flags & PVMW_MIGRATION))
255 return not_found(pvmw);
256 entry = pmd_to_swp_entry(pmde);
257 if (!is_migration_entry(entry) ||
258 page_to_pfn(pfn_swap_entry_to_page(entry)) != pfn)
259 return not_found(pvmw);
260 return true;
261 }
262 /* THP pmd was split under us: handle on pte level */
263 spin_unlock(pvmw->ptl);
264 pvmw->ptl = NULL;
265 } else if (!pmd_present(pmde)) {
266 /*
267 * If PVMW_SYNC, take and drop THP pmd lock so that we
268 * cannot return prematurely, while zap_huge_pmd() has
269 * cleared *pmd but not decremented compound_mapcount().
270 */
271 if ((pvmw->flags & PVMW_SYNC) && page &&
272 PageTransCompound(page)) {
273 spinlock_t *ptl = pmd_lock(mm, pvmw->pmd);
274
275 spin_unlock(ptl);
276 }
277 step_forward(pvmw, PMD_SIZE);
278 continue;
279 }
280 if (!map_pte(pvmw))
281 goto next_pte;
282 this_pte:
283 if (check_pte(pvmw))
284 return true;
285 next_pte:
286 do {
287 pvmw->address += PAGE_SIZE;
288 if (pvmw->address >= end)
289 return not_found(pvmw);
290 /* Did we cross page table boundary? */
291 if ((pvmw->address & (PMD_SIZE - PAGE_SIZE)) == 0) {
292 if (pvmw->ptl) {
293 spin_unlock(pvmw->ptl);
294 pvmw->ptl = NULL;
295 }
296 pte_unmap(pvmw->pte);
297 pvmw->pte = NULL;
298 goto restart;
299 }
300 pvmw->pte++;
301 if ((pvmw->flags & PVMW_SYNC) && !pvmw->ptl) {
302 pvmw->ptl = pte_lockptr(mm, pvmw->pmd);
303 spin_lock(pvmw->ptl);
304 }
305 } while (pte_none(*pvmw->pte));
306
307 if (!pvmw->ptl) {
308 pvmw->ptl = pte_lockptr(mm, pvmw->pmd);
309 spin_lock(pvmw->ptl);
310 }
311 goto this_pte;
312 } while (pvmw->address < end);
313
314 return false;
315 }
316
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org