Re: [PATCH v7 1/3] llist: Add a lock-less list variant terminated by a sentinel node

From: Waiman Long
Date: Mon Oct 03 2022 - 13:34:00 EST


On 10/3/22 12:57, Tejun Heo wrote:
On Mon, Oct 03, 2022 at 12:55:24PM -0400, Waiman Long wrote:
That was my original plan. However, after looking at some existing users of
lockless list, they have coded in the dependency on the fact that a lockless
list is empty if it is NULL. I guess I can make this true also for the new
lockless list with sentinel at the expense of a bit more overhead in the
entry insertion path and deletion path. I will take a further look at that.
There aren't that many users of llist. Maybe it'd be easier / cleaner to
introduce a macro to test whether a llist is empty and replace the NULL
tests?

What my current thinking is to make llist works with both NULL and sentinel terminated lockless list. Users who wish to use the sentinel terminated version will have to use special sentinel version of LLIST_HEAD() macro and llist_del_all() and __llist_del_all() functions. In this way, I don't need to touch an existing users of llist while minimizing code redundancy. What do you think?

Cheers,
Longman