Re: [PATCH v8 03/10] kernfs: Change kernfs_notify_list to llist.
From: Tejun Heo
Date: Fri Apr 22 2022 - 12:41:55 EST
Hello,
On Sun, Apr 10, 2022 at 12:37:12PM +1000, Imran Khan wrote:
> @@ -846,18 +845,25 @@ static void kernfs_notify_workfn(struct work_struct *work)
> struct kernfs_node *kn;
> struct kernfs_super_info *info;
> struct kernfs_root *root;
> + struct llist_node *free;
> + struct kernfs_elem_attr *attr;
> repeat:
> - /* pop one off the notify_list */
> + /**
> + * pop one off the notify_list.
> + * There can be multiple concurrent work items.
> + * Use kernfs_notify_lock to synchronize between multipl consumers.
> + */
This is running off of a single work item, so there can only be one instance
of this running at any given time.
> spin_lock_irq(&kernfs_notify_lock);
> - kn = kernfs_notify_list;
> - if (kn == KERNFS_NOTIFY_EOL) {
> + if (llist_empty(&kernfs_notify_list)) {
> spin_unlock_irq(&kernfs_notify_lock);
> return;
> }
> - kernfs_notify_list = kn->attr.notify_next;
> - kn->attr.notify_next = NULL;
> +
> + free = llist_del_first(&kernfs_notify_list);
Why not just test whether the returned pointer is NULL here instead of doing
a separate empty check above?
Thanks.
--
tejun