Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755169AbcKBCgJ (ORCPT ); Tue, 1 Nov 2016 22:36:09 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33368 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752001AbcKBCgH (ORCPT ); Tue, 1 Nov 2016 22:36:07 -0400 Date: Wed, 2 Nov 2016 03:35:52 +0100 From: luca abeni To: Juri Lelli Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Claudio Scordino , Steven Rostedt Subject: Re: [RFC v3 2/6] Improve the tracking of active utilisation Message-ID: <20161102033552.4d41c9ca@utopia> In-Reply-To: <20161101224633.4e5ee0ca@utopia> References: <1477317998-7487-1-git-send-email-luca.abeni@unitn.it> <1477317998-7487-3-git-send-email-luca.abeni@unitn.it> <20161101164604.GB2769@ARMvm> <20161101224633.4e5ee0ca@utopia> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; i686-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1107 Lines: 28 On Tue, 1 Nov 2016 22:46:33 +0100 luca abeni wrote: [...] > > > @@ -1074,6 +1161,14 @@ select_task_rq_dl(struct task_struct *p, int cpu, int sd_flag, int flags) > > > } > > > rcu_read_unlock(); > > > > > > + rq = task_rq(p); > > > + raw_spin_lock(&rq->lock); > > > + if (hrtimer_active(&p->dl.inactive_timer)) { > > > + sub_running_bw(&p->dl, &rq->dl); > > > + hrtimer_try_to_cancel(&p->dl.inactive_timer); > > > > Can't we subtract twice if it happens that after we grabbed rq_lock the timer > > fired, so it's now waiting for that lock and it goes ahead and sub_running_bw > > again after we release the lock? > Uhm... I somehow convinced myself that this could not happen, but I do not > remember the details, sorry :( I think I remember the answer now: pi_lock is acquired before invoking select_task_rq and is released after invoking enqueue_task... So, if there is a pending inactive timer, its handler will be executed after the task is enqueued... It will see the task as RUNNING, and will not decrease the active utilisation. Does this make sense? Luca