Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753934AbaESLiJ (ORCPT ); Mon, 19 May 2014 07:38:09 -0400 Received: from forward-corp1g.mail.yandex.net ([95.108.253.251]:36464 "EHLO forward-corp1g.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751499AbaESLiH (ORCPT ); Mon, 19 May 2014 07:38:07 -0400 X-Yandex-Uniq: f891b630-7032-40a7-9ab1-18ebcf52a7d5 Authentication-Results: smtpcorp4.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Date: Mon, 19 May 2014 15:37:58 +0400 Message-ID: <87vbt29ey1.wl%klamm@yandex-team.ru> From: Roman Gushchin To: Peter Zijlstra Cc: Roman Gushchin , bsegall@google.com, linux-kernel@vger.kernel.org, pjt@google.com, chris.j.arges@canonical.com, gregkh@linuxfoundation.org Subject: Re: [PATCH] sched: tg_set_cfs_bandwidth() causes rq->lock deadlock In-Reply-To: <20140519103247.GX30445@twins.programming.kicks-ass.net> References: <87mwej0yja.wl%klamm@yandex-team.ru> <87lhu215ky.wl%klamm@yandex-team.ru> <20140519103247.GX30445@twins.programming.kicks-ass.net> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.8 EasyPG/1.0.0 Emacs/24.3 (x86_64-redhat-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At Mon, 19 May 2014 12:32:47 +0200, Peter Zijlstra wrote: > > OK, so can someone explain this ->timer_active thing? esp. what's the > 'obvious' difference with hrtimer_active()? A good question :) > Ideally we'd change the lot to not have this, but if we have to keep it > we'll need to make it lockdep visible because all this stinks If the patch below is what Ben means, timer_active will become even more unused. It seems to me now, that it will be perfectly possible to just drop it. I'll try to prepare a patch for. -- index 7570dd9..be7865e 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3408,7 +3408,6 @@ static int do_sched_cfs_period_timer(struct cfs_bandwidth *cfs_b, int overrun) u64 runtime, runtime_expires; int idle = 1, throttled; - raw_spin_lock(&cfs_b->lock); /* no need to continue the timer with no bandwidth constraint */ if (cfs_b->quota == RUNTIME_INF) goto out_unlock; @@ -3477,7 +3476,6 @@ static int do_sched_cfs_period_timer(struct cfs_bandwidth *cfs_b, int overrun) out_unlock: if (idle) cfs_b->timer_active = 0; - raw_spin_unlock(&cfs_b->lock); return idle; } @@ -3656,6 +3654,8 @@ static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer) int overrun; int idle = 0; + raw_spin_lock(&cfs_b->lock); + for (;;) { now = hrtimer_cb_get_time(timer); overrun = hrtimer_forward(timer, now, cfs_b->period); @@ -3666,6 +3666,8 @@ static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer) idle = do_sched_cfs_period_timer(cfs_b, overrun); } + raw_spin_unlock(&cfs_b->lock); + return idle ? HRTIMER_NORESTART : HRTIMER_RESTART; }