Hi Guanghui, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on v5.19-rc4] [also build test WARNING on linus/master next-20220630] [cannot apply to arm64/for-next/core] [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] url: https://github.com/intel-lab-lkp/linux/commits/Guanghui-Feng/arm64-mm-fix-linear-mapping-mem-access-performance-degradation/20220630-163924 base: 03c765b0e3b4cb5063276b086c76f7a612856a9a config: arm64-allyesconfig (https://download.01.org/0day-ci/archive/20220701/202207010409.ajCVDXYO-lkp@xxxxxxxxx/config) compiler: aarch64-linux-gcc (GCC) 11.3.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/intel-lab-lkp/linux/commit/168f0d56f0a26c4f7a9470d6f1c398b4e1c1b5b9 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Guanghui-Feng/arm64-mm-fix-linear-mapping-mem-access-performance-degradation/20220630-163924 git checkout 168f0d56f0a26c4f7a9470d6f1c398b4e1c1b5b9 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash arch/arm64/mm/ If you fix the issue, kindly add following tag where applicable Reported-by: kernel test robot <lkp@xxxxxxxxx> All warnings (new ones prefixed by >>): arch/arm64/mm/mmu.c: In function 'alloc_init_pud': >> arch/arm64/mm/mmu.c:426:35: warning: suggest braces around empty body in an 'if' statement [-Wempty-body] 426 | pud_clear_fixmap(); | ^ vim +/if +426 arch/arm64/mm/mmu.c d27cfa1fc823d3 Ard Biesheuvel 2017-03-09 333 20a004e7b017cc Will Deacon 2018-02-15 334 static void alloc_init_pud(pgd_t *pgdp, unsigned long addr, unsigned long end, da141706aea52c Laura Abbott 2015-01-21 335 phys_addr_t phys, pgprot_t prot, 90292aca9854a2 Yu Zhao 2019-03-11 336 phys_addr_t (*pgtable_alloc)(int), c0951366d4b7e0 Ard Biesheuvel 2017-03-09 337 int flags) c1cc1552616d0f Catalin Marinas 2012-03-05 338 { 168f0d56f0a26c Guanghui Feng 2022-06-30 339 phys_addr_t map_offset; c1cc1552616d0f Catalin Marinas 2012-03-05 340 unsigned long next; 168f0d56f0a26c Guanghui Feng 2022-06-30 341 pudval_t pudval; 20a004e7b017cc Will Deacon 2018-02-15 342 pud_t *pudp; e9f6376858b979 Mike Rapoport 2020-06-04 343 p4d_t *p4dp = p4d_offset(pgdp, addr); e9f6376858b979 Mike Rapoport 2020-06-04 344 p4d_t p4d = READ_ONCE(*p4dp); c1cc1552616d0f Catalin Marinas 2012-03-05 345 e9f6376858b979 Mike Rapoport 2020-06-04 346 if (p4d_none(p4d)) { 87143f404f338d Ard Biesheuvel 2021-03-10 347 p4dval_t p4dval = P4D_TYPE_TABLE | P4D_TABLE_UXN; 132233a759580f Laura Abbott 2016-02-05 348 phys_addr_t pud_phys; 87143f404f338d Ard Biesheuvel 2021-03-10 349 87143f404f338d Ard Biesheuvel 2021-03-10 350 if (flags & NO_EXEC_MAPPINGS) 87143f404f338d Ard Biesheuvel 2021-03-10 351 p4dval |= P4D_TABLE_PXN; 132233a759580f Laura Abbott 2016-02-05 352 BUG_ON(!pgtable_alloc); 90292aca9854a2 Yu Zhao 2019-03-11 353 pud_phys = pgtable_alloc(PUD_SHIFT); 87143f404f338d Ard Biesheuvel 2021-03-10 354 __p4d_populate(p4dp, pud_phys, p4dval); e9f6376858b979 Mike Rapoport 2020-06-04 355 p4d = READ_ONCE(*p4dp); c79b954bf6c006 Jungseok Lee 2014-05-12 356 } e9f6376858b979 Mike Rapoport 2020-06-04 357 BUG_ON(p4d_bad(p4d)); c79b954bf6c006 Jungseok Lee 2014-05-12 358 ee017ee353506f Jianyong Wu 2022-02-01 359 /* ee017ee353506f Jianyong Wu 2022-02-01 360 * No need for locking during early boot. And it doesn't work as ee017ee353506f Jianyong Wu 2022-02-01 361 * expected with KASLR enabled. ee017ee353506f Jianyong Wu 2022-02-01 362 */ ee017ee353506f Jianyong Wu 2022-02-01 363 if (system_state != SYSTEM_BOOTING) ee017ee353506f Jianyong Wu 2022-02-01 364 mutex_lock(&fixmap_lock); 168f0d56f0a26c Guanghui Feng 2022-06-30 365 168f0d56f0a26c Guanghui Feng 2022-06-30 366 pudp = (flags & NO_SEC_REMAPPINGS) ? pud_offset(p4dp, addr) : 168f0d56f0a26c Guanghui Feng 2022-06-30 367 pud_set_fixmap_offset(p4dp, addr); c1cc1552616d0f Catalin Marinas 2012-03-05 368 do { 20a004e7b017cc Will Deacon 2018-02-15 369 pud_t old_pud = READ_ONCE(*pudp); c1cc1552616d0f Catalin Marinas 2012-03-05 370 next = pud_addr_end(addr, end); 206a2a73a62d37 Steve Capper 2014-05-06 371 168f0d56f0a26c Guanghui Feng 2022-06-30 372 if (flags & NO_SEC_REMAPPINGS) { 168f0d56f0a26c Guanghui Feng 2022-06-30 373 if (!pud_none(*pudp) && pud_sect(*pudp)) { 168f0d56f0a26c Guanghui Feng 2022-06-30 374 phys_addr_t pmd_phys = pgtable_alloc(PMD_SHIFT); 168f0d56f0a26c Guanghui Feng 2022-06-30 375 pud_clear(pudp); 168f0d56f0a26c Guanghui Feng 2022-06-30 376 pudval = PUD_TYPE_TABLE | PUD_TABLE_UXN; 168f0d56f0a26c Guanghui Feng 2022-06-30 377 if (flags & NO_EXEC_MAPPINGS) 168f0d56f0a26c Guanghui Feng 2022-06-30 378 pudval |= PUD_TABLE_PXN; 168f0d56f0a26c Guanghui Feng 2022-06-30 379 168f0d56f0a26c Guanghui Feng 2022-06-30 380 __pud_populate(pudp, pmd_phys, pudval); 168f0d56f0a26c Guanghui Feng 2022-06-30 381 flush_tlb_kernel_range(addr, addr + PAGE_SIZE); 168f0d56f0a26c Guanghui Feng 2022-06-30 382 168f0d56f0a26c Guanghui Feng 2022-06-30 383 map_offset = addr - (addr & PUD_MASK); 168f0d56f0a26c Guanghui Feng 2022-06-30 384 if (map_offset) 168f0d56f0a26c Guanghui Feng 2022-06-30 385 alloc_init_cont_pmd(pudp, addr & PUD_MASK, 168f0d56f0a26c Guanghui Feng 2022-06-30 386 addr, phys - map_offset, 168f0d56f0a26c Guanghui Feng 2022-06-30 387 prot, pgtable_alloc, 168f0d56f0a26c Guanghui Feng 2022-06-30 388 flags & (~NO_SEC_REMAPPINGS)); 168f0d56f0a26c Guanghui Feng 2022-06-30 389 168f0d56f0a26c Guanghui Feng 2022-06-30 390 if (next < (addr & PUD_MASK) + PUD_SIZE) 168f0d56f0a26c Guanghui Feng 2022-06-30 391 alloc_init_cont_pmd(pudp, next, 168f0d56f0a26c Guanghui Feng 2022-06-30 392 (addr & PUD_MASK) + 168f0d56f0a26c Guanghui Feng 2022-06-30 393 PUD_SIZE, 168f0d56f0a26c Guanghui Feng 2022-06-30 394 next - addr + phys, 168f0d56f0a26c Guanghui Feng 2022-06-30 395 prot, pgtable_alloc, 168f0d56f0a26c Guanghui Feng 2022-06-30 396 flags & (~NO_SEC_REMAPPINGS)); 168f0d56f0a26c Guanghui Feng 2022-06-30 397 } 168f0d56f0a26c Guanghui Feng 2022-06-30 398 alloc_init_cont_pmd(pudp, addr, next, phys, prot, 168f0d56f0a26c Guanghui Feng 2022-06-30 399 pgtable_alloc, flags); 168f0d56f0a26c Guanghui Feng 2022-06-30 400 } 206a2a73a62d37 Steve Capper 2014-05-06 401 /* 206a2a73a62d37 Steve Capper 2014-05-06 402 * For 4K granule only, attempt to put down a 1GB block 206a2a73a62d37 Steve Capper 2014-05-06 403 */ 168f0d56f0a26c Guanghui Feng 2022-06-30 404 else if (pud_sect_supported() && 1310222c276b79 Anshuman Khandual 2022-02-16 405 ((addr | next | phys) & ~PUD_MASK) == 0 && c0951366d4b7e0 Ard Biesheuvel 2017-03-09 406 (flags & NO_BLOCK_MAPPINGS) == 0) { 20a004e7b017cc Will Deacon 2018-02-15 407 pud_set_huge(pudp, phys, prot); 206a2a73a62d37 Steve Capper 2014-05-06 408 206a2a73a62d37 Steve Capper 2014-05-06 409 /* e98216b52176ba Ard Biesheuvel 2016-10-21 410 * After the PUD entry has been populated once, we e98216b52176ba Ard Biesheuvel 2016-10-21 411 * only allow updates to the permission attributes. 206a2a73a62d37 Steve Capper 2014-05-06 412 */ e98216b52176ba Ard Biesheuvel 2016-10-21 413 BUG_ON(!pgattr_change_is_safe(pud_val(old_pud), 20a004e7b017cc Will Deacon 2018-02-15 414 READ_ONCE(pud_val(*pudp)))); 206a2a73a62d37 Steve Capper 2014-05-06 415 } else { 20a004e7b017cc Will Deacon 2018-02-15 416 alloc_init_cont_pmd(pudp, addr, next, phys, prot, c0951366d4b7e0 Ard Biesheuvel 2017-03-09 417 pgtable_alloc, flags); e98216b52176ba Ard Biesheuvel 2016-10-21 418 e98216b52176ba Ard Biesheuvel 2016-10-21 419 BUG_ON(pud_val(old_pud) != 0 && 20a004e7b017cc Will Deacon 2018-02-15 420 pud_val(old_pud) != READ_ONCE(pud_val(*pudp))); 206a2a73a62d37 Steve Capper 2014-05-06 421 } c1cc1552616d0f Catalin Marinas 2012-03-05 422 phys += next - addr; 20a004e7b017cc Will Deacon 2018-02-15 423 } while (pudp++, addr = next, addr != end); f4710445458c0a Mark Rutland 2016-01-25 424 168f0d56f0a26c Guanghui Feng 2022-06-30 425 if (!(flags & NO_SEC_REMAPPINGS)) f4710445458c0a Mark Rutland 2016-01-25 @426 pud_clear_fixmap(); ee017ee353506f Jianyong Wu 2022-02-01 427 if (system_state != SYSTEM_BOOTING) ee017ee353506f Jianyong Wu 2022-02-01 428 mutex_unlock(&fixmap_lock); c1cc1552616d0f Catalin Marinas 2012-03-05 429 } c1cc1552616d0f Catalin Marinas 2012-03-05 430 -- 0-DAY CI Kernel Test Service https://01.org/lkp