[Deepin-Kernel-SIG] [linux 6.6.y] [deepin] Input: evdev - Modify the process of closing the evdev device to use …#1636
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR adjusts the evdev client detach path to use synchronize_rcu_expedited() instead of synchronize_rcu() during system halt, power-off, or restart, in order to reduce shutdown latency while preserving the normal synchronize_rcu() behavior in all other runtime cases. Sequence diagram for evdev_detach_client RCU synchronization on shutdownsequenceDiagram
participant Caller
participant evdev as evdev_detach_client
participant RCU as RCU_subsystem
Caller->>evdev: evdev_detach_client(evdev, client)
evdev->>evdev: spin_lock(evdev->client_lock)
evdev->>evdev: list_del_rcu(client->node)
evdev->>evdev: spin_unlock(evdev->client_lock)
alt system_state is SYSTEM_HALT or SYSTEM_POWER_OFF or SYSTEM_RESTART
evdev->>RCU: synchronize_rcu_expedited()
RCU-->>evdev: expedited grace period complete
else system_state is any other state
evdev->>RCU: synchronize_rcu()
RCU-->>evdev: normal grace period complete
end
evdev-->>Caller: detach complete
Flow diagram for conditional RCU synchronization in evdev_detach_clientflowchart TD
A["Start evdev_detach_client"] --> B["Acquire client_lock spinlock"]
B --> C["Remove client from list with list_del_rcu"]
C --> D["Release client_lock spinlock"]
D --> E{system_state}
E -->|SYSTEM_HALT| F["Call synchronize_rcu_expedited"]
E -->|SYSTEM_POWER_OFF| F
E -->|SYSTEM_RESTART| F
E -->|Any other state| G["Call synchronize_rcu"]
F --> H["RCU grace period completed"]
G --> H
H --> I["Return from evdev_detach_client"]
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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
…the synchronize_rcu_expedited interface to speed up the shutdown process. deepin inclusion categroy: performace As Documentations saied: synchronize_rcu_expedited() instead of synchronize_rcu(). This reduces latency, but can increase CPU utilization, degrade real-time latency, and degrade energy efficiency. use it to optimize the shutdown process by our system developer report where some input dev shutdown cost many XXms. With the patched kernel, shutdown cost time from 5.96 to 5.11. Tested-by: qiancheng <qiancheng@uniontech.com> Signed-off-by: huangbibo <huangbibo@uniontech.com> Signed-off-by: tuhaowen <tuhaowen@uniontech.com> Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
a320522 to
bfaaaf8
Compare
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The repeated
system_statechecks can be simplified by using an existing helper likein_shutdown()(if available in this kernel) or a small static inline helper, which will make the intent clearer and reduce duplication. - Given the higher cost of
synchronize_rcu_expedited(), it would be worth briefly confirming thatevdev_detach_client()is only called a small, bounded number of times during shutdown so this change doesn’t introduce unnecessary CPU spikes in that path.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The repeated `system_state` checks can be simplified by using an existing helper like `in_shutdown()` (if available in this kernel) or a small static inline helper, which will make the intent clearer and reduce duplication.
- Given the higher cost of `synchronize_rcu_expedited()`, it would be worth briefly confirming that `evdev_detach_client()` is only called a small, bounded number of times during shutdown so this change doesn’t introduce unnecessary CPU spikes in that path.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
This PR optimizes evdev client teardown during system shutdown by switching from a normal RCU grace-period wait to an expedited one when the kernel is halting, powering off, or restarting, reducing shutdown latency in the input stack.
Changes:
- Update
evdev_detach_client()to callsynchronize_rcu_expedited()whensystem_stateisSYSTEM_HALT,SYSTEM_POWER_OFF, orSYSTEM_RESTART. - Preserve existing behavior (
synchronize_rcu()) during normal runtime.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…the synchronize_rcu_expedited interface to speed up the shutdown process.
deepin inclusion
categroy: performace
As Documentations saied:
synchronize_rcu_expedited() instead
of synchronize_rcu(). This reduces latency,
but can increase CPU utilization, degrade
real-time latency, and degrade energy efficiency.
use it to optimize the shutdown process by
our system developer report where some input dev shutdown cost many XXms.
With the patched kernel, shutdown cost time from 5.96 to 5.11.
Tested-by: qiancheng qiancheng@uniontech.com
Summary by Sourcery
Enhancements: