Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3666848ybi; Fri, 19 Jul 2019 07:03:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqykQvWeW22iJVMqUPEVuWgU6elQ7h8gw8j8sbbsmyLHXKTdrSkeD+2ybGKeW6Ud88WUvTNW X-Received: by 2002:a17:90a:3463:: with SMTP id o90mr59322767pjb.15.1563545025930; Fri, 19 Jul 2019 07:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563545025; cv=none; d=google.com; s=arc-20160816; b=vJx2FbOvvvY8UIc63H+I0Ty6LKOjemMkXv4PL9zdtk4MvBs4que5DHPE4LYqsFCiqI 6tgAufxBEhL6YK59WdJk550aK+ECQZVNkl5SR75YfGLBPgptCSeluiJsOkSQAv494ohv cThpiR4EKfgGA/85e1XSgZlbFkMC5qqfBPjwyPxzVTjlzaef0J4a/zEioGFiziM4TOvY 1/x2+8uBAq6tsKJkci6QfIuFngwHDzRUKBuJIENfW3fh2P2Okf43grvchPbiht47Hp3V akN1jAuaBVJ42Ut7x0N798bxcybzU4dEYoDDfMecdVLa9URGEqyG9kjZQjbtwF5J1dGW 0Ygw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=VKh5F3gMwRtIY8LwPbQ4AcnY8aG7rL1fZSwNVcviJak=; b=ei7DUuVUFYj+w6Mgas1ERllCxjuJnEWEh8o39sGaxpD1oyiJBtul6EXKd9nbBGewn4 00d5UKYauuHexEw/ZdTLfxPouwKmn32Cp7fIkTULUwlyATyNfI5cJB0R7+G1kT8DpPz3 71MoFOYwE6C1J+6gX2cQIp/GA9wMBpVj6Z3aFCxO1pD1Nv5ELFZ5mSg50Z9aWilw0Kkf tNLFC3h8bSb4tUpnsxDGoCK9avk8eiV2Do5sSVNulZjuGvCinqN3N2K9HiuW/mef7vxR nHa5k91DEoAXM+zm/dbaPeiTn/Wb1KutBcqgf45ZibSggrNNJw3aqWCEL1XjjOvny1QP dpMw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x22si2172997pln.150.2019.07.19.07.03.29; Fri, 19 Jul 2019 07:03:45 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729573AbfGSOAg (ORCPT + 99 others); Fri, 19 Jul 2019 10:00:36 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51273 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729509AbfGSOAd (ORCPT ); Fri, 19 Jul 2019 10:00:33 -0400 Received: by mail-wm1-f66.google.com with SMTP id 207so28930482wma.1 for ; Fri, 19 Jul 2019 07:00:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VKh5F3gMwRtIY8LwPbQ4AcnY8aG7rL1fZSwNVcviJak=; b=Ao7HT2lbeBOsNwUMUwo+PYzmGpnVu0gId3gdnZiNsY+GuTC+ZBju+ZL8MI8C8KvSy0 Xa8M1xzA8MCA/1BlhAou7xykqrQW1HNiRLnpnghoJBK8bu0dXTiRapgy2lU7E/ftGj9Q PMsMgbaLAEnprjewOxMMxDoh5zGn3Q/lApgssTwFiOXnaJMWj3vkrM0SUcTBNZzajJzS jiNw6zXv/CkyW5ScuIjitlT7ROftmoyhjiZaAHNt1u1DuYyhI4DGPwXmHt5w+rgPphxD 7ny2jheWJBAgpux3+uoUKkVL2wV77Z1C4W6QWdZTtA9M9aIr947ahdwbg9JoYisnKhEA 8p3g== X-Gm-Message-State: APjAAAWu6hukbf5GtDFVOn1hov/NyDE5cuw9TWXa/oaSEL+gb3Ox/P45 KTFwGrwsZce0b2RqSwPEiWNKhg== X-Received: by 2002:a1c:7c08:: with SMTP id x8mr48579844wmc.19.1563544831694; Fri, 19 Jul 2019 07:00:31 -0700 (PDT) Received: from localhost.localdomain.com ([151.15.230.231]) by smtp.gmail.com with ESMTPSA id f10sm21276926wrs.22.2019.07.19.07.00.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jul 2019 07:00:30 -0700 (PDT) From: Juri Lelli To: peterz@infradead.org, mingo@redhat.com, rostedt@goodmis.org, tj@kernel.org Cc: linux-kernel@vger.kernel.org, luca.abeni@santannapisa.it, claudio@evidence.eu.com, tommaso.cucinotta@santannapisa.it, bristot@redhat.com, mathieu.poirier@linaro.org, lizefan@huawei.com, longman@redhat.com, dietmar.eggemann@arm.com, cgroups@vger.kernel.org, Juri Lelli Subject: [PATCH v9 4/8] sched/deadline: Fix bandwidth accounting at all levels after offline migration Date: Fri, 19 Jul 2019 15:59:56 +0200 Message-Id: <20190719140000.31694-5-juri.lelli@redhat.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190719140000.31694-1-juri.lelli@redhat.com> References: <20190719140000.31694-1-juri.lelli@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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()). Signed-off-by: Juri Lelli --- kernel/sched/deadline.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index 4cedcf8d6b03..f0166ab8c6b4 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 file (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); -- 2.17.2