Thread (2 messages) 2 messages, 2 authors, 2021-07-06

Re: [PATCH] blk-cgroup: prevent rcu_sched detected stalls warnings while iterating blkgs

From: Tejun Heo <hidden>
Date: 2021-07-06 17:56:36
Also in: linux-block, lkml

Hello, Yu.

On Fri, Jul 02, 2021 at 12:04:44PM +0800, Yu Kuai wrote:
blkcg_activate_policy() and blkcg_deactivate_policy() might have the
same problem, fix them the same way.
Given that these are basically only called from module init/exit paths,
let's leave them alone for now.
+#define BLKG_BATCH_OP_NUM 64
Can we do BLKG_DESTRY_BATCH_SIZE instead?
quoted hunk ↗ jump to hunk
 static void blkg_destroy_all(struct request_queue *q)
 {
 	struct blkcg_gq *blkg, *n;
+	int count = BLKG_BATCH_OP_NUM;
 
+restart:
 	spin_lock_irq(&q->queue_lock);
 	list_for_each_entry_safe(blkg, n, &q->blkg_list, q_node) {
 		struct blkcg *blkcg = blkg->blkcg;
@@ -430,6 +434,17 @@ static void blkg_destroy_all(struct request_queue *q)
 		spin_lock(&blkcg->lock);
 		blkg_destroy(blkg);
 		spin_unlock(&blkcg->lock);
+
+		/*
+		 * in order to avoid holding the spin lock for too long, release
+		 * it when a batch of blkgs are destroyed.
+		 */
+		if (!(--count)) {
+			count = BLKG_BATCH_OP_NUM;
+			spin_unlock_irq(&q->queue_lock);
+			cond_resched();
+			goto restart;
+		}
 	}
This part looks good otherwise.

Thanks.

-- 
tejun
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help