Skip to content

[Deepin-Kernel-SIG] [linux 6.6.y] [Upstream] LoongArch: Select THP_SWAP if HAVE_ARCH_TRANSPARENT_HUGEPAGE#1709

Open
opsiff wants to merge 1 commit into
deepin-community:linux-6.6.yfrom
opsiff:linux-6.6.y-2026-05-14-loongarch-perf
Open

[Deepin-Kernel-SIG] [linux 6.6.y] [Upstream] LoongArch: Select THP_SWAP if HAVE_ARCH_TRANSPARENT_HUGEPAGE#1709
opsiff wants to merge 1 commit into
deepin-community:linux-6.6.yfrom
opsiff:linux-6.6.y-2026-05-14-loongarch-perf

Conversation

@opsiff
Copy link
Copy Markdown
Member

@opsiff opsiff commented May 14, 2026

THP_SWAP has been proven to improve the swap throughput significantly on x86_64 system according to commit bd4c82c ("mm, THP, swap: delay splitting THP after swapped out"), on ARM64 system according to commit d0637c5 ("arm64: enable THP_SWAP for arm64") and on RISC-V system according to commit 87f81e6 ("riscv: enable THP_SWAP for RV64").

Enable THP_SWAP for LoongArch, testing the micro-benchmark which is introduced by commit d0637c5 ("arm64: enable THP_SWAP for arm64") shows below numbers on the Loongson-3A5000 board:

swp out bandwidth w/o patch: 1815716 bytes/ms (mean of 10 tests)
swp out bandwidth w/ patch: 3410003 bytes/ms (mean of 10 tests)

Improved by 46.75%!

[Tested in 3A6000,seem not improved, but XXX% improved in 3C5000]

Summary by Sourcery

New Features:

  • Add Kconfig support for THP_SWAP on LoongArch when HAVE_ARCH_TRANSPARENT_HUGEPAGE is selected.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 14, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Enables THP_SWAP support for the LoongArch architecture by updating its Kconfig to select THP_SWAP when transparent huge pages are supported, aligning LoongArch with other architectures that already benefit from THP-based swap performance improvements.

File-Level Changes

Change Details Files
Enable THP_SWAP for LoongArch when transparent huge pages are supported.
  • Update the LoongArch Kconfig to select THP_SWAP if HAVE_ARCH_TRANSPARENT_HUGEPAGE is set
  • Align LoongArch THP swap behavior with x86_64, arm64, and RISC-V, leveraging proven swap throughput improvements
arch/loongarch/Kconfig

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from opsiff. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@opsiff opsiff force-pushed the linux-6.6.y-2026-05-14-loongarch-perf branch from 2a136f2 to 1f2dad1 Compare May 14, 2026 05:55
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The PR description still contains a placeholder note ([Tested in 3A6000,seem not improved, but XXX% improved in 3C5000]); please replace XXX% with actual data or remove this bracketed note before merging.
  • When selecting THP_SWAP in arch/loongarch/Kconfig, ensure it is gated under the same conditions (e.g., 64-bit / HAVE_ARCH_TRANSPARENT_HUGEPAGE constraints) as other architectures so it cannot be enabled in unsupported LoongArch configurations.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The PR description still contains a placeholder note (`[Tested in 3A6000,seem not improved, but XXX% improved in 3C5000]`); please replace `XXX%` with actual data or remove this bracketed note before merging.
- When selecting `THP_SWAP` in `arch/loongarch/Kconfig`, ensure it is gated under the same conditions (e.g., 64-bit / `HAVE_ARCH_TRANSPARENT_HUGEPAGE` constraints) as other architectures so it cannot be enabled in unsupported LoongArch configurations.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables THP swap support for LoongArch when transparent huge pages are supported, aligning LoongArch with other architectures that opt into ARCH_WANTS_THP_SWAP.

Changes:

  • Selects ARCH_WANTS_THP_SWAP from arch/loongarch/Kconfig when HAVE_ARCH_TRANSPARENT_HUGEPAGE is available.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

THP_SWAP has been proven to improve the swap throughput significantly on
x86_64 system according to commit bd4c82c ("mm, THP, swap: delay
splitting THP after swapped out"), on ARM64 system according to commit
d0637c5 ("arm64: enable THP_SWAP for arm64") and on RISC-V system
according to commit 87f81e6 ("riscv: enable THP_SWAP for RV64").

Enable THP_SWAP for LoongArch, testing the micro-benchmark which is
introduced by commit d0637c5 ("arm64: enable THP_SWAP for arm64")
shows below numbers on the Loongson-3A5000 board:

swp out bandwidth w/o patch: 1815716 bytes/ms (mean of 10 tests)
swp out bandwidth w/  patch: 3410003 bytes/ms (mean of 10 tests)

Improved by 46.75%!

Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
[Tested in 3A6000,seem not improved, but improved in 3C5000]
Before:
for((i=10;i>=1;i--)); do ./a.out; done;
swp out bandwidth: 3153612 bytes/ms
swp out bandwidth: 3153612 bytes/ms
swp out bandwidth: 3153612 bytes/ms
swp out bandwidth: 3106891 bytes/ms
swp out bandwidth: 3153612 bytes/ms
swp out bandwidth: 3153612 bytes/ms
swp out bandwidth: 3153612 bytes/ms
swp out bandwidth: 3084047 bytes/ms
swp out bandwidth: 3647220 bytes/ms
swp out bandwidth: 3647220 bytes/ms
After:
swp out bandwidth: 1997287 bytes/ms
swp out bandwidth: 3017484 bytes/ms
swp out bandwidth: 9118052 bytes/ms
swp out bandwidth: 10485760 bytes/ms
swp out bandwidth: 10754625 bytes/ms
swp out bandwidth: 9320675 bytes/ms
swp out bandwidth: 10485760 bytes/ms
swp out bandwidth: 10485760 bytes/ms
swp out bandwidth: 10754625 bytes/ms
swp out bandwidth: 9118052 bytes/ms
(cherry picked from commit ff4a244)
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
@opsiff opsiff force-pushed the linux-6.6.y-2026-05-14-loongarch-perf branch from 1f2dad1 to 38f3998 Compare May 14, 2026 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants