Per-CPU memory for user space

The kernel makes extensive use of per-CPU data as a way to avoid contention between processors and improve scalability. Using the same technique in user space is harder, though, since there is little control over which CPU a process may be running on at any given time. That hasn't stopped Mathieu Desnoyers from trying, though; in the memory-management track of the 2025 Linux Storage, Filesystem, Memory-Management, and BPF Summit, he presented a proposal for how user-space per-CPU memory could work.
内核广泛使用每 CPU 数据(per-CPU data)来避免处理器之间的竞争并提高可扩展性。然而,在用户空间中使用同样的技术要困难得多,因为无法很好地控制一个进程在任何时刻运行在哪个 CPU 上。但这并没有阻止 Mathieu Desnoyers 尝试这一方向;在 2025 年 Linux 存储、文件系统、内存管理与 BPF 峰会的内存管理专题中,他提出了一个用户空间 per-CPU 内存的工作提案。

Desnoyers started by saying that his objective is to help user-space developers make better use of restartable sequences, which facilitate some types of access to per-CPU data by interrupting a process if it is migrated during a critical section. User-space applications generally use thread-local storage for this kind of code, but that becomes inefficient if there are more threads running than CPUs to run on. Thread-local storage must also be defined statically, making it inflexible to work with, and it can slow down thread creation if the area is large.
Desnoyers 开场表示,他的目标是帮助用户空间开发者更好地利用可重启序列(restartable sequences),该机制允许在关键区段中,如果进程被迁移,则中断其访问,从而便于访问 per-CPU 数据。用户空间应用通常会使用线程局部存储(thread-local storage)来实现这类代码,但如果运行的线程数量多于 CPU 数量,这种方式的效率会变得很低。此外,线程局部存储必须在编译时静态定义,灵活性差,而且如果该区域很大,还会导致线程创建变慢。

So he would like to provide true per-CPU data as an alternative. One way not to do that, he said, is to structure per-CPU data in an array indexed by the CPU

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mounter625

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值