Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2247283ybv; Mon, 24 Feb 2020 01:54:05 -0800 (PST) X-Google-Smtp-Source: APXvYqzI1Z6PZSKp8RCWeJmgxTE7aSQOPUIvegK3HO+2yx7PhWxZ506ObRvJ0oaUclZB+7lBxroZ X-Received: by 2002:a9d:76d2:: with SMTP id p18mr2373585otl.144.1582538045622; Mon, 24 Feb 2020 01:54:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582538045; cv=none; d=google.com; s=arc-20160816; b=RihdFNVS7BbFqs5UyfvyajuXKaexx+0xaOVmiNdg0VcCUa20Lh3lc9Ci4WYQng9ExH elMXuRP8SIMhdMK8WFRxVjlw98Heh58obzKQRf8E7dE6pyqBJhbEOY0jOV9TX7AEZLsK FjJ/70ojJUPBBQoCEe7Np3DPYfAGX/EBfcpk79TzPFfUN1Xmcp38/SsI87IbgZMogrSz hvUPhPI7FlpcWZlKznj8hLwgsaPr3jYuypy8VAyR8WxsjyqwtO98jVs3C3ZGzsg0OxAD tC69tJ72MtbEcW5Hv6h8EYKHb0dnInr/rO++0/Z5Fghm1JBqonV6uwv4h09pplY4B01r 2RxQ== 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=jiO72itPwxbxhaEYDK6XS5ZShwgyAmvRCjYAK+4gaeQ=; b=NkA5FFYarCuKBoYEhp9fPggvFllw0oyJoBvrGqi7wldsAuH/BIW2iaJPb8rxTTZRFf cQ4AmXTQKoO/L5zRK4XBFnpNvVvSkfR7xcNTyURTX5wkNEfzJrJoH5Ul/lcYx/J09OOX MxH+fOGl+wFEIcG5HChFo2MLifaNq1P0oqGpPRClt00+Zs0wXWit0yRtDk47W7zxNUuB 3JjKcUh9KLLzrqxSiT7EdgJ+DF5eUIf3ucIWqVJcQSGchVP7gGzNskqWEoT5T8ngz+Yn 3ixEfGXfbRhd8P67JzCruWwDf+S69fR+VcfqRAN5m51CnfWnJZ5ul0cCWESO6OtI9qeh xw5A== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7si5860442otr.183.2020.02.24.01.53.53; Mon, 24 Feb 2020 01:54:05 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727521AbgBXJxT (ORCPT + 99 others); Mon, 24 Feb 2020 04:53:19 -0500 Received: from outbound-smtp24.blacknight.com ([81.17.249.192]:57908 "EHLO outbound-smtp24.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726838AbgBXJxS (ORCPT ); Mon, 24 Feb 2020 04:53:18 -0500 Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp24.blacknight.com (Postfix) with ESMTPS id 09B79C0C75 for ; Mon, 24 Feb 2020 09:53:16 +0000 (GMT) Received: (qmail 20529 invoked from network); 24 Feb 2020 09:53:15 -0000 Received: from unknown (HELO stampy.112glenside.lan) (mgorman@techsingularity.net@[84.203.18.57]) by 81.17.254.9 with ESMTPA; 24 Feb 2020 09:53:15 -0000 From: Mel Gorman To: Peter Zijlstra Cc: Ingo Molnar , Vincent Guittot , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Valentin Schneider , Phil Auld , Hillf Danton , LKML , Mel Gorman Subject: [PATCH 04/13] sched/fair: Reorder enqueue/dequeue_task_fair path Date: Mon, 24 Feb 2020 09:52:14 +0000 Message-Id: <20200224095223.13361-5-mgorman@techsingularity.net> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200224095223.13361-1-mgorman@techsingularity.net> References: <20200224095223.13361-1-mgorman@techsingularity.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincent Guittot The walk through the cgroup hierarchy during the enqueue/dequeue of a task is split in 2 distinct parts for throttled cfs_rq without any added value but making code less readable. Change the code ordering such that everything related to a cfs_rq (throttled or not) will be done in the same loop. In addition, the same steps ordering is used when updating a cfs_rq: - update_load_avg - update_cfs_group - update *h_nr_running This reordering enables the use of h_nr_running in PELT algorithm. No functional and performance changes are expected and have been noticed during tests. Signed-off-by: Vincent Guittot Reviewed-by: "Dietmar Eggemann " Signed-off-by: Mel Gorman --- kernel/sched/fair.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 6c866fb2129c..4395951b1530 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -5261,32 +5261,31 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) cfs_rq = cfs_rq_of(se); enqueue_entity(cfs_rq, se, flags); - /* - * end evaluation on encountering a throttled cfs_rq - * - * note: in the case of encountering a throttled cfs_rq we will - * post the final h_nr_running increment below. - */ - if (cfs_rq_throttled(cfs_rq)) - break; cfs_rq->h_nr_running++; cfs_rq->idle_h_nr_running += idle_h_nr_running; + /* end evaluation on encountering a throttled cfs_rq */ + if (cfs_rq_throttled(cfs_rq)) + goto enqueue_throttle; + flags = ENQUEUE_WAKEUP; } for_each_sched_entity(se) { cfs_rq = cfs_rq_of(se); - cfs_rq->h_nr_running++; - cfs_rq->idle_h_nr_running += idle_h_nr_running; + /* end evaluation on encountering a throttled cfs_rq */ if (cfs_rq_throttled(cfs_rq)) - break; + goto enqueue_throttle; update_load_avg(cfs_rq, se, UPDATE_TG); update_cfs_group(se); + + cfs_rq->h_nr_running++; + cfs_rq->idle_h_nr_running += idle_h_nr_running; } +enqueue_throttle: if (!se) { add_nr_running(rq, 1); /* @@ -5347,17 +5346,13 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) cfs_rq = cfs_rq_of(se); dequeue_entity(cfs_rq, se, flags); - /* - * end evaluation on encountering a throttled cfs_rq - * - * note: in the case of encountering a throttled cfs_rq we will - * post the final h_nr_running decrement below. - */ - if (cfs_rq_throttled(cfs_rq)) - break; cfs_rq->h_nr_running--; cfs_rq->idle_h_nr_running -= idle_h_nr_running; + /* end evaluation on encountering a throttled cfs_rq */ + if (cfs_rq_throttled(cfs_rq)) + goto dequeue_throttle; + /* Don't dequeue parent if it has other entities besides us */ if (cfs_rq->load.weight) { /* Avoid re-evaluating load for this entity: */ @@ -5375,16 +5370,19 @@ static void dequeue_task_fair(struct rq *rq, struct task_struct *p, int flags) for_each_sched_entity(se) { cfs_rq = cfs_rq_of(se); - cfs_rq->h_nr_running--; - cfs_rq->idle_h_nr_running -= idle_h_nr_running; + /* end evaluation on encountering a throttled cfs_rq */ if (cfs_rq_throttled(cfs_rq)) - break; + goto dequeue_throttle; update_load_avg(cfs_rq, se, UPDATE_TG); update_cfs_group(se); + + cfs_rq->h_nr_running--; + cfs_rq->idle_h_nr_running -= idle_h_nr_running; } +dequeue_throttle: if (!se) sub_nr_running(rq, 1); -- 2.16.4