Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3741210ybk; Tue, 19 May 2020 11:50:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyC6d25SrGRaImtVvqy1+Jr81EN0LpdRkLEp/sFzaRPg+LRVrnDFhISOvAQz3y7A/TOSM23 X-Received: by 2002:a50:8d57:: with SMTP id t23mr299964edt.168.1589914208404; Tue, 19 May 2020 11:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589914208; cv=none; d=google.com; s=arc-20160816; b=CaJPIlW0FGqQ5qA86s7jY6cn7vCZ7g8J1ij21uBBe8KA2QHlkYK4sCLShomX/hb+6X eRAyshQgRGMp9+zSwXuAgQtgt3dYi/E/MMiRHwPHXg2UnswtDRFFTGW2YILcYGIeWzsM Gxx2z/bwHi8Hejc5XQW3Q3smOlq/fWlt6lGNlQvtPrSNvOJtyegTMApsrtwYujf7hYQ+ MIwjpd9ThAmBwzmtFomDwUa4ozXzZmDl4KsODXKk3old2iCRYxfG4/raGIfDVTRNd6Vt jPTTaX+8dTnoBtwGVu4VjtCEkUtgtj0PV46NbECSKHM1F2tI6L1cSFtR2uvfA0ait0CP P3Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=Y8lm654ASccXTQCIE+P25SYogxTY78MoLcXq4h3LBDs=; b=tbqx9KBi9EiVUfy0yvqLF4OgfSUFbYSNGWZDGMJ5vwLBQ0wqxM7ROvVgSBNuD+Tjjf EZ3d6p76qczb5iIX5NwGDDu4QX/qJhw7lmeILN2T0SHx1/PppdBwlc3G8uyXA1OJkAMg omp04OU2T6vgQ2tZgqyBBzJu+0KdBTrF4zoR/atFjo8SmlwYifd9/kqjsmls71dQA4sx ldDE8uwQE4h66STVKWFq1lyg0TZHboVFHyNOnTa2x9t/Zzz/tnBfxJqEBOdaLAAwJUYu WFndE+VCFZWQ2ReDzV+H6Cip/BD7Xp9HgnObvl9ulCejkUBhn4Q9PReC5gEenO+ew8tC PTSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d13si148991edt.406.2020.05.19.11.49.44; Tue, 19 May 2020 11:50:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728231AbgESSo6 (ORCPT + 99 others); Tue, 19 May 2020 14:44:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727011AbgESSoU (ORCPT ); Tue, 19 May 2020 14:44:20 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25485C08C5C0; Tue, 19 May 2020 11:44:20 -0700 (PDT) Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jb7Dp-0006bk-CM; Tue, 19 May 2020 20:44:13 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 017191C0178; Tue, 19 May 2020 20:44:13 +0200 (CEST) Date: Tue, 19 May 2020 18:44:12 -0000 From: "tip-bot2 for Vincent Guittot" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] sched/fair: Fix unthrottle_cfs_rq() for leaf_cfs_rq list Cc: Vincent Guittot , "Peter Zijlstra (Intel)" , Phil Auld , Ben Segall , x86 , LKML In-Reply-To: <20200513135528.4742-1-vincent.guittot@linaro.org> References: <20200513135528.4742-1-vincent.guittot@linaro.org> MIME-Version: 1.0 Message-ID: <158991385289.17951.3658407082283832789.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/urgent branch of tip: Commit-ID: 39f23ce07b9355d05a64ae303ce20d1c4b92b957 Gitweb: https://git.kernel.org/tip/39f23ce07b9355d05a64ae303ce20d1c4b92b957 Author: Vincent Guittot AuthorDate: Wed, 13 May 2020 15:55:28 +02:00 Committer: Peter Zijlstra CommitterDate: Tue, 19 May 2020 20:34:10 +02:00 sched/fair: Fix unthrottle_cfs_rq() for leaf_cfs_rq list Although not exactly identical, unthrottle_cfs_rq() and enqueue_task_fair() are quite close and follow the same sequence for enqueuing an entity in the cfs hierarchy. Modify unthrottle_cfs_rq() to use the same pattern as enqueue_task_fair(). This fixes a problem already faced with the latter and add an optimization in the last for_each_sched_entity loop. Fixes: fe61468b2cb (sched/fair: Fix enqueue_task_fair warning) Reported-by Tao Zhou Signed-off-by: Vincent Guittot Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Phil Auld Reviewed-by: Ben Segall Link: https://lkml.kernel.org/r/20200513135528.4742-1-vincent.guittot@linaro.org --- kernel/sched/fair.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index c6d57c3..538ba5d 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4774,7 +4774,6 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) struct rq *rq = rq_of(cfs_rq); struct cfs_bandwidth *cfs_b = tg_cfs_bandwidth(cfs_rq->tg); struct sched_entity *se; - int enqueue = 1; long task_delta, idle_task_delta; se = cfs_rq->tg->se[cpu_of(rq)]; @@ -4798,26 +4797,44 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) idle_task_delta = cfs_rq->idle_h_nr_running; for_each_sched_entity(se) { if (se->on_rq) - enqueue = 0; + break; + cfs_rq = cfs_rq_of(se); + enqueue_entity(cfs_rq, se, ENQUEUE_WAKEUP); + cfs_rq->h_nr_running += task_delta; + cfs_rq->idle_h_nr_running += idle_task_delta; + + /* end evaluation on encountering a throttled cfs_rq */ + if (cfs_rq_throttled(cfs_rq)) + goto unthrottle_throttle; + } + + for_each_sched_entity(se) { cfs_rq = cfs_rq_of(se); - if (enqueue) { - enqueue_entity(cfs_rq, se, ENQUEUE_WAKEUP); - } else { - update_load_avg(cfs_rq, se, 0); - se_update_runnable(se); - } + + update_load_avg(cfs_rq, se, UPDATE_TG); + se_update_runnable(se); cfs_rq->h_nr_running += task_delta; cfs_rq->idle_h_nr_running += idle_task_delta; + + /* end evaluation on encountering a throttled cfs_rq */ if (cfs_rq_throttled(cfs_rq)) - break; + goto unthrottle_throttle; + + /* + * One parent has been throttled and cfs_rq removed from the + * list. Add it back to not break the leaf list. + */ + if (throttled_hierarchy(cfs_rq)) + list_add_leaf_cfs_rq(cfs_rq); } - if (!se) - add_nr_running(rq, task_delta); + /* At this point se is NULL and we are at root level*/ + add_nr_running(rq, task_delta); +unthrottle_throttle: /* * The cfs_rq_throttled() breaks in the above iteration can result in * incomplete leaf list maintenance, resulting in triggering the @@ -4826,7 +4843,8 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) for_each_sched_entity(se) { cfs_rq = cfs_rq_of(se); - list_add_leaf_cfs_rq(cfs_rq); + if (list_add_leaf_cfs_rq(cfs_rq)) + break; } assert_list_leaf_cfs_rq(rq);