-
Notifications
You must be signed in to change notification settings - Fork 92
[Deepin-Kernel-SIG] [linux 6.6-y] [Upstream] merge pipe optimization from mainline v6.7 #913
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
[Deepin-Kernel-SIG] [linux 6.6-y] [Upstream] merge pipe optimization from mainline v6.7 #913
Conversation
mainline inclusion from mainline-v6.7-rc1 category: performance This has no effect on 64 bit because there are 10 32-bit integers surrounding the two bools, but on 32 bit architectures, this reduces the struct size by 4 bytes by merging the two bools into one word. Signed-off-by: Max Kellermann <[email protected]> Message-Id: <[email protected]> Signed-off-by: Christian Brauner <[email protected]> (cherry picked from commit 61105aa) Signed-off-by: Wentao Guan <[email protected]> Change-Id: I3bd93024632f840bbcee33cf88dd7433e782db1a
mainline inclusion from mainline-v6.7-rc1 category: performance This reverts commit 8df4412 ("pipe: Check for ring full inside of the spinlock in pipe_write()") which was obsoleted by commit c73be61 ("pipe: Add general notification queue support") because now pipe_write() fails early with -EXDEV if there is a watch_queue. Without a watch_queue, no notifications can be posted to the pipe and mutex protection is enough, as can be seen in splice_pipe_to_pipe() which does not use the spinlock either. Signed-off-by: Max Kellermann <[email protected]> Message-Id: <[email protected]> Reviewed-by: David Howells <[email protected]> Signed-off-by: Christian Brauner <[email protected]> (cherry picked from commit dfaabf9) Signed-off-by: Wentao Guan <[email protected]> Change-Id: I321d4c751c752c5e7e2c1a7b817b0e8cc14f1fe5
mainline inclusion from mainline-v6.7-rc1 category: performance If there is no watch_queue, holding the pipe mutex is enough to prevent concurrent writes, and we can avoid the spinlock. O_NOTIFICATION_QUEUE is an exotic and rarely used feature, and of all the pipes that exist at any given time, only very few actually have a watch_queue, therefore it appears worthwile to optimize the common case. This patch does not optimize pipe_resize_ring() where the spinlocks could be avoided as well; that does not seem like a worthwile optimization because this function is not called often. Related commits: - commit 8df4412 ("pipe: Check for ring full inside of the spinlock in pipe_write()") - commit b667b86 ("pipe: Advance tail pointer inside of wait spinlock in pipe_read()") - commit 189b0dd ("pipe: Fix missing lock in pipe_resize_ring()") Signed-off-by: Max Kellermann <[email protected]> Message-Id: <[email protected]> Reviewed-by: David Howells <[email protected]> Signed-off-by: Christian Brauner <[email protected]> (cherry picked from commit 478dbf1) Signed-off-by: Wentao Guan <[email protected]> Change-Id: Icdeb15fb11c0c6e6d07a3adb17b46457795396a0
Reviewer's GuideThis PR merges the upstream pipe optimization from mainline v6.7 by centralizing pipe tail updates into a new helper with conditional locking, refactoring pipe_read to use it, removing redundant locks in pipe_write, and reorganizing the note_loss flag placement in the pipe_inode_info struct. Sequence diagram for pipe tail update in pipe_readsequenceDiagram
participant pipe_read
participant pipe_update_tail
participant pipe_inode_info
participant pipe_buffer
pipe_read->>pipe_update_tail: call with (pipe, buf, tail)
pipe_update_tail->>pipe_buffer: pipe_buf_release(pipe, buf)
alt pipe_has_watch_queue(pipe)
pipe_update_tail->>pipe_inode_info: spin_lock_irq(&rd_wait.lock)
pipe_update_tail->>pipe_inode_info: update note_loss if needed
pipe_update_tail->>pipe_inode_info: increment tail
pipe_update_tail->>pipe_inode_info: spin_unlock_irq(&rd_wait.lock)
else
pipe_update_tail->>pipe_inode_info: increment tail (mutex is enough)
end
pipe_update_tail-->>pipe_read: return new tail
Class diagram for updated pipe_inode_info structureclassDiagram
class pipe_inode_info {
unsigned int head
unsigned int tail
unsigned int max_usage
unsigned int ring_size
#ifdef CONFIG_WATCH_QUEUE
bool note_loss
#endif
unsigned int nr_accounted
unsigned int readers
unsigned int writers
unsigned int r_counter
unsigned int w_counter
bool poll_usage
struct page *tmp_page
struct fasync_struct *fasync_readers
struct fasync_struct *fasync_writers
}
Class diagram for new pipe_update_tail helperclassDiagram
class pipe_update_tail {
+unsigned int pipe_update_tail(pipe_inode_info *pipe, pipe_buffer *buf, unsigned int tail)
}
class pipe_inode_info
class pipe_buffer
pipe_update_tail --> pipe_inode_info
pipe_update_tail --> pipe_buffer
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test result: Dhrystone 2 using register variables 50676438.6 lps (10.0 s, 1 samples) System Benchmarks Index Values BASELINE RESULT INDEX Benchmark Run: 二 7月 01 2025 15:56:06 - 16:02:49 Dhrystone 2 using register variables 207741722.5 lps (10.0 s, 1 samples) System Benchmarks Index Values BASELINE RESULT INDEX After patch: Dhrystone 2 using register variables 45448570.8 lps (10.0 s, 1 samples) System Benchmarks Index Values BASELINE RESULT INDEX Benchmark Run: 三 7月 02 2025 13:43:03 - 13:49:46 Dhrystone 2 using register variables 207902728.4 lps (10.0 s, 1 samples) System Benchmarks Index Values BASELINE RESULT INDEX |
https://lore.kernel.org/all/[email protected]/
Merged:
fs/pipe: move check to pipe_has_watch_queue()
Summary by Sourcery
Integrate mainline v6.7 pipe performance optimizations by consolidating tail-update logic, reducing unnecessary locking, and reorganizing the note_loss flag.
Enhancements: