2023-01-06 06:26:16

by Sia Jee Heng

[permalink] [raw]
Subject: [PATCH 2/3] RISC-V: mm: Enable huge page support to kernel_page_present() function

Currently kernel_page_present() function doesn't support huge page
detection causes the function to mistakenly return false to the
hibernation core.

Add huge page detection to the function to solve the problem.

Signed-off-by: Sia Jee Heng <[email protected]>
Reviewed-by: Ley Foon Tan <[email protected]>
Reviewed-by: Mason Huo <[email protected]>
---
arch/riscv/mm/pageattr.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/arch/riscv/mm/pageattr.c b/arch/riscv/mm/pageattr.c
index 86c56616e5de..fb59d494d708 100644
--- a/arch/riscv/mm/pageattr.c
+++ b/arch/riscv/mm/pageattr.c
@@ -221,14 +221,20 @@ bool kernel_page_present(struct page *page)
p4d = p4d_offset(pgd, addr);
if (!p4d_present(*p4d))
return false;
+ if (pgtable_l5_enabled && p4d_leaf(*pud))
+ return true;

pud = pud_offset(p4d, addr);
if (!pud_present(*pud))
return false;
+ if (pgtable_l4_enabled && pud_leaf(*pud))
+ return true;

pmd = pmd_offset(pud, addr);
if (!pmd_present(*pmd))
return false;
+ if (pmd_leaf(*pmd))
+ return true;

pte = pte_offset_kernel(pmd, addr);
return pte_present(*pte);
--
2.34.1


2023-01-06 14:17:11

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/3] RISC-V: mm: Enable huge page support to kernel_page_present() function

Hi Sia,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on 1f5abbd77e2c1787e74b7c2caffac97def78ba52]

url: https://github.com/intel-lab-lkp/linux/commits/Sia-Jee-Heng/RISC-V-Change-suspend_save_csrs-and-suspend_restore_csrs-to-public-function/20230106-140835
base: 1f5abbd77e2c1787e74b7c2caffac97def78ba52
patch link: https://lore.kernel.org/r/20230106060535.104321-3-jeeheng.sia%40starfivetech.com
patch subject: [PATCH 2/3] RISC-V: mm: Enable huge page support to kernel_page_present() function
config: riscv-randconfig-r023-20230106
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 8d9828ef5aa9688500657d36cd2aefbe12bbd162)
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
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/c0a75e6ecfccdcd52d39b80c09dc6b10d32ea435
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Sia-Jee-Heng/RISC-V-Change-suspend_save_csrs-and-suspend_restore_csrs-to-public-function/20230106-140835
git checkout c0a75e6ecfccdcd52d39b80c09dc6b10d32ea435
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash arch/riscv/mm/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

>> arch/riscv/mm/pageattr.c:224:6: error: use of undeclared identifier 'pgtable_l5_enabled'; did you mean 'pgtable_l4_enabled'?
if (pgtable_l5_enabled && p4d_leaf(*pud))
^~~~~~~~~~~~~~~~~~
pgtable_l4_enabled
arch/riscv/include/asm/pgtable.h:819:13: note: 'pgtable_l4_enabled' declared here
extern bool pgtable_l4_enabled;
^
1 error generated.


vim +224 arch/riscv/mm/pageattr.c

207
208 bool kernel_page_present(struct page *page)
209 {
210 unsigned long addr = (unsigned long)page_address(page);
211 pgd_t *pgd;
212 pud_t *pud;
213 p4d_t *p4d;
214 pmd_t *pmd;
215 pte_t *pte;
216
217 pgd = pgd_offset_k(addr);
218 if (!pgd_present(*pgd))
219 return false;
220
221 p4d = p4d_offset(pgd, addr);
222 if (!p4d_present(*p4d))
223 return false;
> 224 if (pgtable_l5_enabled && p4d_leaf(*pud))

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests


Attachments:
(No filename) (2.81 kB)
config (179.88 kB)
Download all attachments

2023-01-06 14:20:59

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/3] RISC-V: mm: Enable huge page support to kernel_page_present() function

Hi Sia,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on 1f5abbd77e2c1787e74b7c2caffac97def78ba52]

url: https://github.com/intel-lab-lkp/linux/commits/Sia-Jee-Heng/RISC-V-Change-suspend_save_csrs-and-suspend_restore_csrs-to-public-function/20230106-140835
base: 1f5abbd77e2c1787e74b7c2caffac97def78ba52
patch link: https://lore.kernel.org/r/20230106060535.104321-3-jeeheng.sia%40starfivetech.com
patch subject: [PATCH 2/3] RISC-V: mm: Enable huge page support to kernel_page_present() function
config: riscv-rv32_defconfig
compiler: riscv32-linux-gcc (GCC) 12.1.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/c0a75e6ecfccdcd52d39b80c09dc6b10d32ea435
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Sia-Jee-Heng/RISC-V-Change-suspend_save_csrs-and-suspend_restore_csrs-to-public-function/20230106-140835
git checkout c0a75e6ecfccdcd52d39b80c09dc6b10d32ea435
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=riscv olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

arch/riscv/mm/pageattr.c: In function 'kernel_page_present':
>> arch/riscv/mm/pageattr.c:224:13: error: 'pgtable_l5_enabled' undeclared (first use in this function); did you mean 'pgtable_l4_enabled'?
224 | if (pgtable_l5_enabled && p4d_leaf(*pud))
| ^~~~~~~~~~~~~~~~~~
| pgtable_l4_enabled
arch/riscv/mm/pageattr.c:224:13: note: each undeclared identifier is reported only once for each function it appears in


vim +224 arch/riscv/mm/pageattr.c

207
208 bool kernel_page_present(struct page *page)
209 {
210 unsigned long addr = (unsigned long)page_address(page);
211 pgd_t *pgd;
212 pud_t *pud;
213 p4d_t *p4d;
214 pmd_t *pmd;
215 pte_t *pte;
216
217 pgd = pgd_offset_k(addr);
218 if (!pgd_present(*pgd))
219 return false;
220
221 p4d = p4d_offset(pgd, addr);
222 if (!p4d_present(*p4d))
223 return false;
> 224 if (pgtable_l5_enabled && p4d_leaf(*pud))

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests


Attachments:
(No filename) (2.68 kB)
config (117.46 kB)
Download all attachments