public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blk-cgroup: add spin_lock for u64_stats_update
@ 2024-07-05  7:55 boy.wu
  2024-07-05 17:05 ` Markus Elfring
  2024-07-05 17:13 ` [PATCH] " Tejun Heo
  0 siblings, 2 replies; 8+ messages in thread
From: boy.wu @ 2024-07-05  7:55 UTC (permalink / raw)
  To: Tejun Heo, Josef Bacik, Jens Axboe
  Cc: Matthias Brugger, AngeloGioacchino Del Regno, Boris Burkov,
	cgroups, linux-block, linux-kernel, linux-arm-kernel,
	linux-mediatek, iverlin.wang, Boy Wu

From: Boy Wu <boy.wu@mediatek.com>

In 32bit SMP systems, if the system is stressed on the sys node
by processes, it may cause blkcg_fill_root_iostats to have a concurrent
problem on the seqlock in u64_stats_update, which will cause a deadlock 
on u64_stats_fetch_begin in blkcg_print_one_stat.

To prevent this problem, add spin_locks.

Fixes: ef45fe470e1e ("blk-cgroup: show global disk stats in root cgroup io.stat")
Signed-off-by: Boy Wu <boy.wu@mediatek.com>
---
 block/blk-cgroup.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 37e6cc91d576..a633b7431e91 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1134,9 +1134,15 @@ static void blkcg_fill_root_iostats(void)
 				cpu_dkstats->sectors[STAT_DISCARD] << 9;
 		}
 
+#if BITS_PER_LONG == 32
+		spin_lock_irq(&blkg->q->queue_lock);
+#endif
 		flags = u64_stats_update_begin_irqsave(&blkg->iostat.sync);
 		blkg_iostat_set(&blkg->iostat.cur, &tmp);
 		u64_stats_update_end_irqrestore(&blkg->iostat.sync, flags);
+#if BITS_PER_LONG == 32
+		spin_unlock_irq(&blkg->q->queue_lock);
+#endif
 	}
 }
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-07-10  6:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-05  7:55 [PATCH] blk-cgroup: add spin_lock for u64_stats_update boy.wu
2024-07-05 17:05 ` Markus Elfring
2024-07-08  2:52   ` Boy Wu (吳勃誼)
2024-07-08  5:43     ` Markus Elfring
2024-07-10  6:19       ` Boy Wu (吳勃誼)
2024-07-05 17:13 ` [PATCH] " Tejun Heo
2024-07-08  2:00   ` Boy Wu (吳勃誼)
2024-07-08 18:36     ` tj

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox