All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] blk-iolatency related ref counting fixes
@ 2018-07-31 16:39 Josef Bacik
  2018-07-31 16:39 ` [PATCH 1/3] blk-iolatency: fix blkg leak in timer_fn Josef Bacik
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Josef Bacik @ 2018-07-31 16:39 UTC (permalink / raw)
  To: axboe, linux-block, kernel-team

These are three ref counting issues we found in testing.  They are pretty
straightforward, the first two don't really happen in practice but need to be
fixed, but the last one fixes a real panic we saw pretty regularly in our stress
testing.  They've been running on our test boxes internally under stress tests
and seem to have fixed the remaining issues we were seeing.  Thanks,

Josef

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

* [PATCH 1/3] blk-iolatency: fix blkg leak in timer_fn
  2018-07-31 16:39 [PATCH 0/3] blk-iolatency related ref counting fixes Josef Bacik
@ 2018-07-31 16:39 ` Josef Bacik
  2018-07-31 16:39 ` [PATCH 2/3] blk-cgroup: hold the queue ref during throttling Josef Bacik
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Josef Bacik @ 2018-07-31 16:39 UTC (permalink / raw)
  To: axboe, linux-block, kernel-team

At this point we have a ref on the blkg, we need to drop it if we don't
have a iolat.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 block/blk-iolatency.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c
index bb59b2929e0d..b0dc4fc64b3e 100644
--- a/block/blk-iolatency.c
+++ b/block/blk-iolatency.c
@@ -627,7 +627,7 @@ static void blkiolatency_timer_fn(struct timer_list *t)
 
 		iolat = blkg_to_lat(blkg);
 		if (!iolat)
-			continue;
+			goto next;
 
 		lat_info = &iolat->child_lat;
 		cookie = atomic_read(&lat_info->scale_cookie);
-- 
2.14.3

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

* [PATCH 2/3] blk-cgroup: hold the queue ref during throttling
  2018-07-31 16:39 [PATCH 0/3] blk-iolatency related ref counting fixes Josef Bacik
  2018-07-31 16:39 ` [PATCH 1/3] blk-iolatency: fix blkg leak in timer_fn Josef Bacik
@ 2018-07-31 16:39 ` Josef Bacik
  2018-07-31 16:39 ` [PATCH 3/3] blk-cgroup: clear the throttle queue on fork Josef Bacik
  2018-08-01 15:16 ` [PATCH 0/3] blk-iolatency related ref counting fixes Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Josef Bacik @ 2018-07-31 16:39 UTC (permalink / raw)
  To: axboe, linux-block, kernel-team

The blkg lifetime is protected by the queue lifetime, so we need to put
the queue _after_ we're done using the blkg.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 block/blk-cgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 1942357d7165..694595b29b8f 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1759,10 +1759,10 @@ void blkcg_maybe_throttle_current(void)
 	if (!blkg)
 		goto out;
 	rcu_read_unlock();
-	blk_put_queue(q);
 
 	blkcg_maybe_throttle_blkg(blkg, use_memdelay);
 	blkg_put(blkg);
+	blk_put_queue(q);
 	return;
 out:
 	rcu_read_unlock();
-- 
2.14.3

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

* [PATCH 3/3] blk-cgroup: clear the throttle queue on fork
  2018-07-31 16:39 [PATCH 0/3] blk-iolatency related ref counting fixes Josef Bacik
  2018-07-31 16:39 ` [PATCH 1/3] blk-iolatency: fix blkg leak in timer_fn Josef Bacik
  2018-07-31 16:39 ` [PATCH 2/3] blk-cgroup: hold the queue ref during throttling Josef Bacik
@ 2018-07-31 16:39 ` Josef Bacik
  2018-08-01 15:16 ` [PATCH 0/3] blk-iolatency related ref counting fixes Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Josef Bacik @ 2018-07-31 16:39 UTC (permalink / raw)
  To: axboe, linux-block, kernel-team

We were hitting a panic in production where we put too many times on the
request queue.  This is because we'd get the throttle_queue of the
parent if we fork()'ed while we needed to be throttled, but we didn't
have a reference on it.  Instead just clear these flags on fork so the
child doesn't pay for the sins of its father.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 kernel/fork.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/fork.c b/kernel/fork.c
index 9440d61b925c..694ae0e56866 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -843,6 +843,11 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
 	tsk->fail_nth = 0;
 #endif
 
+#ifdef CONFIG_BLK_CGROUP
+	tsk->throttle_queue = NULL;
+	tsk->use_memdelay = 0;
+#endif
+
 	return tsk;
 
 free_stack:
-- 
2.14.3

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

* Re: [PATCH 0/3] blk-iolatency related ref counting fixes
  2018-07-31 16:39 [PATCH 0/3] blk-iolatency related ref counting fixes Josef Bacik
                   ` (2 preceding siblings ...)
  2018-07-31 16:39 ` [PATCH 3/3] blk-cgroup: clear the throttle queue on fork Josef Bacik
@ 2018-08-01 15:16 ` Jens Axboe
  3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2018-08-01 15:16 UTC (permalink / raw)
  To: Josef Bacik, linux-block, kernel-team

On 7/31/18 10:39 AM, Josef Bacik wrote:
> These are three ref counting issues we found in testing.  They are pretty
> straightforward, the first two don't really happen in practice but need to be
> fixed, but the last one fixes a real panic we saw pretty regularly in our stress
> testing.  They've been running on our test boxes internally under stress tests
> and seem to have fixed the remaining issues we were seeing.  Thanks,

Applied for 4.19, thanks.

-- 
Jens Axboe

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

end of thread, other threads:[~2018-08-01 15:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-31 16:39 [PATCH 0/3] blk-iolatency related ref counting fixes Josef Bacik
2018-07-31 16:39 ` [PATCH 1/3] blk-iolatency: fix blkg leak in timer_fn Josef Bacik
2018-07-31 16:39 ` [PATCH 2/3] blk-cgroup: hold the queue ref during throttling Josef Bacik
2018-07-31 16:39 ` [PATCH 3/3] blk-cgroup: clear the throttle queue on fork Josef Bacik
2018-08-01 15:16 ` [PATCH 0/3] blk-iolatency related ref counting fixes Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.