Re: [PATCH-block v3 2/2] blk-cgroup: Flush stats at blkgs destruction path

From: Waiman Long
Date: Tue Dec 13 2022 - 21:00:20 EST



On 12/13/22 14:30, Tejun Heo wrote:
On Tue, Dec 13, 2022 at 01:44:46PM -0500, Waiman Long wrote:
+ /*
+ * Flush all the non-empty percpu lockless lists so as to release
+ * the blkg references held by those lists which, in turn, may
+ * allow the blkgs to be freed and release their references to
+ * blkcg speeding up its freeing.
+ */
Can you mention the possible deadlock explicitly? This sounds more like an
optimization.

I am mostly thinking about the optimization aspect. Yes, deadlock in the sense that both blkgs and blkcg remained offline but not freed is possible because of the references hold in those lockless list. It is a problem if blkcg is the only controller in a cgroup. For cgroup that has both the blkcg and memory controllers, it shouldn't be a problem as the cgroup_rstat_flush() call in the release of memory cgroup will clear up blkcg too. Right, I will update the comment to mention that.

Cheers,
Longman