VOOZH about

URL: https://www.phoronix.com/news/Linux-6.19-Scoped-User-Access

⇱ Scoped User Access In Linux 6.19 To Reduce Speculation Barriers & Its Performance Hit - Phoronix


👁 Phoronix

Scoped User Access In Linux 6.19 To Reduce Speculation Barriers & Its Performance Hit

Written by Michael Larabel in Linux Security on 3 December 2025 at 06:29 AM EST. 3 Comments
Merged yesterday to the Linux 6.19 Git codebase was the "core/uaccess" pull that introduces new scoped user-mode access with auto-cleanup functionality. This can reduce the number of speculation barriers encountered when needing to access user-mode memory and thereby avoiding some of the performance penalties incurred by speculation barriers.

Intel Fellow Thomas Gleixner pursued this scoped user access functionality for the Linux kernel in an effort to avoid the need for some speculation barriers to cut-down on the performance overhead in the kernel's hot code paths.

Gleixner explained in the core/uaccess pull request of this new kernel functionality:
"Scoped user mode access with auto cleanup

Access to user mode memory can be required in hot code paths, but if it has to be done with user controlled pointers, the access is shielded with a speculation barrier, so that the CPU cannot speculate around the address range check. Those speculation barriers impact performance quite significantly. This can be avoided by "masking" the provided pointer so it is guaranteed to be in the valid user memory access range and otherwise to point to a guaranteed unpopulated address space. This has to be done without branches so it creates an address dependency for the access, which the CPU cannot speculate ahead.

This results in repeating and error prone programming patterns:

      if (can_do_masked_user_access())
            from = masked_user_read_access_begin((from));
      else if (!user_read_access_begin(from, sizeof(*from)))
            return -EFAULT;
      unsafe_get_user(val, from, Efault);
      user_read_access_end();
      return 0;
      Efault:
            user_read_access_end();
            return -EFAULT;

which can be replaced with scopes and automatic cleanup:

      scoped_user_read_access(from, Efault)
            unsafe_get_user(val, from, Efault);
      return 0;
Efault:
      return -EFAULT;"

The kernel's x86 futex and select code are among the users adapted to using scoped user access as part of this merge.

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.