Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp26925ybd; Fri, 28 Jun 2019 13:50:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzflu13Lb8UEOWAv1EfG3IsMrD7uOW6e9uSxyS/EMXyBqj81EXobsKEAv/3Ji8HWmE0ojtk X-Received: by 2002:a63:7358:: with SMTP id d24mr8575383pgn.224.1561755017455; Fri, 28 Jun 2019 13:50:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561755017; cv=none; d=google.com; s=arc-20160816; b=ATfROO4d/AoAg0ZdDUqRCrRr7TdU7fv/R1q/mJd7bkC6I3zGkM9f+W6yOTHs8JfvKU rjBoAquKx3OAVTTrYqv0PFa5XIS5q71mILleazAthFk2WR1cdet58X2gCB2I3nfYWp2Y xNJ1Jv0auo9lvjBRw9CzJlpC2ncjNLsYRN31mqXEgF97OlrZRZkcF3zytpLXb3euLuxp lnm6nag7jGZ1SCFrUCrQDpQFn5/GIbMjHwTCVlFq8GnL8tW+IpH4M30VzKiDnIui0Xzs MfHTm7NKJVfhGr3NIuKWMQK6ypNsDbMcGB787kJ8pIY7eG9eRQ/rSOgZVgl97yHT9OxR PBLA== 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 :message-id:date:subject:cc:to:from; bh=jxE9aAjFdfB2Xh8hdz0BIcdDC1RYaxDuKFnEZlbtmtI=; b=zeJxY9S2AXSUfPDzNSa6+2i8+n5d1mcJV5AQLwqf4gvWSjP+cOeo137kIGtdgOG+Du WkVIDw1PFfU6p3BCpdG2Ai3pzXYIGKqZiPgdlW9O++viUszRhSCjEhMZvAHfytaN11Pq oq24a4BKBRZFABD8kYVGKw8whIl54hCQTEFO5wQ6sEClHmLTkSff2iXTxm1K4XLTI2Fd IKYgf0DKoVuSZkrp1oOnY+t0Rp/c1fv24143yxrbZilPCzc+cKFe6+9L9kgogCykorAd 3jTE5WrSAJzDueqTK8OiWpAi5XmA00KXoeBmJNNM1DwPBqTuYWC42Pv9GiK1uh0PhFr2 qmYw== 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 t17si3176139pjw.99.2019.06.28.13.49.38; Fri, 28 Jun 2019 13:50:17 -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 S1726754AbfF1Ut2 (ORCPT + 99 others); Fri, 28 Jun 2019 16:49:28 -0400 Received: from shelob.surriel.com ([96.67.55.147]:38398 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725783AbfF1Ut1 (ORCPT ); Fri, 28 Jun 2019 16:49:27 -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-CP; 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 Subject: [PATCH RFC v2 0/10] sched,fair: flatten CPU controller runqueues Date: Fri, 28 Jun 2019 16:49:03 -0400 Message-Id: <20190628204913.10287-1-riel@surriel.com> X-Mailer: git-send-email 2.20.1 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 The current implementation of the CPU controller uses hierarchical runqueues, where on wakeup a task is enqueued on its group's runqueue, the group is enqueued on the runqueue of the group above it, etc. This increases a fairly large amount of overhead for workloads that do a lot of wakeups a second, especially given that the default systemd hierarchy is 2 or 3 levels deep. This patch series is an attempt at reducing that overhead, by placing all the tasks on the same runqueue, and scaling the task priority by the priority of the group, which is calculated periodically. This patch series still has a number of TODO items: - Clean up the code, and fix compilation without CONFIG_FAIR_GROUP_SCHED. - Remove some more now unused code. - Figure out a performance regression with our web server workload. I have fixed the schbench issue, now I need to find the less obvious stuff causing an increased number of involuntary preemptions... - Reimplement CONFIG_CFS_BANDWIDTH. Plan for the CONFIG_CFS_BANDWIDTH reimplementation: - When a cgroup gets throttled, mark the cgroup and its children as throttled. - When pick_next_entity finds a task that is on a throttled cgroup, stash it on the cgroup runqueue (which is not used for runnable tasks any more). Leave the vruntime unchanged, and adjust that runqueue's vruntime to be that of the left-most task. - When a cgroup gets unthrottled, and has tasks on it, place it on a vruntime ordered heap separate from the main runqueue. - Have pick_next_task_fair grab one task off that heap every time it is called, and the min vruntime of that heap is lower than the vruntime of the CPU's cfs_rq (or the CPU has no other runnable tasks). - Place that selected task on the CPU's cfs_rq, renormalizing its vruntime with the GENTLE_FAIR_SLEEPERS logic. That should help interleave the already runnable tasks with the recently unthrottled group, and prevent thundering herd issues. - If the group gets throttled again before all of its task had a chance to run, vruntime sorting ensures all the tasks in the throttled cgroup get a chance to run over time. Changes from v1: - use task_se_h_weight instead of task_se_h_load in calc_delta_fair and sched_slice, this seems to improve performance a little, but I still have some remaining regression to chase with our web server workload - implement a number of the changes suggested by Dietmar Eggemann (still holding out for a better name for group_cfs_rq_of_parent) This series applies on top of 5.2-rc6. include/linux/sched.h | 6 kernel/sched/core.c | 2 kernel/sched/debug.c | 15 - kernel/sched/fair.c | 746 +++++++++++++++++++++----------------------------- kernel/sched/pelt.c | 53 +-- kernel/sched/pelt.h | 2 kernel/sched/sched.h | 10 7 files changed, 346 insertions(+), 488 deletions(-)