Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2335678imm; Fri, 7 Sep 2018 14:54:20 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYM+SLtvkyne1REAPTNuGWZcTtpEhJ6rFhiPQHtxpTfWeTbEf4XVXFxiUuvwXB0PSdyXe4y X-Received: by 2002:a62:4bc6:: with SMTP id d67-v6mr10790252pfj.175.1536357260274; Fri, 07 Sep 2018 14:54:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536357260; cv=none; d=google.com; s=arc-20160816; b=Eya8/BlZyFPEe4+JJp8ww+Scs26EL1GdsjWFPvHcrWVtXN8RV0eSi7p5EDu5ymT1DA r/U3YOFRxSndeRD7YxXlhBXXpJMz3fCcwPsQnsXb3Z1iKyOImJof0ayzBn4/n4BwVKhV jl9PDmBaRH5QCCAI+w04s21241qwfsnwb6zRjvg6OAPQpOYcP8d77PKZmTAsLuwONuU3 7Jo5h74CvmCCl2Tpr9vgTUf2vOfY96V6VHGuyXDK0qyoYUCV/uZdwNedVOJQV+Rs8Q6Z uQBPWpJ/yVhrNgtitCjXSYJ9UA5K1zlcR8QO39HYKmel7iDg2MNPb671RczEDgTxWbax b2Bw== 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 :dkim-signature; bh=JHgdqofGPw7S35H43SLYQDxxWOv3XzAe65kUZqWe60I=; b=xlyD5p3Vv4VcI4FM+mNV77Rlk0QtcmS6HvFOnvmBa0Q/rak1ANVQWb9kzhUTM01iyt cH4Gxjg4eS4rH4GsTP+XJHIY5zaYunSbpy0lbHhzArY7WZlsCXI3LQdgiKcNN9cK2Of3 elBxsJm35lOdanScIOXmZn7xbCq2PWjxLGD4fqxYGlMQ2D+o0sDLc0cWoQjobSxuh+UQ EZ1GJKZYbwxHxF+BZ+qBRCPuO/YM4XQt1OKQRfoGZ3dFZfo08WFuRL7XQx5RLVkMZsa2 0JIK0H2ngAa1i2PoRrlT+mw1WwxOTw1IAoxh999IEcKw9nPk4ul/KItvaXLx9AFJ1Zw3 LMbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=H7Dqdqq9; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2-v6si9447663pgk.33.2018.09.07.14.54.05; Fri, 07 Sep 2018 14:54:20 -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; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=H7Dqdqq9; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730381AbeIHCYq (ORCPT + 99 others); Fri, 7 Sep 2018 22:24:46 -0400 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:62448 "EHLO smtp-fw-6001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729673AbeIHCYp (ORCPT ); Fri, 7 Sep 2018 22:24:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1536356510; x=1567892510; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JHgdqofGPw7S35H43SLYQDxxWOv3XzAe65kUZqWe60I=; b=H7Dqdqq9gNHwxKvO6h5wTGidjh0SMm7O1awLgQrV9DmFVcv0oxfUGy8A vbpBvdodKygE62S+Hwsy9lnj0EgeTGChkLZlob/yeCyKgvqRKsZQgVdIa pLBjKs0MW7OfgzYRZtHTIigdpe1Y3WquXkoKmtweuy01dvpGXhGvXUyuS Y=; X-IronPort-AV: E=Sophos;i="5.53,343,1531785600"; d="scan'208";a="355980823" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2b-a7fdc47a.us-west-2.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 07 Sep 2018 21:41:48 +0000 Received: from u7588a65da6b65f.ant.amazon.com (pdx2-ws-svc-lb17-vlan3.amazon.com [10.247.140.70]) by email-inbound-relay-2b-a7fdc47a.us-west-2.amazon.com (8.14.7/8.14.7) with ESMTP id w87LfhIF005892 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 7 Sep 2018 21:41:45 GMT Received: from u7588a65da6b65f.ant.amazon.com (localhost [127.0.0.1]) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTPS id w87LffTL027270 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 7 Sep 2018 23:41:42 +0200 Received: (from jschoenh@localhost) by u7588a65da6b65f.ant.amazon.com (8.15.2/8.15.2/Submit) id w87LffjU027269; Fri, 7 Sep 2018 23:41:41 +0200 From: =?UTF-8?q?Jan=20H=2E=20Sch=C3=B6nherr?= To: Ingo Molnar , Peter Zijlstra Cc: =?UTF-8?q?Jan=20H=2E=20Sch=C3=B6nherr?= , linux-kernel@vger.kernel.org Subject: [RFC 15/60] sched: Introduce parent_cfs_rq() and use it Date: Fri, 7 Sep 2018 23:40:02 +0200 Message-Id: <20180907214047.26914-16-jschoenh@amazon.de> X-Mailer: git-send-email 2.9.3.1.gcba166c.dirty In-Reply-To: <20180907214047.26914-1-jschoenh@amazon.de> References: <20180907214047.26914-1-jschoenh@amazon.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Factor out the logic to retrieve the parent CFS runqueue of another CFS runqueue into its own function and replace open-coded variants. Signed-off-by: Jan H. Schönherr --- kernel/sched/fair.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 9f0ce4555c26..82cdd75e88b9 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -282,11 +282,18 @@ static inline struct cfs_rq *group_cfs_rq(struct sched_entity *grp) return grp->my_q; } +static inline struct cfs_rq *parent_cfs_rq(struct cfs_rq *cfs_rq) +{ + if (!cfs_rq->tg->parent) + return NULL; + return cfs_rq->tg->parent->cfs_rq[cpu_of(rq_of(cfs_rq))]; +} + static inline void list_add_leaf_cfs_rq(struct cfs_rq *cfs_rq) { if (!cfs_rq->on_list) { struct rq *rq = rq_of(cfs_rq); - int cpu = cpu_of(rq); + struct cfs_rq *pcfs_rq = parent_cfs_rq(cfs_rq); /* * Ensure we either appear before our parent (if already * enqueued) or force our parent to appear after us when it is @@ -296,8 +303,7 @@ static inline void list_add_leaf_cfs_rq(struct cfs_rq *cfs_rq) * tmp_alone_branch either when the branch is connected * to a tree or when we reach the beg of the tree */ - if (cfs_rq->tg->parent && - cfs_rq->tg->parent->cfs_rq[cpu]->on_list) { + if (pcfs_rq && pcfs_rq->on_list) { /* * If parent is already on the list, we add the child * just before. Thanks to circular linked property of @@ -305,14 +311,14 @@ static inline void list_add_leaf_cfs_rq(struct cfs_rq *cfs_rq) * of the list that starts by parent. */ list_add_tail_rcu(&cfs_rq->leaf_cfs_rq_list, - &(cfs_rq->tg->parent->cfs_rq[cpu]->leaf_cfs_rq_list)); + &pcfs_rq->leaf_cfs_rq_list); /* * The branch is now connected to its tree so we can * reset tmp_alone_branch to the beginning of the * list. */ rq->tmp_alone_branch = &rq->leaf_cfs_rq_list; - } else if (!cfs_rq->tg->parent) { + } else if (!pcfs_rq) { /* * cfs rq without parent should be put * at the tail of the list. @@ -4716,7 +4722,7 @@ static void sync_throttle(struct cfs_rq *cfs_rq) if (!cfs_bandwidth_used()) return; - pcfs_rq = cfs_rq->tg->parent->cfs_rq[cpu_of(rq_of(cfs_rq))]; + pcfs_rq = parent_cfs_rq(cfs_rq); cfs_rq->throttle_count = pcfs_rq->throttle_count; cfs_rq->throttled_clock_task = rq_clock_task(rq_of(cfs_rq)); -- 2.9.3.1.gcba166c.dirty