Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp28115ybd; Fri, 28 Jun 2019 13:52:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxedhnLe05xgwDSQdRItPbspsgpc+Yojrgsy6bsC7uCARKLR4/rv9wF0IBRYS1OosKb/wRr X-Received: by 2002:a17:902:2aa8:: with SMTP id j37mr13318478plb.316.1561755122334; Fri, 28 Jun 2019 13:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561755122; cv=none; d=google.com; s=arc-20160816; b=vCulqjYbAMQYnP9RqqN8dOyM11mLwLN/ALS48VhkuGAZgeKrzONBt7yiPFUcSnNylO hWcaGuzOGdtLJ07PRdZql+mD7JOZ2eiwauS1AlJwTgPX19vxERbUJlgDVmyy1o7oZDI4 fJY5AekxSG08GLisqH1aA7BUzuYAkZcQ58DU+WAH+LEoGiL1f9Np8cgO7QCGYJXEIuRg zTZE4+t21zez6IvDsGPmlGmeiq67KACe7mw0r2yn6IbiJPalj6t7b+Hbtt15ijf/obZy NjhLeuu93siIz+edKbsK/hl6Ule7tAj4TX4cNka4LI8qWD+neXsWfqFCeU1+sePBmmjQ b5iQ== 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=EIrXO6puyjF1ogeWmtGfmECSg8pI4ChzXp1Ni3Wzzz4=; b=VfRmDExtAyKcZQvuvLPbNAQWcCFkxjHtuejnKrxdufH4DSeu9BkVFCbOrkOmt79ZQ8 oSKAKYirBVWARcqfJffqSIEE04uSwuLmOh/+OU1Y7GO/P2uyVGCO9GKvUade16nRn1dy rz8iHrbq+4+K2Pb75COPD23ae+zMbz+0LEIdQf8dROk24xEllmTp/rX/FcqmLFfIClNF 9QfrprkyeNmt9KbXrTzMtLJAkdUy7YVQZ9G+G7/8ffGybcWAcHLjCUptpvOUEtDOcnX/ FuMzDGArXGccc5a5/f3k50L3EuVmbtvhc2jLGLqbyD4QBJSK6+cH0RwOCJS9PRE9olQ7 puKw== 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 s62si3055723pjc.75.2019.06.28.13.51.41; Fri, 28 Jun 2019 13:52:02 -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 S1726983AbfF1UuG (ORCPT + 99 others); Fri, 28 Jun 2019 16:50:06 -0400 Received: from shelob.surriel.com ([96.67.55.147]:38440 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726586AbfF1Utg (ORCPT ); Fri, 28 Jun 2019 16:49:36 -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 1hgxo6-0007TL-PI; Fri, 28 Jun 2019 16:49:18 -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 09/10] sched,fair: add helper functions for flattened runqueue Date: Fri, 28 Jun 2019 16:49:12 -0400 Message-Id: <20190628204913.10287-10-riel@surriel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190628204913.10287-1-riel@surriel.com> References: <20190628204913.10287-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 | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index a751e7a9b228..6fea8849cc12 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: @@ -411,6 +412,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) { @@ -7819,6 +7826,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); @@ -7855,6 +7876,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