diff mbox series

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

Message ID 20230106060535.104321-3-jeeheng.sia@starfivetech.com (mailing list archive)
State Superseded
Headers show
Series RISC-V Hibernation Support | expand

Checks

Context Check Description
conchuod/patch_count success Link
conchuod/cover_letter success Series has a cover letter
conchuod/tree_selection success Guessed tree name to be for-next
conchuod/fixes_present success Fixes tag not required for -next series
conchuod/maintainers_pattern success MAINTAINERS pattern errors before the patch: 13 and now 13
conchuod/verify_signedoff success Signed-off-by tag matches author and committer
conchuod/kdoc success Errors and warnings before: 0 this patch: 0
conchuod/module_param success Was 0 now: 0
conchuod/alphanumeric_selects success Out of order selects before the patch: 57 and now 57
conchuod/build_rv32_defconfig fail Build failed
conchuod/build_warn_rv64 success Errors and warnings before: 2054 this patch: 2054
conchuod/dtb_warn_rv64 success Errors and warnings before: 0 this patch: 0
conchuod/header_inline success No static functions without inline keyword in header files
conchuod/checkpatch success total: 0 errors, 0 warnings, 0 checks, 20 lines checked
conchuod/source_inline success Was 0 now: 0
conchuod/build_rv64_nommu_k210_defconfig success Build OK
conchuod/verify_fixes success No Fixes tag
conchuod/build_rv64_nommu_virt_defconfig success Build OK

Commit Message

Sia Jee Heng Jan. 6, 2023, 6:05 a.m. UTC
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 <jeeheng.sia@starfivetech.com>
Reviewed-by: Ley Foon Tan <leyfoon.tan@starfivetech.com>
Reviewed-by: Mason Huo <mason.huo@starfivetech.com>
---
 arch/riscv/mm/pageattr.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

kernel test robot Jan. 6, 2023, 1:21 p.m. UTC | #1
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 <lkp@intel.com>

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))
kernel test robot Jan. 6, 2023, 2:01 p.m. UTC | #2
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 <lkp@intel.com>

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))
diff mbox series

Patch

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);