Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11166340ybi; Thu, 25 Jul 2019 11:07:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4wK6cfzmTBc0xq9QIrb3/Epn1pBHKPfhQGnSIlM0TIJ6RROVO5qaH3Bpfbs7jyAPIlu8O X-Received: by 2002:a63:2c8:: with SMTP id 191mr86177805pgc.139.1564078078867; Thu, 25 Jul 2019 11:07:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564078078; cv=none; d=google.com; s=arc-20160816; b=jL9KSk2x1kurivAIyRw9OShLx6THjYbkeSfh+3ouizD7IbUj86Cdf3vdQ9eKtwdXOa SdLUGiL+YXoVDe4XmmftKO/q9bf5TuBXyTuYkiPO7Z9YWoOMdQyY94Gh8wpLYD3IM9NJ WHtXW9/+F8PnTkKqguh77Ok1ESsbMYiyQZ4cYuchVK1pPo6rDvdhB6O7bWLn0rSYC1Kk gcMRd4l9pg/KpdxOWSpwh1GXtIYJWnC6xu8kD/ZKqsJobX8QaBLOavqBT51q0t2GChn1 VRIHGsnlOPa7EvXwn0vcPxLpxwGcTyfTl5t9AuE3vYVmXtobHnNv3Y2jaeUoBDWNiI4G 3xPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=QXOXO9wq4aev/cbpwXbEdrVvuV4twTGcbRXaVH2AxoU=; b=c76LTj791qudO7TIn1SBaIWKU6W0+FSJzqWoXS2LjwItVpVEgOyKVtsq/Ke7k/Jfwu HmHzekinWEKdgkO/3EKkJ60GC0mrXE2TKwMb++08GVns6sRWQzeE60iGZ6cKuf8Chwiq 7cD8ZoL2MN744Y215ASWBAY6RSKqpzRKgvAhV2GYFelMWYZMBbqKevz7oJ226y2GbhFU 0J6/xAIMhqGF05xbjzEatMSEUUy4WbzLjsIkHUJvR7UlEpaN1Yruzdt80PH3TvT9ibDY WrRV5LxiTp1p4HPsA9ZramqINKnj365pKiUmou1BtRgwEaiRNGmFwdlEvdu7iY0UCZ81 fUQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019071901 header.b=BLnRdG+l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2si15972045pls.391.2019.07.25.11.07.43; Thu, 25 Jul 2019 11:07:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@zytor.com header.s=2019071901 header.b=BLnRdG+l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390373AbfGYQWZ (ORCPT + 99 others); Thu, 25 Jul 2019 12:22:25 -0400 Received: from terminus.zytor.com ([198.137.202.136]:34375 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388971AbfGYQWY (ORCPT ); Thu, 25 Jul 2019 12:22:24 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x6PGLxI01076400 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 25 Jul 2019 09:21:59 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x6PGLxI01076400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019071901; t=1564071719; bh=QXOXO9wq4aev/cbpwXbEdrVvuV4twTGcbRXaVH2AxoU=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=BLnRdG+ljfNmUt1LU427KJWCAwUEPuWWOY+7SapLihk2V4VKgkfKvCX8RM4feWfBG lailTTW8LquR4mXg62u4E3pu8hs+lCqa/5vXQOUufSaMYa6aHTd0834NRu2NmDy9dm muEFMB/9GM/ReZPiCZhoSKGCUjWu78NJqIvV3nxNV+UVGAQwC2eGY+Ir1v/MoLk4JY GhZ1kiVFSPmqARJPdhMtMUCoPyo9xdcI+FGnb749R2vFGwdUQKcD1gA6BQm515LwGq MO2mVxOW/zq5e0jgft3cc/HH3X5UMAFJFqkRG9DH4qSHwNMBKHwpiXv3YATME5dOwH FNFHZpglr10uw== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x6PGLw7l1076397; Thu, 25 Jul 2019 09:21:58 -0700 Date: Thu, 25 Jul 2019 09:21:58 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Juri Lelli Message-ID: Cc: linux-kernel@vger.kernel.org, mingo@kernel.org, juri.lelli@redhat.com, peterz@infradead.org, torvalds@linux-foundation.org, dietmar.eggemann@arm.com, tglx@linutronix.de, hpa@zytor.com Reply-To: tglx@linutronix.de, dietmar.eggemann@arm.com, hpa@zytor.com, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, peterz@infradead.org, juri.lelli@redhat.com, mingo@kernel.org In-Reply-To: <20190719140000.31694-5-juri.lelli@redhat.com> References: <20190719140000.31694-5-juri.lelli@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched/deadline: Fix bandwidth accounting at all levels after offline migration Git-Commit-ID: 59d06cea1198d665ba11f7e8c5f45b00ff2e4812 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.3 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_96_Q,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 59d06cea1198d665ba11f7e8c5f45b00ff2e4812 Gitweb: https://git.kernel.org/tip/59d06cea1198d665ba11f7e8c5f45b00ff2e4812 Author: Juri Lelli AuthorDate: Fri, 19 Jul 2019 15:59:56 +0200 Committer: Ingo Molnar CommitDate: Thu, 25 Jul 2019 15:55:02 +0200 sched/deadline: Fix bandwidth accounting at all levels after offline migration If a task happens to be throttled while the CPU it was running on gets hotplugged off, the bandwidth associated with the task is not correctly migrated with it when the replenishment timer fires (offline_migration). Fix things up, for this_bw, running_bw and total_bw, when replenishment timer fires and task is migrated (dl_task_offline_migration()). Tested-by: Dietmar Eggemann Signed-off-by: Juri Lelli Signed-off-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: bristot@redhat.com Cc: claudio@evidence.eu.com Cc: lizefan@huawei.com Cc: longman@redhat.com Cc: luca.abeni@santannapisa.it Cc: mathieu.poirier@linaro.org Cc: rostedt@goodmis.org Cc: tj@kernel.org Cc: tommaso.cucinotta@santannapisa.it Link: https://lkml.kernel.org/r/20190719140000.31694-5-juri.lelli@redhat.com Signed-off-by: Ingo Molnar --- kernel/sched/deadline.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 0f9d2180be23..039dde2b1dac 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c @@ -529,6 +529,7 @@ static struct rq *find_lock_later_rq(struct task_struct *task, struct rq *rq); static struct rq *dl_task_offline_migration(struct rq *rq, struct task_struct *p) { struct rq *later_rq = NULL; + struct dl_bw *dl_b; later_rq = find_lock_later_rq(p, rq); if (!later_rq) { @@ -557,6 +558,38 @@ static struct rq *dl_task_offline_migration(struct rq *rq, struct task_struct *p double_lock_balance(rq, later_rq); } + if (p->dl.dl_non_contending || p->dl.dl_throttled) { + /* + * Inactive timer is armed (or callback is running, but + * waiting for us to release rq locks). In any case, when it + * will fire (or continue), it will see running_bw of this + * task migrated to later_rq (and correctly handle it). + */ + sub_running_bw(&p->dl, &rq->dl); + sub_rq_bw(&p->dl, &rq->dl); + + add_rq_bw(&p->dl, &later_rq->dl); + add_running_bw(&p->dl, &later_rq->dl); + } else { + sub_rq_bw(&p->dl, &rq->dl); + add_rq_bw(&p->dl, &later_rq->dl); + } + + /* + * And we finally need to fixup root_domain(s) bandwidth accounting, + * since p is still hanging out in the old (now moved to default) root + * domain. + */ + dl_b = &rq->rd->dl_bw; + raw_spin_lock(&dl_b->lock); + __dl_sub(dl_b, p->dl.dl_bw, cpumask_weight(rq->rd->span)); + raw_spin_unlock(&dl_b->lock); + + dl_b = &later_rq->rd->dl_bw; + raw_spin_lock(&dl_b->lock); + __dl_add(dl_b, p->dl.dl_bw, cpumask_weight(later_rq->rd->span)); + raw_spin_unlock(&dl_b->lock); + set_task_cpu(p, later_rq->cpu); double_unlock_balance(later_rq, rq);