Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge arm64/riscv hugetlbfs contpte support #981

Closed
wants to merge 10 commits into from

Conversation

bjoto
Copy link

@bjoto bjoto commented May 8, 2024

Pull request for series with
subject: Merge arm64/riscv hugetlbfs contpte support
version: 2
url: https://patchwork.kernel.org/project/linux-riscv/list/?series=851551

@bjoto
Copy link
Author

bjoto commented May 8, 2024

Upstream branch: 6beb6bc
series: https://patchwork.kernel.org/project/linux-riscv/list/?series=851551
version: 2

Alexandre Ghiti added 9 commits May 14, 2024 19:49
The core mm code expects to be able to extract the pfn from a pte. NAPOT
mappings work differently since its ptes actually point to the first pfn
of the mapping, the other bits being used to encode the size of the
mapping.

So modify ptep_get() so that it returns a pte value that contains the
*real* pfn (which is then different from what the HW expects) and right
before storing the ptes to the page table, reset the pfn LSBs to the
size of the mapping.

And make sure that all NAPOT mappings are set using set_ptes().

Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
The pte_t pointer is expected to point to the first entry of the NAPOT
mapping so no need to use huge_pte_offset(), similarly to what is done
in arm64.

Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
For that, we need to introduce:

- a new config: ARCH_HAS_CONTPTE,
- a new arch specific function which returns the number of contiguous PTE
  in a mapping and its base page size,
- a pte_cont() helper, only introduced for riscv since we keep the arm64
  naming (contpte) which is more explicit than the riscv's (napot).

Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
After some adjustments, both architectures have the same implementation
so move it to generic code.

Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Both architectures have the same implementation so move it to generic code.

Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
After some adjustments, both architectures have the same implementation
so move it to the generic code.

Note that get_clear_contig() function is duplicated in the generic and
the arm64 code because it is still used by some arm64 functions that
will, in the next commits, be moved to the generic code. Once all have
been moved, the arm64 version will be removed.

Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Both architectures have almost the same implementation:
__cont_access_flags_changed() is also correct on riscv and brings the
same benefits (ie don't do anything if the flags are unchanged).

As in the previous commit, get_clear_contig_flush() is duplicated in both
the arch and the generic codes, it will be removed from the arch code when
the last reference there gets moved to the generic code.

Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
After some adjustments, both architectures have the same implementation
so move it to the generic code.

Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
After some adjustments, both architectures have the same implementation
so move it to the generic code.

Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
@bjoto bjoto reopened this May 14, 2024
@bjoto
Copy link
Author

bjoto commented May 14, 2024

Upstream branch: 6beb6bc
series: https://patchwork.kernel.org/project/linux-riscv/list/?series=851551
version: 2

@bjoto
Copy link
Author

bjoto commented May 22, 2024

Upstream branch: 0bfbc91
series: https://patchwork.kernel.org/project/linux-riscv/list/?series=851551
version: 2

Pull request is NOT updated. Failed to apply https://patchwork.kernel.org/project/linux-riscv/list/?series=851551
error message:

Cmd('git') failed due to: exit code(128)
  cmdline: git am -s --3way
  stdout: 'Applying: riscv: Restore the pfn in a NAPOT pte when manipulated by core mm code
Applying: riscv: Safely remove huge_pte_offset() when manipulating NAPOT ptes
Applying: mm: Use common huge_ptep_get() function for riscv/arm64
Applying: mm: Use common set_huge_pte_at() function for riscv/arm64
Applying: mm: Use common huge_pte_clear() function for riscv/arm64
Applying: mm: Use common huge_ptep_get_and_clear() function for riscv/arm64
Patch failed at 0006 mm: Use common huge_ptep_get_and_clear() function for riscv/arm64
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".'
  stderr: 'error: sha1 information is lacking or useless (arch/riscv/include/asm/pgtable.h).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch'

conflict:


@bjoto bjoto closed this May 23, 2024
@bjoto bjoto reopened this May 23, 2024
@bjoto bjoto closed this May 27, 2024
@bjoto bjoto deleted the series/831446=>fixes branch June 1, 2024 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant