Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • L linux
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Kirill Smelkov
  • linux
  • Repository
  • linux
  • kernel
  • task_work.c
Find file BlameHistoryPermalink
  • Uros Bizjak's avatar
    task_work: use try_cmpxchg in task_work_add, task_work_cancel_match and task_work_run · 5fdfa161
    Uros Bizjak authored Aug 23, 2022
    Use try_cmpxchg instead of cmpxchg (*ptr, old, new) == old in
    task_work_add, task_work_cancel_match and task_work_run.  x86 CMPXCHG
    instruction returns success in ZF flag, so this change saves a compare
    after cmpxchg (and related move instruction in front of cmpxchg).
    
    Also, atomic_try_cmpxchg implicitly assigns old *ptr value to "old"
    when cmpxchg fails, enabling further code simplifications.
    
    The patch avoids extra memory read in case cmpxchg fails.
    
    Link: https://lkml.kernel.org/r/20220823152632.4517-1-ubizjak@gmail.com
    
    
    Signed-off-by: default avatarUros Bizjak <ubizjak@gmail.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    5fdfa161
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7