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
You need to sign in or sign up before continuing.
  • linux
  • tools
  • testing
  • selftests
  • resctrl
  • resctrl_tests.c
Find file BlameHistoryPermalink
  • Ilpo Järvinen's avatar
    selftests/resctrl: Replace file write with volatile variable · 90a009db
    Ilpo Järvinen authored Dec 15, 2023
    
    
    The fill_buf code prevents compiler optimizating the entire read loop
    away by writing the final value of the variable into a file. While it
    achieves the goal, writing into a file requires significant amount of
    work within the innermost test loop and also error handling.
    
    A simpler approach is to take advantage of volatile. Writing through
    a pointer to a volatile variable is enough to prevent compiler from
    optimizing the write away, and therefore compiler cannot remove the
    read loop either.
    
    Add a volatile 'value_sink' into resctrl_tests.c and make fill_buf to
    write into it. As a result, the error handling in fill_buf.c can be
    simplified.
    
    Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: default avatarReinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
    90a009db
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7