[Devel] [RFC PATCH vz9 v6 07/62] dm-ploop: convert wait_list and wb_batch_llist to use lockless lists

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Thu Jan 9 08:00:55 MSK 2025



On 12/6/24 05:55, Alexander Atanasov wrote:
> diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
> index a0fe92a592a1..fb49dc7bd7b0 100644
> --- a/drivers/md/dm-ploop-map.c
> +++ b/drivers/md/dm-ploop-map.c
> @@ -382,13 +382,14 @@ static bool ploop_delay_if_md_busy(struct ploop *ploop, struct md_page *md,
>   
>   	WARN_ON_ONCE(!list_empty(&pio->list));
>   
> -	write_lock_irqsave(&ploop->bat_rwlock, flags);
> +	/* lock protects piwb */
> +	read_lock_irqsave(&ploop->bat_rwlock, flags);
>   	piwb = md->piwb;
>   	if (piwb && (piwb->type != type || test_bit(MD_WRITEBACK, &md->status))) {
> -		list_add_tail(&pio->list, &md->wait_list);
> +		llist_add((struct llist_node *)(&pio->list), &md->wait_llist);

Probably we can have:

struct pio {
   union {
     struct list_head list;
     struct llist_node llist;
   };
}

And use llist member where we need lock-less lists and use list where we 
want doubly linked list.

>   		busy = true;
>   	}
> -	write_unlock_irqrestore(&ploop->bat_rwlock, flags);
> +	read_unlock_irqrestore(&ploop->bat_rwlock, flags);
>   
>   	return busy;
>   }

-- 
Best regards, Tikhomirov Pavel
Senior Software Developer, Virtuozzo.



More information about the Devel mailing list