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

Optimize klp_shadow performance with improved locking and RCU usage #955

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Sep 16, 2024

  1. Optimize klp_shadow performance with improved locking and RCU usage

    This commit enhances the performance of the klp_shadow module by applying several optimizations:
    
    - **Minimized spinlock contention**: Critical sections using spinlocks are reduced to only necessary regions, while memory allocation and initialization are performed outside the lock. This reduces contention and improves parallelism.
      
    - **Branch prediction hints**: Added `likely()` and `unlikely()` macros for frequently occurring conditions, improving CPU branch prediction and overall performance.
      
    - **RCU-safe lookups**: Replaced `hash_for_each_possible()` with `hash_for_each_possible_rcu()` where appropriate, allowing for more efficient read-side lookups without blocking writes.
      
    - **Optimized memory freeing**: Improved shadow variable freeing by batching operations under the lock and using `hash_for_each_rcu()` in `klp_shadow_free_all()` for faster traversal.
    
    These changes improve concurrency and efficiency in managing shadow variables, especially under high-load scenarios, while maintaining safety through proper RCU mechanisms.
    HajimohammadiNet authored Sep 16, 2024
    Configuration menu
    Copy the full SHA
    da8b5d9 View commit details
    Browse the repository at this point in the history