Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3162700pxb; Sat, 6 Feb 2021 23:26:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmXFWDxuzEBhIRorrlylJdvZ0fBQ/+jQ9q6+8C68LIzxfvz9i9GU6aKkFOIE2F03umb9it X-Received: by 2002:a05:6402:1383:: with SMTP id b3mr11133147edv.131.1612682768111; Sat, 06 Feb 2021 23:26:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612682768; cv=none; d=google.com; s=arc-20160816; b=C9Ks+oI/9IjcmSY2FRX7e+Lvd4JKZNNAsFWAuMKYCkCmnfiJRrxqZb4ZYrn6pubVdj PuMq+Qnyyt5XQh998zPoAslT0lmad6CqwNNvh+hpsRY4g4pE8D65SdcdniN9o/ux7enf ZAwl5dnYRpsQa5lpYKGCvwXZJTgC/TIufPOc0LPV0m5Ztac6aFCeGa21QBfGFa1jI/7N tPjJaOKg2roHCUhL2k8Mi49N0mMDXU56BFyQ1rTg5iE8WbizV765Qu+js4xyGOwUwUVY j8rkMCTZcXCgl5uRgqc9ebdnMJRkWx2ycuiM2mHCYEwq0ypxgr6r2KZ0bgSRbX7b+/jS QtTQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=uEuMnedgqTej0QSJxh1iRlfrELjx7TlOWPlJXqTZiVI=; b=pWaGIeuR7+9jZMiQN7jLyZf2/X4VV6QRYVLvevE9QmFeYm0WnJmY1KmzoMLqWmalgU oyuBLOkJXwbMlfqL5KuwR6IHVK9fZYsVuzq1mIH53wnCYebxp079PzFEoo4TSbI5aTyg ctOk/nFpXKnbl5k3feJ4P3YGFz93XzsQvLAFs914qnI5yP2+w3fbnN/9j0e0SeZS13IY JKfBULAFm9rNttMB6DBLCVHOsfr2AjHBFfTyzEcjbgjEtS9C1dIhRTIPoms8HeIeUIgh RnY1fA7r3w1FfQy1lFSZGcvwybpcR4mDUbE4Y4BxulrcMowP+yXoE7QOzrNqpVrZ+t8l rMtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=N+mz0cQ8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a8si2237630ejt.133.2021.02.06.23.25.44; Sat, 06 Feb 2021 23:26:08 -0800 (PST) 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=@bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=N+mz0cQ8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229522AbhBGHYx (ORCPT + 99 others); Sun, 7 Feb 2021 02:24:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbhBGHYw (ORCPT ); Sun, 7 Feb 2021 02:24:52 -0500 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41C19C06174A for ; Sat, 6 Feb 2021 23:24:12 -0800 (PST) Received: by mail-pl1-x634.google.com with SMTP id a16so6175915plh.8 for ; Sat, 06 Feb 2021 23:24:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uEuMnedgqTej0QSJxh1iRlfrELjx7TlOWPlJXqTZiVI=; b=N+mz0cQ8fywwZ4JwGLIh9GkLKQm73Ux9OLSIHoG516+IvqtLJ6djwdqw+jh6HMb+zo Lm+Ssu/yjzDswdpYnYbzqVq9rUUd6rylZ86Nu9l4R+qnQjopc2WDRGj/C+OLPDD9UqR4 PSorGJ2AnXKjXzBW+LjHiGKFL5eaF7WN4XElPAGZ2bmSnqOSy1JsUW7LduYPnSstDJ9M l4/17+icevE2SGWiaIXxh3X3JHGnjf4BzJpkqjsmvJbF6ahAMdTa5DhLp6KLd/EphSS0 SQFJnZgaGutYQhpjsx9pn2tajy5joj7XpIS152JXR+/50n2698x2fSwRzwId2VY/jfzs gEYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uEuMnedgqTej0QSJxh1iRlfrELjx7TlOWPlJXqTZiVI=; b=ZSJ1qz3t/DlUsmjAWahOrE6TwYGZogEvhRLU7LLTgAhzRIRbINvX9gJ7CIjjOwAHHt wfd3vpQccqLYshpLp07ut3hbJLuobzG/ohgykhE0ilqnixgxhfZUUd7F49fl0eXdNqHC lt/rE1WVGwcC0D33GUkD6/Fs6r3zXAeMtMEdeNcYRAA/8HeantIDqksTl/I2ttPN1LMf jbJBirEluaYZr18HFlVxyv/p3B+M/Y2l0RS0xZ+56CnwH+C+5rHyLNpQ4Lz+hb5shH4f BJGfJ0h04g1iyYtU5lTjxjGivp4k8P2uO2Q/Rz4XbAfdTSFCcQxmpaiAnsy0+aGguCdj lc8A== X-Gm-Message-State: AOAM531xs+OXGlBSaRPVr03SKqegqCL7rFaIlFhJT2fDSiehpQ3sHkcU qJ2p1wFBl2jLhPz/khoomFIPAw== X-Received: by 2002:a17:90a:590c:: with SMTP id k12mr11404812pji.233.1612682651575; Sat, 06 Feb 2021 23:24:11 -0800 (PST) Received: from C02CV1DAMD6P.bytedance.net ([139.177.225.254]) by smtp.gmail.com with ESMTPSA id f3sm13659869pfe.25.2021.02.06.23.24.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 06 Feb 2021 23:24:10 -0800 (PST) From: Chengming Zhou To: hannes@cmpxchg.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, rostedt@goodmis.org, dietmar.eggemann@arm.com Cc: linux-kernel@vger.kernel.org, songmuchun@bytedance.com, zhouchengming@bytedance.com Subject: [PATCH] psi: Add PSI_CPU_FULL state Date: Sun, 7 Feb 2021 15:24:02 +0800 Message-Id: <20210207072402.67532-1-zhouchengming@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The FULL state doesn't exist for the CPU resource at the system level, but exist at the cgroup level, means all non-idle tasks in a cgroup are delayed on the CPU resource which used by others outside of the cgroup. Co-developed-by: Muchun Song Signed-off-by: Muchun Song Signed-off-by: Chengming Zhou --- include/linux/psi_types.h | 3 ++- kernel/sched/psi.c | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/linux/psi_types.h b/include/linux/psi_types.h index b95f3211566a..0a23300d49af 100644 --- a/include/linux/psi_types.h +++ b/include/linux/psi_types.h @@ -50,9 +50,10 @@ enum psi_states { PSI_MEM_SOME, PSI_MEM_FULL, PSI_CPU_SOME, + PSI_CPU_FULL, /* Only per-CPU, to weigh the CPU in the global average: */ PSI_NONIDLE, - NR_PSI_STATES = 6, + NR_PSI_STATES = 7, }; enum psi_aggregators { diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 39d758a15a57..c572ad529d87 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -34,7 +34,10 @@ * delayed on that resource such that nobody is advancing and the CPU * goes idle. This leaves both workload and CPU unproductive. * - * (Naturally, the FULL state doesn't exist for the CPU resource.) + * Naturally, the FULL state doesn't exist for the CPU resource at the + * system level, but exist at the cgroup level, means all non-idle tasks + * in a cgroup are delayed on the CPU resource which used by others outside + * of the cgroup. * * SOME = nr_delayed_tasks != 0 * FULL = nr_delayed_tasks != 0 && nr_running_tasks == 0 @@ -225,6 +228,8 @@ static bool test_state(unsigned int *tasks, enum psi_states state) return tasks[NR_MEMSTALL] && !tasks[NR_RUNNING]; case PSI_CPU_SOME: return tasks[NR_RUNNING] > tasks[NR_ONCPU]; + case PSI_CPU_FULL: + return tasks[NR_RUNNING] && !tasks[NR_ONCPU]; case PSI_NONIDLE: return tasks[NR_IOWAIT] || tasks[NR_MEMSTALL] || tasks[NR_RUNNING]; @@ -678,8 +683,11 @@ static void record_times(struct psi_group_cpu *groupc, int cpu, } } - if (groupc->state_mask & (1 << PSI_CPU_SOME)) + if (groupc->state_mask & (1 << PSI_CPU_SOME)) { groupc->times[PSI_CPU_SOME] += delta; + if (groupc->state_mask & (1 << PSI_CPU_FULL)) + groupc->times[PSI_CPU_FULL] += delta; + } if (groupc->state_mask & (1 << PSI_NONIDLE)) groupc->times[PSI_NONIDLE] += delta; @@ -1018,7 +1026,7 @@ int psi_show(struct seq_file *m, struct psi_group *group, enum psi_res res) group->avg_next_update = update_averages(group, now); mutex_unlock(&group->avgs_lock); - for (full = 0; full < 2 - (res == PSI_CPU); full++) { + for (full = 0; full < 2; full++) { unsigned long avg[3]; u64 total; int w; -- 2.11.0