[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <09AD613C-97F2-4C60-8267-18E27909779F@gmail.com>
Date: Fri, 20 Sep 2024 03:53:47 +0800
From: Alan Huang <mmpgouride@...il.com>
To: Boqun Feng <boqun.feng@...il.com>
Cc: Lai Jiangshan <jiangshanlai@...il.com>,
LKML <linux-kernel@...r.kernel.org>,
RCU <rcu@...r.kernel.org>,
linux-mm@...ck.org,
lkmm@...ts.linux.dev,
"Paul E. McKenney" <paulmck@...nel.org>,
Frederic Weisbecker <frederic@...nel.org>,
Neeraj Upadhyay <neeraj.upadhyay@...nel.org>,
Joel Fernandes <joel@...lfernandes.org>,
Josh Triplett <josh@...htriplett.org>,
"Uladzislau Rezki (Sony)" <urezki@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Zqiang <qiang.zhang1211@...il.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Will Deacon <will@...nel.org>,
Waiman Long <longman@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Thomas Gleixner <tglx@...utronix.de>,
Kent Overstreet <kent.overstreet@...il.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Vlastimil Babka <vbabka@...e.cz>,
maged.michael@...il.com,
Neeraj upadhyay <neeraj.upadhyay@....com>
Subject: Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard
pointers
2024年9月20日 02:58,Boqun Feng <boqun.feng@...il.com> wrote:
>
> On Thu, Sep 19, 2024 at 09:57:12PM +0800, Alan Huang wrote:
> [...]
>>>
>>> I think you're right. (Although the node will be eventually deleted at
>>> cleanup_hazptr_context(), however there could be a long-live
>>> hazptr_context). It should be:
>>>
>>> hazptr_t val = smp_load_acquire(&hzcp->slots[i]);
>>> struct hazptr_slot_snap *snap = &hzcp->snaps[i];
>>>
>>> if (val != snap->slot) { // val changed, need to update the tree node.
>>> // Already in the tree, need to remove first.
>>> if (!is_null_or_unused(snap->slot)) {
>>> reader_del(tree, snap);
>>> }
>>>
>>> // use the latest snapshot.
>>> snap->slot = val;
>>>
>>> // Add it into tree if there is a reader
>>> if (!is_null_or_unused(val))
>>> reader_add(tree, snap);
>>> }
>>
>> It seems like that two different hazptr_context can’t be used to protect the same pointer?
>>
>> Otherwise the following can happen?
>>
>> thread1 thread2 thread3(worker) thread4
>> hazptr_tryprotect(hzp1, ptr1) hazptr_tryprotect(hzp2, ptr1)
>> add ptr1 to tree
>
> Note that we have snapshot rb_node for each hazard pointer slot, so here
> thread3 actually would add two rb_nodes with ->slot == ptr1 here.
Ok, good to know the rbtree can have multiple nodes with the same key.
Thanks for the explanation!
>
>> hazptr_clear(hzp1)
>> hazptr_tryprotect(hzp1, ptr2)
>> delete ptr1 from tree unpub ptr1
>
> Therefore, there is still one rb_node with ->slot == ptr1 in the tree
> after the deletion, so updaters won't invoke ptr1's callback.
>
> Regards,
> Boqun
>
>> call_hazptr(ptr1)
>> oops: invoke ptr1's callback
>> Or am I missing something?
>>
>>>
>>> Regards,
>>> Boqun
>>>
>>>> I'm not so sure...
>>>>
>>>> Thanks
>>>> Lai
Powered by blists - more mailing lists