Tejun Heo
258df8fce4
mm: Add ptep_try_set() for lockless empty-slot installs
...
Add ptep_try_set(ptep, new_pte): atomically set *ptep to new_pte iff it is
currently pte_none(). Returns true on success, false if the slot was already
populated or the arch has no implementation.
The intended caller is the upcoming bpf_arena kernel-side fault recovery
path. The install runs from a page fault that can be nested under locks
held by the faulting kernel caller (e.g. a BPF program holding
raw_res_spin_lock_irqsave on its arena's spinlock), so trylock-and-retry
would A-A deadlock. Lock-free cmpxchg is the only viable option, which
constrains this helper to special kernel page tables where concurrent
writers cooperate via atomic accessors.
The generic version in <linux/pgtable.h> returns false. x86 and arm64
override with try_cmpxchg-based implementations on the underlying pteval.
Other architectures get the false stub - the callers there already fall
through to oops.
v2: Rename to ptep_try_set(). Tighten kerneldoc. (David, Alexei)
v3: Note that strict-zero cmpxchg is narrower than pte_none(). (Andrea)
Suggested-by: Kumar Kartikeya Dwivedi <memxor@gmail.com >
Suggested-by: Alexei Starovoitov <ast@kernel.org >
Signed-off-by: Tejun Heo <tj@kernel.org >
Reviewed-by: Andrea Righi <arighi@nvidia.com >
Cc: David Hildenbrand <david@kernel.org >
Acked-by: David Hildenbrand (arm) <david@kernel.org >
Link: https://lore.kernel.org/r/20260522172219.1423324-2-tj@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org >
2026-05-23 01:50:32 -07:00
..
2026-04-13 19:03:11 -07:00
2026-04-08 19:38:52 -07:00
2026-04-16 20:34:34 -07:00
2026-04-16 19:27:51 -07:00
2026-04-13 20:10:58 -07:00
2026-04-06 09:04:53 +02:00
2026-05-11 14:56:03 +02:00
2026-04-18 00:10:48 -07:00
2026-04-20 11:31:01 -07:00
2026-04-20 11:20:35 -07:00
2026-04-15 14:15:25 -07:00
2026-04-27 15:08:04 +02:00
2026-05-08 01:30:16 +02:00
2026-05-08 01:30:16 +02:00
2026-05-08 01:30:16 +02:00
2026-05-08 01:30:16 +02:00
2026-04-24 13:23:50 -07:00
2026-04-06 09:37:50 -05:00
2026-04-06 09:37:51 -05:00
2026-05-13 15:00:40 -07:00
2026-04-17 14:18:55 -07:00
2026-04-22 15:10:22 +01:00
2026-04-24 14:20:03 -07:00
2026-04-19 08:47:40 -07:00
2026-04-15 16:52:20 +02:00
2026-04-18 00:10:50 -07:00
2026-05-06 17:08:39 +01:00
2026-04-13 14:56:54 -07:00
2026-05-13 13:55:06 -06:00
2026-04-09 13:28:05 -04:00
2026-04-13 15:51:31 -07:00
2026-04-10 21:22:32 -07:00
2026-04-16 07:03:40 -07:00
2026-04-06 18:37:52 -07:00
2026-04-22 12:58:57 -07:00
2026-04-12 11:33:23 -07:00
2026-04-27 15:52:51 -06:00
2026-05-04 08:52:26 -10:00
2026-05-04 09:06:03 -10:00
2026-04-16 10:12:43 -07:00
2026-04-11 07:58:33 +02:00
2026-04-14 10:53:44 -07:00
2026-04-15 08:37:45 -07:00
2026-04-07 15:32:20 +02:00
2026-04-18 00:10:51 -07:00
2026-04-21 14:12:01 -07:00
2026-04-21 07:30:44 -07:00
2026-04-19 12:58:08 -07:00
2026-04-27 10:26:49 +02:00
2026-04-08 15:27:47 +02:00
2026-04-30 11:37:39 +02:00
2026-04-06 20:21:37 -06:00
2026-04-16 22:19:29 +02:00
2026-04-24 00:36:50 +02:00
2026-04-16 07:03:40 -07:00
2026-04-05 13:53:07 -07:00
2026-04-05 13:53:07 -07:00
2026-04-07 17:38:07 +02:00
2026-05-11 19:04:46 +09:00
2026-04-19 08:01:17 -07:00
2026-04-16 13:31:04 +02:00
2026-04-06 20:21:37 -06:00
2026-04-06 20:21:37 -06:00
2026-04-08 14:23:29 -07:00
2026-05-12 18:03:37 +02:00
2026-05-12 18:03:58 +02:00
2026-04-12 16:46:29 +08:00
2026-04-05 13:53:45 -07:00
2026-04-05 13:53:25 -07:00
2026-04-15 12:59:16 -07:00
2026-04-06 09:43:18 -05:00
2026-04-22 09:50:46 -07:00
2026-04-07 15:36:02 +02:00
2026-04-08 08:55:15 +02:00
2026-04-12 15:20:46 -07:00
2026-04-13 15:09:49 +02:00
2026-04-23 12:13:57 +02:00
2026-05-07 16:06:28 +03:00
2026-04-13 16:22:30 -07:00
2026-04-15 12:59:16 -07:00
2026-04-09 13:18:27 +01:00
2026-05-08 17:00:44 +02:00
2026-04-09 10:52:35 -04:00
2026-04-05 13:53:28 -07:00
2026-04-13 10:10:28 -07:00
2026-04-18 00:10:48 -07:00
2026-04-21 16:41:54 +01:00
2026-04-05 13:53:04 -07:00
2026-04-09 14:36:52 +02:00
2026-04-09 14:36:52 +02:00
2026-04-05 13:53:40 -07:00
2026-04-13 19:00:43 +02:00
2026-04-05 13:53:46 -07:00
2026-04-18 00:10:50 -07:00
2026-04-13 15:42:19 -07:00
2026-04-18 13:07:36 -05:00
2026-04-27 05:54:25 -07:00
2026-04-06 11:39:54 +02:00
2026-04-18 11:29:14 -07:00
2026-04-18 00:10:48 -07:00
2026-04-05 13:53:32 -07:00
2026-04-05 13:53:33 -07:00
2026-04-05 13:53:01 -07:00
2026-04-18 00:10:47 -07:00
2026-04-05 13:53:45 -07:00
2026-04-27 05:54:24 -07:00
2026-04-05 13:53:41 -07:00
2026-04-08 13:18:57 -07:00
2026-04-15 12:59:16 -07:00
2026-04-19 08:01:17 -07:00
2026-04-27 18:46:17 -07:00
2026-04-13 14:56:28 -07:00
2026-04-24 09:41:58 -07:00
2026-04-22 08:53:23 -04:00
2026-04-13 11:46:08 -07:00
2026-04-24 00:34:59 +02:00
2026-04-27 15:47:21 -06:00
2026-04-17 14:09:02 -07:00
2026-04-05 13:53:12 -07:00
2026-04-05 13:53:17 -07:00
2026-04-05 13:53:19 -07:00
2026-04-05 13:53:10 -07:00
2026-04-10 17:27:39 -05:00
2026-04-06 16:55:16 +02:00
2026-04-15 14:41:21 -07:00
2026-04-18 00:10:50 -07:00
2026-05-23 01:50:32 -07:00
2026-04-12 11:33:23 -07:00
2026-04-20 11:35:17 -07:00
2026-04-20 15:42:18 -07:00
2026-04-21 12:48:44 +02:00
2026-04-07 12:24:49 -07:00
2026-04-10 11:46:15 +01:00
2026-04-20 20:10:50 -10:00
2026-04-20 20:10:50 -10:00
2026-04-06 09:37:51 -05:00
2026-05-08 17:00:44 +02:00
2026-05-06 17:40:15 +02:00
2026-05-05 16:02:57 +02:00
2026-05-14 08:32:11 -07:00
2026-04-13 15:42:19 -07:00
2026-04-19 08:44:41 -07:00
2026-04-19 08:01:17 -07:00
2026-04-12 10:54:31 -07:00
2026-05-05 16:12:07 +08:00
2026-05-01 16:24:25 -05:00
2026-04-18 00:10:47 -07:00
2026-04-13 19:03:11 -07:00
2026-04-17 14:23:26 -06:00
2026-04-08 12:30:31 +02:00
2026-04-21 18:54:28 +03:00
2026-04-28 14:28:29 -04:00
2026-04-05 13:53:08 -07:00
2026-04-13 08:39:51 -07:00
2026-04-05 13:53:44 -07:00
2026-04-06 09:06:39 +02:00
2026-04-18 00:10:54 -07:00
2026-05-13 14:49:06 -06:00
2026-04-05 13:53:04 -07:00
2026-04-20 12:02:24 -07:00
2026-04-28 06:13:40 -10:00
2026-04-05 13:53:07 -07:00