Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7346762ybi; Mon, 22 Jul 2019 11:25:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqzaCksYIuF+QKf4YLoxcthzBHrG8SaC0TAefONk5CaRLQr+/monE7KuA4Pg16rqBW7Dc3pi X-Received: by 2002:a62:be04:: with SMTP id l4mr1480423pff.77.1563819932054; Mon, 22 Jul 2019 11:25:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563819932; cv=none; d=google.com; s=arc-20160816; b=u6i7xdqtgCbGUvWGtvjU/Vl+DueZbAaGa/S1KoC3YqYxsLQYRN9tBQpHM24kRyLfFp 4w/GU2vDsba1Nknz9Jjm1jEj2UDRYoWxSXeXwOYgQkgTSQYUkiuuzONmj9ZEFLFhDnf1 oNakYUkvTItCu4NdRVl9ikWZPGIBPqMKQclt8FIFdKnlX+JG3RtF/RfesbxPlMhSUE7r zux7frcUiitLwLBtxMrfVGzNLlPnGeyTWTalh5dLSGD0r38zGFqvZIDWbKyLAwfCYWs7 t1flwh6qjogJhaVPC9Bs4lPkyceg/Z0HzF8ijf320BxnkYGvqrLCHBj9Hm2mZ0057XUd M1+Q== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rLI7mfe+LCb0HIMKwvMrrUkdOEn2/M3Y81AlRfbCNXc=; b=psAjSmrmwqFpP/CPopql6R3Gi/QUcZle4zDDU+LBB4knj59Ttm66aSsQk8LbritluE v2A1qGzAt83floTPWOal0nhDKr0RAux+bKgbH1MgYRyeNe5HWntlSMZ/rY7dHchzz7ML ewDbYHcGqzBL+nclWHltOfa785BNFz362QBqUypBw0ka3NhkMjJLU/ozfL8nRCIZSs7B 0PTFqVfoPpH8tTNqF3FDoF6uCcKmrjvRU+D6xhAArMzvvbCudO8sMjMCeFj3VAKO0iYd t5EAE3eUNsS6nGwUrMnFnWx89digeh8Qm6+JFy2TJ8a0UDjS8OnOrRjMZTFA+LJzvU4u OTsQ== 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 23si9462352pfi.265.2019.07.22.11.25.16; Mon, 22 Jul 2019 11:25:32 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727991AbfGVReY (ORCPT + 99 others); Mon, 22 Jul 2019 13:34:24 -0400 Received: from shelob.surriel.com ([96.67.55.147]:37752 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727777AbfGVReW (ORCPT ); Mon, 22 Jul 2019 13:34:22 -0400 Received: from imladris.surriel.com ([96.67.55.152]) by shelob.surriel.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1hpcC8-0003HL-CV; Mon, 22 Jul 2019 13:33:52 -0400 From: Rik van Riel To: linux-kernel@vger.kernel.org Cc: kernel-team@fb.com, pjt@google.com, dietmar.eggemann@arm.com, peterz@infradead.org, mingo@redhat.com, morten.rasmussen@arm.com, tglx@linutronix.de, mgorman@techsingularity.net, vincent.guittot@linaro.org, Rik van Riel Subject: [PATCH 10/14] sched,fair: add helper functions for flattened runqueue Date: Mon, 22 Jul 2019 13:33:44 -0400 Message-Id: <20190722173348.9241-11-riel@surriel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190722173348.9241-1-riel@surriel.com> References: <20190722173348.9241-1-riel@surriel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add helper functions to make the flattened runqueue patch a little smaller. The task_se_h_weight function is similar to task_se_h_load, but scales the task weight by the group weight, without taking the task's duty cycle into account. The task_se_in_cgroup helper is functionally identical to parent_entity, but directly calling a function with that name obscures what the other code is trying to use it for, and would make the code harder to understand. Signed-off-by: Rik van Riel --- kernel/sched/fair.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index c944729423bd..6073fabb171b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -243,6 +243,7 @@ static u64 __calc_delta(u64 delta_exec, unsigned long weight, struct load_weight const struct sched_class fair_sched_class; static unsigned long task_se_h_load(struct sched_entity *se); +static unsigned long task_se_h_weight(struct sched_entity *se); /************************************************************** * CFS operations on generic schedulable entities: @@ -431,6 +432,12 @@ static inline struct sched_entity *parent_entity(struct sched_entity *se) return se->parent; } +/* Is this (task) sched_entity in a non-root cgroup? */ +static inline bool task_se_in_cgroup(struct sched_entity *se) +{ + return parent_entity(se); +} + static void find_matching_se(struct sched_entity **se, struct sched_entity **pse) { @@ -513,6 +520,11 @@ static inline struct sched_entity *parent_entity(struct sched_entity *se) return NULL; } +static inline bool task_se_in_cgroup(struct sched_entity *se) +{ + return false; +} + static inline void find_matching_se(struct sched_entity **se, struct sched_entity **pse) { @@ -7835,6 +7847,20 @@ static void update_cfs_rq_h_load(struct cfs_rq *cfs_rq) } } +static unsigned long task_se_h_weight(struct sched_entity *se) +{ + struct cfs_rq *cfs_rq; + + if (!task_se_in_cgroup(se)) + return se->load.weight; + + cfs_rq = group_cfs_rq_of_parent(se); + update_cfs_rq_h_load(cfs_rq); + + /* Reduce the load.weight by the h_load of the group the task is in. */ + return (cfs_rq->h_load * se->load.weight) >> SCHED_FIXEDPOINT_SHIFT; +} + static unsigned long task_se_h_load(struct sched_entity *se) { struct cfs_rq *cfs_rq = group_cfs_rq_of_parent(se); @@ -7871,6 +7897,11 @@ static unsigned long task_se_h_load(struct sched_entity *se) { return se->avg.load_avg; } + +static unsigned long task_se_h_weight(struct sched_entity *se) +{ + return se->load.weight; +} #endif /********** Helpers for find_busiest_group ************************/ -- 2.20.1