Skip to content

[Deepin-Kernel-SIG] [linux 6.6-y] [Upstream] Remove use of wait bookmarks #915

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

Conversation

opsiff
Copy link
Member

@opsiff opsiff commented Jul 2, 2025

https://lore.kernel.org/all/[email protected]/T/#m25ba483bf902a43b2858751f9255e644b60e026a

Summary by Sourcery

Remove support for wait bookmarks from the scheduler and filemap wakeup paths and simplify wakeup code accordingly.

Enhancements:

  • Drop WAITQUEUE_WALK_BREAK_CNT and bookmark-related logic from wake queue walking.
  • Simplify __wake_up_common and associated wrappers by removing bookmark parameters and loops.
  • Remove __wake_up_locked_key_bookmark API and its uses in filemap.c.
  • Eliminate WQ_FLAG_BOOKMARK definition and adjust wait queue flag values accordingly in wait.h

Matthew Wilcox (Oracle) added 2 commits July 2, 2025 16:27
mainline inclusion
from mainline-v6.7-rc1
category: bugfix

The original problem of the overly long list of waiters on a locked page
was solved properly by commit 9a1ea43 ("mm:
put_and_wait_on_page_locked() while page is migrated").  In the meantime,
using bookmarks for the writeback bit can cause livelocks, so we need to
stop using them.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
Cc: Bin Lai <[email protected]>
Cc: Benjamin Segall <[email protected]>
Cc: Daniel Bristot de Oliveira <[email protected]>
Cc: Dietmar Eggemann <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Juri Lelli <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Steven Rostedt (Google) <[email protected]>
Cc: Valentin Schneider <[email protected]>
Cc: Vincent Guittot <[email protected]>

Cc: Ingo Molnar <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
(cherry picked from commit b0b598e)
Change-Id: I1566d45a8673091974f7d35272b5d251d27b030b
mainline inclusion
from mainline-v6.7-rc1
category: bugfix

There are no users of wait bookmarks left, so simplify the wait
code by removing them.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
Acked-by: Ingo Molnar <[email protected]>
Cc: Benjamin Segall <[email protected]>
Cc: Bin Lai <[email protected]>
Cc: Daniel Bristot de Oliveira <[email protected]>
Cc: Dietmar Eggemann <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Juri Lelli <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Steven Rostedt (Google) <[email protected]>
Cc: Valentin Schneider <[email protected]>
Cc: Vincent Guittot <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
(cherry picked from commit 37acade)
Change-Id: Iafe103ff6af09c27f50849f8ac9e5926846297b0
Signed-off-by: Wentao Guan <[email protected]>
Copy link

sourcery-ai bot commented Jul 2, 2025

Reviewer's Guide

This PR removes the waitqueue “bookmark” feature from the kernel scheduler by deleting its constants, flags, parameters, and loop‐breaking logic in __wake_up_common and related wrappers, updates all wake‐up calls to the simplified interfaces without bookmarks (including mm/filemap), and adjusts wait‐queue flag definitions accordingly.

Class diagram for wait queue wake-up API after bookmark removal

classDiagram
    class wait_queue_entry_t {
        +unsigned int flags
        +void *private
        +wait_queue_func_t func
        +struct list_head entry
    }
    class wait_queue_head {
        +spinlock_t lock
        +struct list_head head
    }
    class __wake_up_common {
        +int __wake_up_common(wait_queue_head *wq_head, unsigned int mode, int nr_exclusive, int wake_flags, void *key)
    }
    class __wake_up_locked {
        +void __wake_up_locked(wait_queue_head *wq_head, unsigned int mode, int nr)
    }
    class __wake_up_locked_key {
        +void __wake_up_locked_key(wait_queue_head *wq_head, unsigned int mode, void *key)
    }
    class __wake_up_locked_sync_key {
        +void __wake_up_locked_sync_key(wait_queue_head *wq_head, unsigned int mode, void *key)
    }
    class __wake_up_on_current_cpu {
        +void __wake_up_on_current_cpu(wait_queue_head *wq_head, unsigned int mode, void *key)
    }
    class __wake_up {
        +int __wake_up(wait_queue_head *wq_head, unsigned int mode, int nr, void *key)
    }
    wait_queue_head "1" -- "*" wait_queue_entry_t : contains
    __wake_up_locked_key ..> __wake_up_common : calls
    __wake_up_locked ..> __wake_up_common : calls
    __wake_up_locked_sync_key ..> __wake_up_common : calls
    __wake_up_on_current_cpu ..> __wake_up_common : calls
    __wake_up ..> __wake_up_common : calls
Loading

File-Level Changes

Change Details Files
Remove bookmark logic from __wake_up_common and its locking wrapper
  • Delete WAITQUEUE_WALK_BREAK_CNT and bookmark parameter from __wake_up_common signature
  • Remove bookmark‐based scan‐break and flag checks inside the wakeup loop
  • Simplify __wake_up_common_lock by dropping bookmark initialization and do–while loop
kernel/sched/wait.c
Simplify wake‐up wrapper functions by dropping bookmark parameter
  • Update all __wake_up_locked*, __wake_up_locked_key*, __wake_up_locked_sync_key to call __wake_up_common without bookmark
  • Remove __wake_up_locked_key_bookmark and its EXPORT_SYMBOL
kernel/sched/wait.c
Clean up folio wake‐up logic in mm/filemap.c
  • Remove local bookmark entry and its wake-loop in folio_wake_bit
  • Replace __wake_up_locked_key_bookmark calls with direct __wake_up_locked_key invocation
mm/filemap.c
Adjust wait-queue flag definitions
  • Delete WQ_FLAG_BOOKMARK from wait.h
  • Reassign values for WQ_FLAG_CUSTOM, WQ_FLAG_DONE, and WQ_FLAG_PRIORITY
include/linux/wait.h

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

deepin pr auto review

关键摘要:

  • 移除了WQ_FLAG_BOOKMARK标志的定义和相关的函数调用,可能会影响依赖此标志的代码部分。
  • 删除了WAITQUEUE_WALK_BREAK_CNT宏定义,这可能会影响等待队列的遍历逻辑。
  • 修改了__wake_up_common__wake_up_common_lock函数的实现,移除了对bookmark的处理,这可能会改变等待队列的唤醒行为。

是否建议立即修改:

建议的修改:

  • 如果移除WQ_FLAG_BOOKMARK和相关的函数调用是故意的,需要确保所有相关的代码都已经更新,并且没有其他地方依赖这些标志和函数。
  • 如果删除WAITQUEUE_WALK_BREAK_CNT宏定义是故意的,需要确保没有代码依赖于这个宏定义,并且等待队列的遍历逻辑仍然能够正确工作。
  • 如果修改__wake_up_common__wake_up_common_lock函数的实现是故意的,需要确保这些修改不会引入新的问题,并且已经通过了充分的测试。

@deepin-ci-robot
Copy link

[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.

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

Copy link

@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 @opsiff - I've reviewed your changes and they look great!


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.

@opsiff
Copy link
Member Author

opsiff commented Jul 3, 2025

Test result:
Before patch:

Benchmark Run: 三 7月 02 2025 16:25:47 - 16:32:31
8 CPUs in system; running 1 parallel copy of tests

Dhrystone 2 using register variables 50655140.0 lps (10.0 s, 1 samples)
Double-Precision Whetstone 5024.0 MWIPS (10.0 s, 1 samples)
Execl Throughput 4470.8 lps (29.8 s, 1 samples)
File Copy 1024 bufsize 2000 maxblocks 706172.0 KBps (30.0 s, 1 samples)
File Copy 256 bufsize 500 maxblocks 201359.0 KBps (30.0 s, 1 samples)
File Copy 4096 bufsize 8000 maxblocks 2139543.0 KBps (30.0 s, 1 samples)
Pipe Throughput 1726969.6 lps (10.0 s, 1 samples)
Pipe-based Context Switching 136493.3 lps (10.0 s, 1 samples)
Process Creation 9053.5 lps (30.0 s, 1 samples)
Shell Scripts (1 concurrent) 12556.2 lpm (60.0 s, 1 samples)
Shell Scripts (8 concurrent) 4998.9 lpm (60.0 s, 1 samples)
System Call Overhead 1453198.2 lps (10.0 s, 1 samples)

System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 50655140.0 4340.6
Double-Precision Whetstone 55.0 5024.0 913.5
Execl Throughput 43.0 4470.8 1039.7
File Copy 1024 bufsize 2000 maxblocks 3960.0 706172.0 1783.3
File Copy 256 bufsize 500 maxblocks 1655.0 201359.0 1216.7
File Copy 4096 bufsize 8000 maxblocks 5800.0 2139543.0 3688.9
Pipe Throughput 12440.0 1726969.6 1388.2
Pipe-based Context Switching 4000.0 136493.3 341.2
Process Creation 126.0 9053.5 718.5
Shell Scripts (1 concurrent) 42.4 12556.2 2961.4
Shell Scripts (8 concurrent) 6.0 4998.9 8331.6
System Call Overhead 15000.0 1453198.2 968.8
========
System Benchmarks Index Score 1593.7


Benchmark Run: 三 7月 02 2025 16:32:31 - 16:39:14
8 CPUs in system; running 8 parallel copies of tests

Dhrystone 2 using register variables 207894957.3 lps (10.0 s, 1 samples)
Double-Precision Whetstone 37085.2 MWIPS (9.4 s, 1 samples)
Execl Throughput 24307.9 lps (29.1 s, 1 samples)
File Copy 1024 bufsize 2000 maxblocks 3885591.0 KBps (30.0 s, 1 samples)
File Copy 256 bufsize 500 maxblocks 1135295.0 KBps (30.0 s, 1 samples)
File Copy 4096 bufsize 8000 maxblocks 8144126.0 KBps (30.0 s, 1 samples)
Pipe Throughput 9453691.4 lps (10.0 s, 1 samples)
Pipe-based Context Switching 1137628.8 lps (10.0 s, 1 samples)
Process Creation 50709.8 lps (30.0 s, 1 samples)
Shell Scripts (1 concurrent) 43841.3 lpm (60.0 s, 1 samples)
Shell Scripts (8 concurrent) 5701.3 lpm (60.0 s, 1 samples)
System Call Overhead 9323152.0 lps (10.0 s, 1 samples)

System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 207894957.3 17814.5
Double-Precision Whetstone 55.0 37085.2 6742.8
Execl Throughput 43.0 24307.9 5653.0
File Copy 1024 bufsize 2000 maxblocks 3960.0 3885591.0 9812.1
File Copy 256 bufsize 500 maxblocks 1655.0 1135295.0 6859.8
File Copy 4096 bufsize 8000 maxblocks 5800.0 8144126.0 14041.6
Pipe Throughput 12440.0 9453691.4 7599.4
Pipe-based Context Switching 4000.0 1137628.8 2844.1
Process Creation 126.0 50709.8 4024.6
Shell Scripts (1 concurrent) 42.4 43841.3 10339.9
Shell Scripts (8 concurrent) 6.0 5701.3 9502.1
System Call Overhead 15000.0 9323152.0 6215.4
========
System Benchmarks Index Score 7546.0

After patch:
Dhrystone 2 using register variables 45735929.7 lps (10.0 s, 1 samples)
Double-Precision Whetstone 5026.5 MWIPS (10.0 s, 1 samples)
Execl Throughput 4458.3 lps (29.2 s, 1 samples)
File Copy 1024 bufsize 2000 maxblocks 711618.0 KBps (30.0 s, 1 samples)
File Copy 256 bufsize 500 maxblocks 204417.0 KBps (30.0 s, 1 samples)
File Copy 4096 bufsize 8000 maxblocks 2321920.0 KBps (30.0 s, 1 samples)
Pipe Throughput 1747502.7 lps (10.0 s, 1 samples)
Pipe-based Context Switching 136247.6 lps (10.0 s, 1 samples)
Process Creation 9092.3 lps (30.0 s, 1 samples)
Shell Scripts (1 concurrent) 12546.2 lpm (60.0 s, 1 samples)
Shell Scripts (8 concurrent) 5008.9 lpm (60.0 s, 1 samples)
System Call Overhead 1447375.3 lps (10.0 s, 1 samples)

System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 45735929.7 3919.1
Double-Precision Whetstone 55.0 5026.5 913.9
Execl Throughput 43.0 4458.3 1036.8
File Copy 1024 bufsize 2000 maxblocks 3960.0 711618.0 1797.0
File Copy 256 bufsize 500 maxblocks 1655.0 204417.0 1235.1
File Copy 4096 bufsize 8000 maxblocks 5800.0 2321920.0 4003.3
Pipe Throughput 12440.0 1747502.7 1404.7
Pipe-based Context Switching 4000.0 136247.6 340.6
Process Creation 126.0 9092.3 721.6
Shell Scripts (1 concurrent) 42.4 12546.2 2959.0
Shell Scripts (8 concurrent) 6.0 5008.9 8348.2
System Call Overhead 15000.0 1447375.3 964.9
========
System Benchmarks Index Score 1595.2


Benchmark Run: 三 7月 02 2025 18:39:38 - 18:46:21
8 CPUs in system; running 8 parallel copies of tests

Dhrystone 2 using register variables 207875447.4 lps (10.0 s, 1 samples)
Double-Precision Whetstone 36511.1 MWIPS (10.0 s, 1 samples)
Execl Throughput 24289.1 lps (29.1 s, 1 samples)
File Copy 1024 bufsize 2000 maxblocks 4070364.0 KBps (30.0 s, 1 samples)
File Copy 256 bufsize 500 maxblocks 1158825.0 KBps (30.0 s, 1 samples)
File Copy 4096 bufsize 8000 maxblocks 8050024.0 KBps (30.0 s, 1 samples)
Pipe Throughput 9563225.7 lps (10.0 s, 1 samples)
Pipe-based Context Switching 1167311.4 lps (10.0 s, 1 samples)
Process Creation 51302.4 lps (30.0 s, 1 samples)
Shell Scripts (1 concurrent) 43861.1 lpm (60.0 s, 1 samples)
Shell Scripts (8 concurrent) 5705.1 lpm (60.0 s, 1 samples)
System Call Overhead 9306447.0 lps (10.0 s, 1 samples)

System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 207875447.4 17812.8
Double-Precision Whetstone 55.0 36511.1 6638.4
Execl Throughput 43.0 24289.1 5648.6
File Copy 1024 bufsize 2000 maxblocks 3960.0 4070364.0 10278.7
File Copy 256 bufsize 500 maxblocks 1655.0 1158825.0 7002.0
File Copy 4096 bufsize 8000 maxblocks 5800.0 8050024.0 13879.4
Pipe Throughput 12440.0 9563225.7 7687.5
Pipe-based Context Switching 4000.0 1167311.4 2918.3
Process Creation 126.0 51302.4 4071.6
Shell Scripts (1 concurrent) 42.4 43861.1 10344.6
Shell Scripts (8 concurrent) 6.0 5705.1 9508.5
System Call Overhead 15000.0 9306447.0 6204.3
========
System Benchmarks Index Score 7601.0

@Avenger-285714 Avenger-285714 merged commit 58c6e18 into deepin-community:linux-6.6.y Jul 4, 2025
9 checks passed
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.

3 participants