Re: [PATCH 2/2] rseq/selftests: Add test for mm_cid compaction

2025-02-17 Thread Mathieu Desnoyers
ore robust guarantees. Thoughts ? Thanks, Mathieu The test never fails if only 1 core is available, in which case, we cannot test anything as the only available mm_cid is 0. Reviewed-by: Mathieu Desnoyers Signed-off-by: Gabriele Monaco --- tools/testing/selftests/rseq/.gitignore |

Re: [PATCH v5 3/3] rseq/selftests: Add test for mm_cid compaction

2025-02-10 Thread Mathieu Desnoyers
ead should see 0 as mm_cid, if that doesn't happen, the compaction mechanism didn't work and the test fails. The test never fails if only 1 core is available, in which case, we cannot test anything as the only available mm_cid is 0. To: Mathieu Desnoyers Reviewed-by: Mathieu Desnoye

Re: [PATCH] selftests/rseq: Fix handling of glibc without rseq support

2025-01-15 Thread Mathieu Desnoyers
On 2025-01-15 12:57, Shuah Khan wrote: On 1/14/25 17:45, Mathieu Desnoyers wrote: On 2025-01-14 19:14, Shuah Khan wrote: On 1/14/25 07:51, Mathieu Desnoyers wrote: When porting librseq commit: commit c7b45750fa85 ("Adapt to glibc __rseq_size feature detection") from librseq to

Re: [PATCH] selftests/rseq: Fix handling of glibc without rseq support

2025-01-14 Thread Mathieu Desnoyers
On 2025-01-14 19:14, Shuah Khan wrote: On 1/14/25 07:51, Mathieu Desnoyers wrote: When porting librseq commit: commit c7b45750fa85 ("Adapt to glibc __rseq_size feature detection") from librseq to the kernel selftests, the following line was missed at the end of rseq_init():   

[PATCH] selftests/rseq: Fix handling of glibc without rseq support

2025-01-14 Thread Mathieu Desnoyers
on") Fixes: 73a4f5a704a2 ("selftests/rseq: Fix mm_cid test failure") Signed-off-by: Mathieu Desnoyers Cc: Raghavendra Rao Ananta Cc: Shuah Khan Cc: Peter Zijlstra Cc: Boqun Feng Cc: "Paul E. McKenney" Cc: Carlos O'Donell Cc: Florian Weimer Cc: Michael Jeanson

Re: [PATCH] selftests/rseq: Fix rseq for cases without glibc support

2025-01-14 Thread Mathieu Desnoyers
On 2025-01-14 09:07, Mathieu Desnoyers wrote: On 2025-01-13 18:06, Shuah Khan wrote: On 12/10/24 15:44, Raghavendra Rao Ananta wrote: Currently the rseq constructor, rseq_init(), assumes that glibc always has the support for rseq symbols (__rseq_size for instance). However, glibc supports rseq

Re: [PATCH] selftests/rseq: Fix rseq for cases without glibc support

2025-01-14 Thread Mathieu Desnoyers
atch. I need to review it carefully to make sure it does not break anything else moving forward. Please wait before merging. Thanks, Mathieu thanks, -- Shuah -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com

Re: [PATCH] rseq/selftests: Fix riscv rseq_offset_deref_addv inline asm

2025-01-10 Thread Mathieu Desnoyers
quot; constraint. I have compile tested this only for riscv. However, the same fixes I use in the OpenRISC rseq selftests and everything passes with no issues. Signed-off-by: Stafford Horne Reviewed-by: Mathieu Desnoyers --- tools/testing/selftests/rseq/rseq-riscv-bits.h | 6 +++--- tool

Re: [PATCH 3/3] rseq/selftests: Add support for OpenRISC

2025-01-10 Thread Mathieu Desnoyers
Linux: Linux buildroot 6.13.0-rc2-5-g1fa73dd6c2d3-dirty #213 SMP Sat Dec 28 22:18:39 GMT 2024 openrisc GNU/Linux Glibc: 2024-12-13 e4e49583d9 Stafford Horne or1k: Update libm-test-ulps Signed-off-by: Stafford Horne Thanks! Reviewed-by: Mathieu Desnoyers --- tools

Re: [PATCH v2 4/4] rseq/selftests: Add test for mm_cid compaction

2024-12-13 Thread Mathieu Desnoyers
test_mm_cid_compaction(); + if (rseq_unregister_current_thread()) { + fprintf(stderr, + "Error: rseq_unregister_current_thread(...) failed(%d): %s\n", + errno, strerror(errno)); + goto error; + } + return 0; + +error: + return -1; +} -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com

Re: [PATCH v2 1/4] sched: Move task_mm_cid_work to mm delayed work

2024-12-13 Thread Mathieu Desnoyers
d_migrate_to(struct rq *dst_rq, struct task_struct *t) { } -static inline void task_tick_mm_cid(struct rq *rq, struct task_struct *curr) { } -static inline void init_sched_mm_cid(struct task_struct *t) { } #endif /* !CONFIG_SCHED_MM_CID */ extern u64 avg_vruntime(struct cfs_rq *cfs_rq); -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com

Re: [PATCH v2 3/4] sched: Compact RSEQ concurrency IDs with reduced threads and affinity

2024-12-13 Thread Mathieu Desnoyers
On 2024-12-13 04:54, Gabriele Monaco wrote: From: Mathieu Desnoyers When a process reduces its number of threads or clears bits in its CPU affinity mask, the mm_cid allocation should eventually converge towards smaller values. I target v6.13 for this patch. As it fixes a commit which was

Re: [PATCH v2 2/4] sched: Remove mm_cid_next_scan as obsolete

2024-12-13 Thread Mathieu Desnoyers
goto out; /* Clear cids that were not recently used. */ for_each_possible_cpu(cpu) sched_mm_cid_remote_clear_old(mm, cpu); -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com

Re: [PATCH 2/2] sched: Move task_mm_cid_work to RCU callback

2024-12-02 Thread Mathieu Desnoyers
u(rhp, task_mm_cid_work); } void sched_mm_cid_exit_signals(struct task_struct *t) -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com

[PATCH 1/1] selftests/rseq: Fix mm_cid test failure

2024-10-08 Thread Mathieu Desnoyers
d field support") Signed-off-by: Mathieu Desnoyers Cc: Peter Zijlstra CC: Boqun Feng CC: "Paul E. McKenney" Cc: Shuah Khan CC: Carlos O'Donell CC: Florian Weimer CC: linux-kselft...@vger.kernel.org CC: sta...@vger.kernel.org --- tools/testing/selftests/rseq/rseq.c | 110

Re: [RFC PATCH v3 3/4] hazptr: Implement Hazard Pointers

2024-10-08 Thread Mathieu Desnoyers
On 2024-10-08 15:50, Mathieu Desnoyers wrote: [...] +/* Retire the protected hazard pointer from @slot. */ +static inline +void hazptr_retire(struct hazptr_slot *slot, void *addr) +{ + WARN_ON_ONCE(slot->addr != addr); + smp_store_release(&slot->addr, NULL); +} Actually,

[RFC PATCH v3 3/4] hazptr: Implement Hazard Pointers

2024-10-08 Thread Mathieu Desnoyers
kernel.org/lkml/j3scdl5iymjlxavomgc6u5ndg3svhab6ga23dr36o4f5mt333w@7xslvq6b6hmv/ Link: https://lpc.events/event/18/contributions/1731/ Signed-off-by: Mathieu Desnoyers Cc: Nicholas Piggin Cc: Michael Ellerman Cc: Greg Kroah-Hartman Cc: Sebastian Andrzej Siewior Cc: "Paul E. McKenney"

[RFC PATCH v3 4/4] sched+mm: Use hazard pointers to track lazy active mm existence

2024-10-08 Thread Mathieu Desnoyers
: 96 Socket(s):2 Stepping: 1 Frequency boost: enabled CPU(s) scaling MHz: 100% CPU max MHz: 3709. CPU min MHz: 400. BogoMIPS: 4799.75 Memory: 768 GB ram. Signed-off-by: Mathieu Desnoyers Cc: Nicholas

[RFC PATCH v3 1/4] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-10-08 Thread Mathieu Desnoyers
which depend on @a before loading @a. The same logic applies with @a and @b swapped. Suggested-by: Linus Torvalds Suggested-by: Boqun Feng Signed-off-by: Mathieu Desnoyers Reviewed-by: Boqun Feng Reviewed-by: Joel Fernandes (Google) Tested-by: Joel Fernandes (Google) Acked-by: "P

[RFC PATCH v3 0/4] sched+mm: Track lazy active mm existence with hazard pointers

2024-10-08 Thread Mathieu Desnoyers
96 +21% 192 +28% 384+4% 768-0.6% This series applies on top of v6.11.1. Signed-off-by: Mathieu Desnoyers Cc: Linus Torvalds Cc: Andrew Morton Cc: Peter Zijlstra Cc: Nicholas Piggin Cc: Michael Ellerman Cc: Greg Kroah-Hartma

[RFC PATCH v3 2/4] Documentation: RCU: Refer to ptr_eq()

2024-10-08 Thread Mathieu Desnoyers
Refer to ptr_eq() in the rcu_dereference() documentation. ptr_eq() is a mechanism that preserves address dependencies when comparing pointers, and should be favored when comparing a pointer obtained from rcu_dereference() against another pointer. Signed-off-by: Mathieu Desnoyers Acked-by: Alan

Re: [RFC PATCH v2 3/4] hp: Implement Hazard Pointers

2024-10-07 Thread Mathieu Desnoyers
On 2024-10-07 21:06, Paul E. McKenney wrote: On Mon, Oct 07, 2024 at 11:18:14AM -0700, Paul E. McKenney wrote: On Mon, Oct 07, 2024 at 10:50:46AM -0400, Mathieu Desnoyers wrote: On 2024-10-07 12:40, Peter Zijlstra wrote: On Sat, Oct 05, 2024 at 02:50:17PM -0400, Mathieu Desnoyers wrote: On

Re: [RFC PATCH 3/4] hp: Implement Hazard Pointers

2024-10-07 Thread Mathieu Desnoyers
On 2024-10-07 15:47, Boqun Feng wrote: On Thu, Oct 03, 2024 at 09:30:53AM -0400, Mathieu Desnoyers wrote: [...] + /* +* Use RCU dereference without lockdep checks, because +* lockdep is not aware of HP guarantees. +*/ + addr2 = rcu_access_pointer(*addr_p

Re: [RFC PATCH v2 3/4] hp: Implement Hazard Pointers

2024-10-07 Thread Mathieu Desnoyers
On 2024-10-07 12:40, Peter Zijlstra wrote: On Sat, Oct 05, 2024 at 02:50:17PM -0400, Mathieu Desnoyers wrote: On 2024-10-05 18:04, Peter Zijlstra wrote: +/* + * hp_allocate: Allocate a hazard pointer. + * + * Allocate a hazard pointer slot for @addr. The object existence should + * be

Re: [RFC PATCH v2 3/4] hp: Implement Hazard Pointers

2024-10-07 Thread Mathieu Desnoyers
On 2024-10-07 12:42, Peter Zijlstra wrote: On Sat, Oct 05, 2024 at 02:56:26PM -0400, Mathieu Desnoyers wrote: On 2024-10-05 18:07, Peter Zijlstra wrote: On Sat, Oct 05, 2024 at 06:04:44PM +0200, Peter Zijlstra wrote: On Fri, Oct 04, 2024 at 02:27:33PM -0400, Mathieu Desnoyers wrote: +void

Re: [PATCH 1/2] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-10-07 Thread Mathieu Desnoyers
On 2024-10-07 15:18, David Laight wrote: From: Jonas Oberhauser Sent: 07 October 2024 12:55 Am 10/3/2024 um 3:23 PM schrieb Mathieu Desnoyers: What _does_ work however are the following two approaches: 1) Perform the equality check on the original variables, creating new versions (with

Re: [RFC PATCH v2 3/4] hp: Implement Hazard Pointers

2024-10-05 Thread Mathieu Desnoyers
On 2024-10-05 18:07, Peter Zijlstra wrote: On Sat, Oct 05, 2024 at 06:04:44PM +0200, Peter Zijlstra wrote: On Fri, Oct 04, 2024 at 02:27:33PM -0400, Mathieu Desnoyers wrote: +void hp_scan(struct hp_slot __percpu *percpu_slots, void *addr, +void (*retire_cb)(int cpu, struct

Re: [RFC PATCH v2 3/4] hp: Implement Hazard Pointers

2024-10-05 Thread Mathieu Desnoyers
On 2024-10-05 18:04, Peter Zijlstra wrote: On Fri, Oct 04, 2024 at 02:27:33PM -0400, Mathieu Desnoyers wrote: include/linux/hp.h | 158 + kernel/Makefile| 2 +- kernel/hp.c| 46 + 3 files changed, 205 insertions(+), 1

Re: [RFC PATCH v2 3/4] hp: Implement Hazard Pointers

2024-10-05 Thread Mathieu Desnoyers
On 2024-10-04 23:25, Joel Fernandes wrote: On Fri, Oct 4, 2024 at 2:29 PM Mathieu Desnoyers wrote: This API provides existence guarantees of objects through Hazard Pointers (HP). This minimalist implementation is specific to use with preemption disabled, but can be extended further as needed

Re: [RFC PATCH v2 3/4] hp: Implement Hazard Pointers

2024-10-05 Thread Mathieu Desnoyers
On 2024-10-05 13:19, Frederic Weisbecker wrote: Le Fri, Oct 04, 2024 at 02:27:33PM -0400, Mathieu Desnoyers a écrit : +void hp_scan(struct hp_slot __percpu *percpu_slots, void *addr, +void (*retire_cb)(int cpu, struct hp_slot *slot, void *addr)) +{ + int cpu

[RFC PATCH v2 2/4] Documentation: RCU: Refer to ptr_eq()

2024-10-04 Thread Mathieu Desnoyers
Refer to ptr_eq() in the rcu_dereference() documentation. ptr_eq() is a mechanism that preserves address dependencies when comparing pointers, and should be favored when comparing a pointer obtained from rcu_dereference() against another pointer. Signed-off-by: Mathieu Desnoyers Acked-by: Alan

[RFC PATCH v2 4/4] sched+mm: Use hazard pointers to track lazy active mm existence

2024-10-04 Thread Mathieu Desnoyers
: 96 Socket(s):2 Stepping: 1 Frequency boost: enabled CPU(s) scaling MHz: 100% CPU max MHz: 3709. CPU min MHz: 400. BogoMIPS: 4799.75 Memory: 768 GB ram. Signed-off-by: Mathieu Desnoyers Cc: Nicholas

[RFC PATCH v2 3/4] hp: Implement Hazard Pointers

2024-10-04 Thread Mathieu Desnoyers
l.org/lkml/j3scdl5iymjlxavomgc6u5ndg3svhab6ga23dr36o4f5mt333w@7xslvq6b6hmv/ Link: https://lpc.events/event/18/contributions/1731/ Signed-off-by: Mathieu Desnoyers Cc: Nicholas Piggin Cc: Michael Ellerman Cc: Greg Kroah-Hartman Cc: Sebastian Andrzej Siewior Cc: "Paul E. McKenney" Cc: Will Deacon

[RFC PATCH v2 1/4] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-10-04 Thread Mathieu Desnoyers
which depend on @a before loading @a. The same logic applies with @a and @b swapped. Suggested-by: Linus Torvalds Suggested-by: Boqun Feng Signed-off-by: Mathieu Desnoyers Reviewed-by: Boqun Feng Reviewed-by: Joel Fernandes (Google) Tested-by: Joel Fernandes (Google) Acked-by: "P

[RFC PATCH v2 0/4] sched+mm: Track lazy active mm existence with hazard pointers

2024-10-04 Thread Mathieu Desnoyers
0.6% This series applies on top of v6.11.1. Signed-off-by: Mathieu Desnoyers Cc: Linus Torvalds Cc: Andrew Morton Cc: Peter Zijlstra Cc: Nicholas Piggin Cc: Michael Ellerman Cc: Greg Kroah-Hartman Cc: Sebastian Andrzej Siewior Cc: "Paul E. McKenney" Cc: Will Deacon Cc: Alan Stern

Re: [PATCH 1/2] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-10-03 Thread Mathieu Desnoyers
then the compiler can't possibly reverse the asm blocks. Indeed. Thanks, Mathieu David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com

Re: [RFC PATCH 1/4] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-10-03 Thread Mathieu Desnoyers
On 2024-10-03 02:08, Joel Fernandes wrote: On Tue, Oct 01, 2024 at 09:02:02PM -0400, Mathieu Desnoyers wrote: Compiler CSE and SSA GVN optimizations can cause the address dependency of addresses returned by rcu_dereference to be lost when comparing those pointers with either constants or

Re: [RFC PATCH 3/4] hp: Implement Hazard Pointers

2024-10-03 Thread Mathieu Desnoyers
On 2024-10-03 02:24, Boqun Feng wrote: On Tue, Oct 01, 2024 at 09:02:04PM -0400, Mathieu Desnoyers wrote: [...] +/* + * hp_allocate: Allocate a hazard pointer. + * + * Allocate a hazard pointer slot for @addr. The object existence should + * be guaranteed by the caller. + * + * Returns a

Re: [PATCH 1/2] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-10-03 Thread Mathieu Desnoyers
Alan Possibly something like: c = b; OPTIMISER_HIDE_VAR(c); if (a == c) { *b will ensure that there isn't a speculative load from *a. You'll get at least one register-register move - but they are safe. Otherwise you'll need to put the condition inside an asm block. David -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com

Re: [RFC PATCH 0/4] sched+mm: Track lazy active mm existence with hazard pointers

2024-10-02 Thread Mathieu Desnoyers
On 2024-10-02 17:58, Jens Axboe wrote: On 10/2/24 9:53 AM, Mathieu Desnoyers wrote: On 2024-10-02 17:36, Mathieu Desnoyers wrote: On 2024-10-02 17:33, Matthew Wilcox wrote: On Wed, Oct 02, 2024 at 11:26:27AM -0400, Mathieu Desnoyers wrote: On 2024-10-02 16:09, Paul E. McKenney wrote: On Tue

Re: [RFC PATCH 0/4] sched+mm: Track lazy active mm existence with hazard pointers

2024-10-02 Thread Mathieu Desnoyers
On 2024-10-02 17:33, Matthew Wilcox wrote: On Wed, Oct 02, 2024 at 11:26:27AM -0400, Mathieu Desnoyers wrote: On 2024-10-02 16:09, Paul E. McKenney wrote: On Tue, Oct 01, 2024 at 09:02:01PM -0400, Mathieu Desnoyers wrote: Hazard pointers appear to be a good fit for replacing refcount based

Re: [RFC PATCH 0/4] sched+mm: Track lazy active mm existence with hazard pointers

2024-10-02 Thread Mathieu Desnoyers
On 2024-10-02 16:09, Paul E. McKenney wrote: On Tue, Oct 01, 2024 at 09:02:01PM -0400, Mathieu Desnoyers wrote: Hazard pointers appear to be a good fit for replacing refcount based lazy active mm tracking. Highlight: will-it-scale context_switch1_threads nr threads (-t) speedup 24

[RFC PATCH 2/4] Documentation: RCU: Refer to ptr_eq()

2024-10-01 Thread Mathieu Desnoyers
Refer to ptr_eq() in the rcu_dereference() documentation. ptr_eq() is a mechanism that preserves address dependencies when comparing pointers, and should be favored when comparing a pointer obtained from rcu_dereference() against another pointer. Signed-off-by: Mathieu Desnoyers Acked-by: Alan

[RFC PATCH 3/4] hp: Implement Hazard Pointers

2024-10-01 Thread Mathieu Desnoyers
31/ Signed-off-by: Mathieu Desnoyers Cc: Nicholas Piggin Cc: Michael Ellerman Cc: Greg Kroah-Hartman Cc: Sebastian Andrzej Siewior Cc: "Paul E. McKenney" Cc: Will Deacon Cc: Peter Zijlstra Cc: Boqun Feng Cc: Alan Stern Cc: John Stultz Cc: Neeraj Upadhyay Cc: Linus Torvalds C

[RFC PATCH 0/4] sched+mm: Track lazy active mm existence with hazard pointers

2024-10-01 Thread Mathieu Desnoyers
o see what the build bots have to say about this. This series applies on top of v6.11.1. Signed-off-by: Mathieu Desnoyers Cc: Nicholas Piggin Cc: Michael Ellerman Cc: Greg Kroah-Hartman Cc: Sebastian Andrzej Siewior Cc: "Paul E. McKenney" Cc: Will Deacon Cc: Boqun Feng Cc: Alan

[RFC PATCH 4/4] sched+mm: Use hazard pointers to track lazy active mm existence

2024-10-01 Thread Mathieu Desnoyers
: 400. BogoMIPS: 4799.75 Memory: 768 GB ram. Signed-off-by: Mathieu Desnoyers Cc: Nicholas Piggin Cc: Michael Ellerman Cc: Greg Kroah-Hartman Cc: Sebastian Andrzej Siewior Cc: "Paul E. McKenney" Cc: Will Deacon Cc: Peter Zijlstra Cc: Boqun Feng Cc: Alan Stern Cc: J

[RFC PATCH 1/4] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-10-01 Thread Mathieu Desnoyers
which depend on @a before loading @a. The same logic applies with @a and @b swapped. Suggested-by: Linus Torvalds Suggested-by: Boqun Feng Signed-off-by: Mathieu Desnoyers Reviewed-by: Boqun Feng Acked-by: "Paul E. McKenney" Acked-by: Alan Stern Cc: Greg Kroah-Hartman Cc: Sebasti

Re: [PATCH v1 2/2] Documentation: RCU: Refer to ptr_eq()

2024-09-29 Thread Mathieu Desnoyers
On 2024-09-29 17:51, Paul E. McKenney wrote: On Sun, Sep 29, 2024 at 07:16:08AM -0400, Mathieu Desnoyers wrote: Refer to ptr_eq() in the rcu_dereference() documentation. ptr_eq() is a mechanism that preserves address dependencies when comparing pointers, and should be favored when comparing a

[PATCH v1 2/2] Documentation: RCU: Refer to ptr_eq()

2024-09-29 Thread Mathieu Desnoyers
Refer to ptr_eq() in the rcu_dereference() documentation. ptr_eq() is a mechanism that preserves address dependencies when comparing pointers, and should be favored when comparing a pointer obtained from rcu_dereference() against another pointer. Signed-off-by: Mathieu Desnoyers Cc: Greg Kroah

[PATCH v1 1/2] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-09-29 Thread Mathieu Desnoyers
which depend on @a before loading @a. The same logic applies with @a and @b swapped. Suggested-by: Linus Torvalds Suggested-by: Boqun Feng Signed-off-by: Mathieu Desnoyers Reviewed-by: Boqun Feng Acked-by: "Paul E. McKenney" Cc: Greg Kroah-Hartman Cc: Sebastian Andrzej Siewior C

[PATCH v1 0/2] Introduce ptr_eq() to preserve address dependency

2024-09-29 Thread Mathieu Desnoyers
Cc: Mark Rutland Cc: Thomas Gleixner Cc: Vlastimil Babka Cc: maged.mich...@gmail.com Cc: Mateusz Guzik Cc: Gary Guo Cc: Jonas Oberhauser Cc: r...@vger.kernel.org Cc: linux...@kvack.org Cc: l...@lists.linux.dev Cc: Nikita Popov Cc: l...@lists.linux.dev Mathieu Desnoyers (2): compiler.h: Introd

Re: [PATCH 1/2] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-09-29 Thread Mathieu Desnoyers
On 2024-09-29 01:24, Gary Guo wrote: Cc: Nikita Popov Cc: l...@lists.linux.dev On Sat, 28 Sep 2024 09:51:27 -0400 Mathieu Desnoyers wrote: Compiler CSE and SSA GVN optimizations can cause the address dependency of addresses returned by rcu_dereference to be lost when comparing those

Re: [PATCH 1/2] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-09-28 Thread Mathieu Desnoyers
On 2024-09-28 17:49, Alan Stern wrote: On Sat, Sep 28, 2024 at 11:32:18AM -0400, Mathieu Desnoyers wrote: On 2024-09-28 16:49, Alan Stern wrote: On Sat, Sep 28, 2024 at 09:51:27AM -0400, Mathieu Desnoyers wrote: equality, which does not preserve address dependencies and allows the following

Re: [PATCH 1/2] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-09-28 Thread Mathieu Desnoyers
On 2024-09-28 16:49, Alan Stern wrote: On Sat, Sep 28, 2024 at 09:51:27AM -0400, Mathieu Desnoyers wrote: Compiler CSE and SSA GVN optimizations can cause the address dependency of addresses returned by rcu_dereference to be lost when comparing those pointers with either constants or previously

Re: [PATCH 1/2] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-09-28 Thread Mathieu Desnoyers
On 2024-09-28 16:49, Alan Stern wrote: On Sat, Sep 28, 2024 at 09:51:27AM -0400, Mathieu Desnoyers wrote: [...] +/* + * Compare two addresses while preserving the address dependencies for + * later use of the address. It should be used when comparing an address + * returned by rcu_dereference

Re: [PATCH 2/2] Documentation: RCU: Refer to ptr_eq()

2024-09-28 Thread Mathieu Desnoyers
On 2024-09-28 16:58, Alan Stern wrote: On Sat, Sep 28, 2024 at 09:51:28AM -0400, Mathieu Desnoyers wrote: [...] -- Be very careful about comparing pointers obtained from - rcu_dereference() against non-NULL values. As Linus Torvalds - explained, if the two pointers are equal

[PATCH 1/2] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-09-28 Thread Mathieu Desnoyers
d to speculate "ldr w0, [x1]" before "ldr x2, [x0]". Based on the RCU documentation, the control dependency does not prevent the CPU from speculating loads. Suggested-by: Linus Torvalds Suggested-by: Boqun Feng Signed-off-by: Mathieu Desnoyers Reviewed-by: Boqun Feng Acked-

[PATCH 0/2] Introduce ptr_eq() to preserve address dependency

2024-09-28 Thread Mathieu Desnoyers
Cc: Mark Rutland Cc: Thomas Gleixner Cc: Vlastimil Babka Cc: maged.mich...@gmail.com Cc: Mateusz Guzik Cc: Gary Guo Cc: Jonas Oberhauser Cc: r...@vger.kernel.org Cc: linux...@kvack.org Cc: l...@lists.linux.dev Mathieu Desnoyers (2): compiler.h: Introduce ptr_eq() to preserve address

[PATCH 2/2] Documentation: RCU: Refer to ptr_eq()

2024-09-28 Thread Mathieu Desnoyers
Refer to ptr_eq() in the rcu_dereference() documentation. ptr_eq() is a mechanism that preserves address dependencies when comparing pointers, and should be favored when comparing a pointer obtained from rcu_dereference() against another pointer. Signed-off-by: Mathieu Desnoyers Cc: Greg Kroah

Re: [RFC PATCH 1/1] hpref: Hazard Pointers with Reference Counter

2024-09-28 Thread Mathieu Desnoyers
On 2024-09-28 13:22, Jonas Oberhauser wrote: Two more questions below: Am 9/21/2024 um 6:42 PM schrieb Mathieu Desnoyers: +#define NR_PERCPU_SLOTS_BITS    3 Have you measured any advantage of this multi-slot version vs a version with just one normal slot and one emergency slot? No, I have

Re: [RFC PATCH] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-09-27 Thread Mathieu Desnoyers
On 2024-09-27 22:33, Mathieu Desnoyers wrote: [...] --- include/linux/compiler.h | 62 1 file changed, 62 insertions(+) I'm wondering if this really belongs in compiler.h, or if it's so RCU/HP specific that it should be implemented in

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-27 Thread Mathieu Desnoyers
d be discarded by further optimization. I'm unsure what you are trying to achieve here. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com

[RFC PATCH] compiler.h: Introduce ptr_eq() to preserve address dependency

2024-09-27 Thread Mathieu Desnoyers
d to speculate "ldr w0, [x1]" before "ldr x2, [x0]". Based on the RCU documentation, the control dependency does not prevent the CPU from speculating loads. Suggested-by: Linus Torvalds Suggested-by: Boqun Feng Signed-off-by: Mathieu Desnoyers Cc: Greg Kroah-Hartman Cc: Sebastia

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-27 Thread Mathieu Desnoyers
On 2024-09-27 20:13, Linus Torvalds wrote: On Fri, 27 Sept 2024 at 10:53, Mathieu Desnoyers wrote: (b) the value barrier needs to be on *both* values so that the order of the equality testing doesn't matter. If we use OPTIMIZER_HIDE_VAR() on both parameters, it indeed minimizes the

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-27 Thread Mathieu Desnoyers
On 2024-09-27 19:23, Linus Torvalds wrote: On Fri, 27 Sept 2024 at 10:17, Mathieu Desnoyers wrote: The barrier() is ineffective at fixing the issue. It does not prevent the compiler CSE from losing the address dependency: Ok. Thanks for actually specifying code. That needs to be (a) in

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-27 Thread Mathieu Desnoyers
uaranteeing existence of first and second locks in traversal order, allowing them to be locked in the correct order (which is reverse from traversal order) rather than try-lock+retry on nested lock. This can be done with hazard pointers without requiring object reclaim to be delayed by an RCU grace period. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-27 Thread Mathieu Desnoyers
On 2024-09-27 16:43, Mathieu Desnoyers wrote: On 2024-09-27 12:59, Mathieu Desnoyers wrote: On 2024-09-27 06:28, Boqun Feng wrote: [...] I replaced ADDRESS_EQ(a, b) with ADDRESS_EQ(b, a), and the compile result shows it can prevent the issue: I see, yes. It prevents the issue by making the

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-27 Thread Mathieu Desnoyers
On 2024-09-27 12:59, Mathieu Desnoyers wrote: On 2024-09-27 06:28, Boqun Feng wrote: [...] I replaced ADDRESS_EQ(a, b) with ADDRESS_EQ(b, a), and the compile result shows it can prevent the issue: I see, yes. It prevents the issue by making the compiler create a copy of the value "mod

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-27 Thread Mathieu Desnoyers
On 2024-09-27 06:28, Boqun Feng wrote: On Fri, Sep 27, 2024 at 09:37:50AM +0800, Boqun Feng wrote: On Fri, Sep 27, 2024, at 9:30 AM, Mathieu Desnoyers wrote: On 2024-09-27 02:01, Boqun Feng wrote: #define ADDRESS_EQ(var, expr

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-26 Thread Mathieu Desnoyers
x0, x0, :lo12:.LANCHOR0 .L12: ldr x1, [x0] ldr x2, [x0] cmp x1, x2 bne .L12 ldr w0, [x1] ret p: .zero 8 -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-26 Thread Mathieu Desnoyers
] ldrx9, [x8] cmpx10, x9 b.ne 4 // b.any ldrw0, [x9] ret fct_volatile_acquire: adrp x8, 0 addx8, x8, #0x0 ldrx10, [x8] ldar x9, [x8] cmpx10, x9 b.ne 24 // b.any ldrw0, [x9] ret fct_asm_compare: adrp x8, 0 ldrx9, [x8] ldrx8, [x8] cmpx9, x8 b.ne 3c // b.any ldrw0, [x8] ret main: movw0, wzr -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-25 Thread Mathieu Desnoyers
On 2024-09-25 15:20, Mathieu Desnoyers wrote: [...] static inline bool same_ptr(void *a, void *b) {     asm goto (     "cmpq %[a], %[b]\n\t"     "jne %l[ne]\n\t"     : : [a] "r" (a), [b] "r" (b)     : : ne);     return true;

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-25 Thread Mathieu Desnoyers
On 2024-09-25 15:10, Mathieu Desnoyers wrote: [...] Cleaner without goto in the user code: #include #include static inline bool same_ptr(void *a, void *b) { asm goto ( "cmpq %[a], %[b]\n\t" "jne %l[ne]\n\t" : : [a] "r" (a), [b] "

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-25 Thread Mathieu Desnoyers
On 2024-09-25 14:47, Mathieu Desnoyers wrote: [...] Like so: #include #define __str_1(x)  #x #define __str(x)    __str_1(x) /* x86-64 */ #define bne_ptr(_a, _b, _label) \     asm goto ( \     "cmpq %[a], %[b]\n\t" \     "jne %l[" __str(_label) "]\n\t&qu

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-25 Thread Mathieu Desnoyers
On 2024-09-25 14:16, Boqun Feng wrote: On Wed, Sep 25, 2024 at 01:59:06PM +0200, Mathieu Desnoyers wrote: On 2024-09-25 12:45, Boqun Feng wrote: On Wed, Sep 25, 2024 at 12:11:52PM +0200, Jonas Oberhauser wrote: Am 9/25/2024 um 12:02 PM schrieb Boqun Feng: Hi Jonas, Of course, if we are

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-25 Thread Mathieu Desnoyers
an now be speculated, such that it might happen before the rcu_dereference(). This could result in bugs due to misordering. So I am not only concerned about compiler proofs here, as it appears that the speculation done by the CPU can also cause issues on some architectures. Thanks,

Re: [RFC PATCH 1/1] hpref: Hazard Pointers with Reference Counter

2024-09-25 Thread Mathieu Desnoyers
On 2024-09-25 12:06, Jonas Oberhauser wrote: Am 9/25/2024 um 8:35 AM schrieb Mathieu Desnoyers: On 2024-09-25 07:57, Jonas Oberhauser wrote: Hi Mathieu, I haven't read your code in detail but it seems to me you have an ABA bug: as I explained elsewhere, you could read the same po

Re: [RFC PATCH 1/1] hpref: Hazard Pointers with Reference Counter

2024-09-24 Thread Mathieu Desnoyers
ff --git a/src/hpref.c b/src/hpref.c new file mode 100644 index ..f63530f5 --- /dev/null +++ b/src/hpref.c @@ -0,0 +1,78 @@ +// SPDX-FileCopyrightText: 2024 Mathieu Desnoyers +// +// SPDX-License-Identifier: LGPL-2.1-or-later + +/* + * HPREF: Hazard pointers with reference counters +

[RFC PATCH v1 1/1] hpref: Hazard Pointers with Reference Counter

2024-09-22 Thread Mathieu Desnoyers
lore.kernel.org/lkml/j3scdl5iymjlxavomgc6u5ndg3svhab6ga23dr36o4f5mt333w@7xslvq6b6hmv/ Link: https://lpc.events/event/18/contributions/1731/ Signed-off-by: Mathieu Desnoyers Change-Id: I6369064a0e1a1f9632394df31ff41c76905d17e3 Cc: "Paul E. McKenney" Cc: Will Deacon Cc: Peter Zijlstra Cc: Boqun Feng Cc: Alan Ster

Re: [RFC PATCH 1/1] hpref: Hazard Pointers with Reference Counter

2024-09-22 Thread Mathieu Desnoyers
* emergency slot to transition to refcount. +*/ + caa_cpu_relax(); + goto retry; + } -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com

[RFC PATCH 1/1] hpref: Hazard Pointers with Reference Counter

2024-09-21 Thread Mathieu Desnoyers
b6ga23dr36o4f5mt333w@7xslvq6b6hmv/ Link: https://lpc.events/event/18/contributions/1731/ Signed-off-by: Mathieu Desnoyers Change-Id: I6369064a0e1a1f9632394df31ff41c76905d17e3 Cc: "Paul E. McKenney" Cc: Will Deacon Cc: Peter Zijlstra Cc: Boqun Feng Cc: Alan Stern Cc: John Stultz To: Neeraj Up

Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers

2024-09-18 Thread Mathieu Desnoyers
up readers. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com

[PATCH v6 5/5] tracing: Convert sys_enter/exit to faultable tracepoints

2024-08-28 Thread Mathieu Desnoyers
/20231002202531.3160-1-mathieu.desnoy...@efficios.com/ Co-developed-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers Signed-off-by: Michael Jeanson Reviewed-by: Masami Hiramatsu (Google) Cc: Steven Rostedt Cc: Masami Hiramatsu Cc: Peter Zijlstra Cc: Alexei Starovoitov Cc: Yonghong Song Cc: Paul E

[PATCH v6 4/5] tracing/perf: Add support for faultable tracepoints

2024-08-28 Thread Mathieu Desnoyers
. This change does not yet allow perf to take page faults per se within its probe, but allows its existing probes to connect to faultable tracepoints. Link: https://lore.kernel.org/lkml/20231002202531.3160-1-mathieu.desnoy...@efficios.com/ Co-developed-by: Michael Jeanson Signed-off-by: Mathieu

[PATCH v6 3/5] tracing/bpf-trace: Add support for faultable tracepoints

2024-08-28 Thread Mathieu Desnoyers
change does not yet allow bpf to take page faults per se within its probe, but allows its existing probes to connect to faultable tracepoints. Link: https://lore.kernel.org/lkml/20231002202531.3160-1-mathieu.desnoy...@efficios.com/ Co-developed-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers

[PATCH v6 2/5] tracing/ftrace: Add support for faultable tracepoints

2024-08-28 Thread Mathieu Desnoyers
: Michael Jeanson Signed-off-by: Mathieu Desnoyers Reviewed-by: Masami Hiramatsu (Google) Cc: Steven Rostedt Cc: Masami Hiramatsu Cc: Peter Zijlstra Cc: Alexei Starovoitov Cc: Yonghong Song Cc: Paul E. McKenney Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Mark Rutland Cc: Alexander Shishkin

[PATCH v6 1/5] tracing: Introduce faultable tracepoints

2024-08-28 Thread Mathieu Desnoyers
synchronize read-side marshalling of the registered probes with respect to faultable probes unregistration and teardown. Link: https://lore.kernel.org/lkml/20231002202531.3160-1-mathieu.desnoy...@efficios.com/ Co-developed-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers Signed-off-by: Michael

[PATCH v6 0/5] Faultable Tracepoints

2024-08-28 Thread Mathieu Desnoyers
-trace-ker...@vger.kernel.org Mathieu Desnoyers (5): tracing: Introduce faultable tracepoints tracing/ftrace: Add support for faultable tracepoints tracing/bpf-trace: Add support for faultable tracepoints tracing/perf: Add support for faultable tracepoints tracing: Convert sys_enter/exit to

[PATCH v1 1/2] cleanup.h guard: Rename DEFINE_ prefix to DECLARE_

2024-08-28 Thread Mathieu Desnoyers
ARD()" to actually define a guard variable, rename all the guard "DEFINE_" prefix to "DECLARE_". Signed-off-by: Mathieu Desnoyers Cc: Peter Zijlstra (Intel) Cc: Ingo Molnar --- crypto/asymmetric_keys/x509_parser.h | 4 +- drivers/cxl/acpi.c

[PATCH v1 2/2] cleanup.h: Introduce DEFINE_INACTIVE_GUARD and activate_guard

2024-08-28 Thread Mathieu Desnoyers
); [...] if (a) { might_sleep(); activate_guard(preempt_notrace, myguard)(); } [ protected code ] } Signed-off-by: Mathieu Desnoyers Cc: Peter Zijlstra (Intel) Cc: Ingo Molnar Cc: Linus Torvalds Cc: Kees Cook Cc: Greg KH Cc: Sean

[PATCH v1 0/2] cleanup.h: Introduce DEFINE_INACTIVE_GUARD()/activate_guard()

2024-08-28 Thread Mathieu Desnoyers
ldo Carvalho de Melo Cc: Mark Rutland Cc: Alexander Shishkin Cc: Namhyung Kim Cc: b...@vger.kernel.org Cc: Joel Fernandes Cc: linux-trace-ker...@vger.kernel.org Mathieu Desnoyers (2): cleanup.h guard: Rename DEFINE_ prefix to DECLARE_ cleanup.h: Introduce DEFINE_INACTIVE_GUARD and activate_

Re: [PATCH v5 3/8] cleanup.h: Introduce DEFINE_INACTIVE_GUARD and activate_guard

2024-08-28 Thread Mathieu Desnoyers
On 2024-08-20 01:00, Steven Rostedt wrote: On Thu, 27 Jun 2024 11:23:35 -0400 Mathieu Desnoyers wrote: To cover scenarios where the scope of the guard differs from the scope of its activation, introduce DEFINE_INACTIVE_GUARD() and activate_guard(). Here is an example use for a conditionally

Re: [PATCH] tracing: Update MAINTAINERS file

2024-07-15 Thread Mathieu Desnoyers
On 2024-07-15 15:13, Steven Rostedt wrote: On Mon, 15 Jul 2024 15:10:17 -0400 Mathieu Desnoyers wrote: On 2024-07-15 14:47, Steven Rostedt wrote: From: "Steven Rostedt (Google)" Gone but never forgotten. [ Also moved Daniel's name to be consistent with the alphabetical orde

Re: [PATCH] tracing: Update MAINTAINERS file

2024-07-15 Thread Mathieu Desnoyers
e Oliveira S:Maintained F:Documentation/trace/hwlat_detector.rst F:Documentation/trace/osnoise-tracer.rst -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com

Re: [PATCH v23 3/5] tracing: Allow user-space mapping of the ring-buffer

2024-07-02 Thread Mathieu Desnoyers
On 2024-07-02 12:51, Steven Rostedt wrote: On Tue, 2 Jul 2024 11:32:53 -0400 Mathieu Desnoyers wrote: If we use '*' for user events already, perhaps we'd want to consider using the same range for the ring buffer ioctls ? Arguably one is about instrumentation and the other is ab

Re: [PATCH v23 3/5] tracing: Allow user-space mapping of the ring-buffer

2024-07-02 Thread Mathieu Desnoyers
On 2024-07-02 11:18, Steven Rostedt wrote: On Tue, 2 Jul 2024 10:36:03 -0400 Mathieu Desnoyers wrote: I can send a patch this week to update it. Or feel free to send a patch yourself. You need to reserve an unused ioctl Code and Seq# range within: Documentation/userspace-api/ioctl/ioctl

Re: [PATCH v23 3/5] tracing: Allow user-space mapping of the ring-buffer

2024-07-02 Thread Mathieu Desnoyers
ioctl Code and Seq# range within: Documentation/userspace-api/ioctl/ioctl-number.rst Otherwise this duplicate will confuse all system call instrumentation tooling. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com

[PATCH v5 8/8] tracing: Convert sys_enter/exit to faultable tracepoints

2024-06-27 Thread Mathieu Desnoyers
/20231002202531.3160-1-mathieu.desnoy...@efficios.com/ Co-developed-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers Signed-off-by: Michael Jeanson Cc: Steven Rostedt Cc: Masami Hiramatsu Cc: Peter Zijlstra Cc: Alexei Starovoitov Cc: Yonghong Song Cc: Paul E. McKenney Cc: Ingo Molnar Cc: Arnaldo

[PATCH v5 7/8] tracing/perf: Add support for faultable tracepoints

2024-06-27 Thread Mathieu Desnoyers
. This change does not yet allow perf to take page faults per se within its probe, but allows its existing probes to connect to faultable tracepoints. Link: https://lore.kernel.org/lkml/20231002202531.3160-1-mathieu.desnoy...@efficios.com/ Co-developed-by: Michael Jeanson Signed-off-by: Mathieu

[PATCH v5 5/8] tracing/ftrace: Add support for faultable tracepoints

2024-06-27 Thread Mathieu Desnoyers
: Michael Jeanson Signed-off-by: Mathieu Desnoyers Cc: Steven Rostedt Cc: Masami Hiramatsu Cc: Peter Zijlstra Cc: Alexei Starovoitov Cc: Yonghong Song Cc: Paul E. McKenney Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Mark Rutland Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: b

  1   2   3   4   5   6   7   8   9   10   >