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

2024-09-28 Thread Jonas Oberhauser
Thanks for your response, Am 9/28/2024 um 1:33 PM schrieb Mathieu Desnoyers: This is a userspace prototype. This will behave similarly to a userspace spinlock in that case, which is not great in terms of CPU usage, but should eventually unblock the waiter, unless it has a RT priority that reall

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 1/1] hpref: Hazard Pointers with Reference Counter

2024-09-28 Thread Jonas Oberhauser
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? With just one normal slot, the normal slot version would alw

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

2024-09-25 Thread Jonas Oberhauser
Am 9/25/2024 um 1:36 PM schrieb 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 ex

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 pointer afte

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

2024-09-25 Thread Jonas Oberhauser
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 pointer after ABA but you don't synchronize with the new

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

2024-09-24 Thread Mathieu Desnoyers
On 2024-09-25 07:57, Jonas Oberhauser wrote: Hi Mathieu, interesting idea. Conceptually it looks good. There's another approach of using hazard pointer to optimize shared reference counting (to make it lock-free in common cases). https://github.com/cmuparlay/concurrent_deferred_rc It doesn'

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

2024-09-24 Thread Jonas Oberhauser
Hi Mathieu, interesting idea. Conceptually it looks good. There's another approach of using hazard pointer to optimize shared reference counting (to make it lock-free in common cases). https://github.com/cmuparlay/concurrent_deferred_rc It doesn't go as far as what you're doing, but they als

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

2024-09-22 Thread Mathieu Desnoyers
On 2024-09-21 23:07, Lai Jiangshan wrote: +/* + * hpref_hp_get: Obtain a reference to a stable object, protected either + * by hazard pointer (fast-path) or using reference + * counter as fall-back. + */ +static inline +bool hpref_hp_get(struct hpref_node **node_p, str

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

2024-09-21 Thread Lai Jiangshan
> +/* > + * hpref_hp_get: Obtain a reference to a stable object, protected either > + * by hazard pointer (fast-path) or using reference > + * counter as fall-back. > + */ > +static inline > +bool hpref_hp_get(struct hpref_node **node_p, struct hpref_ctx *ctx) > +{ > +

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

2024-09-21 Thread Mathieu Desnoyers
Boqun Feng's patch series and LPC talk gave me a few ideas I wanted to try. I figured we could improve the concept of reference counters by adding a hazard-pointer protected fast-path to them. This API combines hazard pointers and reference counters. It uses hazard pointers as fast-paths, and fall