Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp803026pxb; Thu, 19 Aug 2021 11:34:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHtYTBv8m9JbZV9xlNwJtth7ZDGayBUG4TtDWUdlOUjKsP4iXzUji0gLonDRDHe9UByplQ X-Received: by 2002:aa7:d28a:: with SMTP id w10mr17973311edq.63.1629398074296; Thu, 19 Aug 2021 11:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629398074; cv=none; d=google.com; s=arc-20160816; b=LlgxxySMS+Ox5PvYoR1FRIG6g4vwVYV0EmLESm5S8xrTEnmh6eHcaB60CGPfkI1HPR jHW86zzNo5Qe6cZRRYf8k9oKAMR0mwd5BFyA2R4vrHn0ib3FU6pSJ6MqyBGaxuit9DBf OESsbgYLGC0DLGDtAwee5zkFwKZJrziKvv8f5kuBFES2ETUBx3s+CAFtHI4VgC41Cw0f XDfi8/bF5sAMjkuAdpCfQyuRcLjgRYwLBUSxud6gj0KuuZESx2K2NEoGpkgpdvA3mrXX n+g9w9IKAlgHv99QztCiKk4I6481FAwthNBe943VCMLq3Ol2kS0Zet74CCFO1rT3mEQq 3/eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZXu5X0lro47sECG/7ctTMKIsIb2WSK/2oU0QLZiG4pE=; b=mXvqW2kAURzwppPRt6WYEF6+hlYcRbz+Fd9vNHvEdV7+F7is90OYgaVUKU0LVbH4jB OVL4abnz4AVUbfKY/xFDJL/nyvYvxK7mU4DsunlNRAc/Z50neta4LUt0yKDVugTm8+7d lj+cciYRn8Zo+bTpZgx+b287uRz0iHuPgCuOAwggxEzobpo/uskAPfq9bTzqKDr7SRAr 9a4bH/h8k2HxeVZUD/B42jmNHEPh4HK+vcIgF+hPEckYc4WZQeP4ac7qPipU7uMInWWW /IhOWERgGzQBxWGCyUks8ec49O2EymhWt2q/vcyYO+Hw0GSls+OVKhvNLxD1jvoRHtDO E/cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="BcQ+Xa/4"; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a17si3870072edx.592.2021.08.19.11.34.07; Thu, 19 Aug 2021 11:34:34 -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; dkim=pass header.i=@suse.com header.s=susede1 header.b="BcQ+Xa/4"; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234084AbhHSRve (ORCPT + 99 others); Thu, 19 Aug 2021 13:51:34 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:57786 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231561AbhHSRvS (ORCPT ); Thu, 19 Aug 2021 13:51:18 -0400 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 64ABD22145; Thu, 19 Aug 2021 17:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1629395441; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZXu5X0lro47sECG/7ctTMKIsIb2WSK/2oU0QLZiG4pE=; b=BcQ+Xa/48N5LNymNq0NWfPz00A1UPHwWZe2MJzkYM7CL/Brg0+qOAJfQTGsSFxpdqxnIZe jLEoWG8gwI1ibQtOhdYO4rutuMUnDNnML1N4YpNpxZiKm5cXYnVLdtpfT63t+Js5hBrys1 BNkyb0pL7O2/kFQdJACeyVHcqd0Xfq4= Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 3BAE013AAE; Thu, 19 Aug 2021 17:50:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id IDnuDfGZHmHnOQAAGKfGzw (envelope-from ); Thu, 19 Aug 2021 17:50:41 +0000 From: =?UTF-8?q?Michal=20Koutn=C3=BD?= To: linux-kernel@vger.kernel.org Cc: Vincent Guittot , Phil Auld , Ingo Molnar , Peter Zijlstra , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Odin Ugedal , Rik van Riel , Giovanni Gherdovich Subject: [RFC PATCH v2 2/5] sched: Add group_se() helper Date: Thu, 19 Aug 2021 19:50:31 +0200 Message-Id: <20210819175034.4577-3-mkoutny@suse.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210819175034.4577-1-mkoutny@suse.com> References: <20210819175034.4577-1-mkoutny@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org No functional change, unify cfs_rq to sched_entity conversion (and move closer to use where possible). The helper is used only by CONFIG_FAIR_GROUP_SCHED code, i.e. no dummy variant is defined. Signed-off-by: Michal Koutný --- kernel/sched/fair.c | 9 +++------ kernel/sched/sched.h | 8 ++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 2c41a9007928..905f95b91a7a 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4824,8 +4824,6 @@ static bool throttle_cfs_rq(struct cfs_rq *cfs_rq) if (!dequeue) return false; /* Throttle no longer required. */ - se = cfs_rq->tg->se[cpu_of(rq_of(cfs_rq))]; - /* freeze hierarchy runnable averages while throttled */ rcu_read_lock(); walk_tg_tree_from(cfs_rq->tg, tg_throttle_down, tg_nop, (void *)rq); @@ -4833,6 +4831,7 @@ static bool throttle_cfs_rq(struct cfs_rq *cfs_rq) task_delta = cfs_rq->h_nr_running; idle_task_delta = cfs_rq->idle_h_nr_running; + se = group_se(cfs_rq); for_each_sched_entity(se) { struct cfs_rq *qcfs_rq = cfs_rq_of(se); /* throttled entity or throttle-on-deactivate */ @@ -4884,8 +4883,6 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) struct sched_entity *se; long task_delta, idle_task_delta; - se = cfs_rq->tg->se[cpu_of(rq)]; - cfs_rq->throttled = 0; update_rq_clock(rq); @@ -4898,6 +4895,7 @@ void unthrottle_cfs_rq(struct cfs_rq *cfs_rq) /* update hierarchical throttle state */ walk_tg_tree_from(cfs_rq->tg, tg_nop, tg_unthrottle_up, (void *)rq); + se = group_se(cfs_rq); if (!cfs_rq->load.weight) { /* Nothing to run but something to decay? Complete the branch */ if (cfs_rq->on_list) @@ -8163,8 +8161,7 @@ static bool __update_blocked_fair(struct rq *rq, bool *done) */ static void update_cfs_rq_h_load(struct cfs_rq *cfs_rq) { - struct rq *rq = rq_of(cfs_rq); - struct sched_entity *se = cfs_rq->tg->se[cpu_of(rq)]; + struct sched_entity *se = group_se(cfs_rq); unsigned long now = jiffies; unsigned long load; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 14a41a243f7b..219ee463fe64 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1383,6 +1383,14 @@ static inline struct cfs_rq *group_cfs_rq(struct sched_entity *grp) return grp->my_q; } +/* sched entity representing the cfs_rq, NULL for root */ +static inline struct sched_entity *group_se(struct cfs_rq *cfs_rq) +{ + int cpu = cpu_of(rq_of(cfs_rq)); + + return cfs_rq->tg->se[cpu]; +} + #else static inline struct task_struct *task_of(struct sched_entity *se) -- 2.32.0