Re: [PATCH net-next 3/7] rxrpc: Fix locking issue

From: Jakub Kicinski
Date: Fri May 20 2022 - 21:11:28 EST


On Fri, 20 May 2022 17:46:13 +0100 David Howells wrote:
> +struct list_head *seq_list_start_rcu(struct list_head *head, loff_t pos)
> +{
> + struct list_head *lh;
> +
> + list_for_each_rcu(lh, head)
> + if (pos-- == 0)
> + return lh;
> +
> + return NULL;
> +}
> +EXPORT_SYMBOL(seq_list_start_rcu);
> +
> +struct list_head *seq_list_start_head_rcu(struct list_head *head, loff_t pos)
> +{
> + if (!pos)
> + return head;
> +
> + return seq_list_start_rcu(head, pos - 1);
> +}
> +EXPORT_SYMBOL(seq_list_start_head_rcu);
> +
> +struct list_head *seq_list_next_rcu(void *v, struct list_head *head,
> + loff_t *ppos)
> +{
> + struct list_head *lh;
> +
> + lh = rcu_dereference(((struct list_head *)v)->next);

Can we use list_next_rcu() here maybe ? to avoid the sparse warning?

> + ++*ppos;
> + return lh == head ? NULL : lh;
> +}
> +EXPORT_SYMBOL(seq_list_next_rcu);