Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1313377pxb; Thu, 16 Sep 2021 05:01:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyo6ZIZxYWb2aWmJAPO/hlzdPAWjjQ8mqaXbqmHAkkl7AsIEoNUkPdzgzbXNMBatAzwjMnv X-Received: by 2002:a92:bf01:: with SMTP id z1mr3532288ilh.155.1631793669501; Thu, 16 Sep 2021 05:01:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631793669; cv=none; d=google.com; s=arc-20160816; b=CAnYTOlEnCLewK5G0HwRxgGesYE1KIQekpf2oTm1NTiBUi0zTPRWR1EUw33rttVqWe GxxnShA5GmI4yUFPQgSjNm2IQdixDFMBQA3bU9JZwqgjdac6QrJPOtYYZ4rlzKbxbTEE l6PWsDQCvB/+shUY50fmmO8K/4710c+lNzro0X+1rNGobuyzOssRuEK6JlGFKavMyKdJ Ge4+McdAnrcBaAN3eQJpAMkHDA+3qvSXyQB2c+OWTkQErg1t9+St5JiUy29utZnR098Y XChqNE5XjxC2V9BdggYK8xlS4MXyTpUMsktoAif1AKe40zB7D8Yu9B6Ih2yMXpgU1TON i2Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=BSDU1TtyZagcqyOboLaL62+Bw73cOugdGNlT67jjNiU=; b=W3XFaGHH2XzZ0fu1gGHdGWMOQfUfrCANfCKD4P1TSQU4ZnUHKQJs7qXSEvyBQ0wBbJ az87a87+BnNI0LNfUmKXw7NKl4yyZCKSX6p2/sp7HMjYNZSTs5jQUfFMQWoIzE+wzRIb QJiU1TJuh2P1N3MzV27aw705xG4MlwbGecGutlx00FG2/0oeBfMOd3WVmA4THvZtmCy7 z7rtWLcU+DN5YvWXfAvV+tZYcDL/w9ylGTZdA5bl/XA5lo5Bt8YFRmB7eNIRvZGAFmui SfQ/0aNPnwTUo90I7qUeBPiRa5cCw9PkA67UBbTHmhkjKbnY9Zz5ehVNQAw4wudiJsF4 j5PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=HEmlZVFZ; dkim=neutral (no key) header.i=@linutronix.de; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n3si2368342ilj.23.2021.09.16.05.00.57; Thu, 16 Sep 2021 05:01:09 -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=@linutronix.de header.s=2020 header.b=HEmlZVFZ; dkim=neutral (no key) header.i=@linutronix.de; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238961AbhIPMBG (ORCPT + 99 others); Thu, 16 Sep 2021 08:01:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238778AbhIPMAw (ORCPT ); Thu, 16 Sep 2021 08:00:52 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA1E1C061764; Thu, 16 Sep 2021 04:59:31 -0700 (PDT) Date: Thu, 16 Sep 2021 11:59:29 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1631793570; h=from:from:sender:sender:reply-to:reply-to:subject:subject: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=BSDU1TtyZagcqyOboLaL62+Bw73cOugdGNlT67jjNiU=; b=HEmlZVFZid8L5XThFKUwK++5ZrkJ5pxpJdWkg1qQK2QXuBYw7a5RNRiZby7MdnYQOMYOx9 BctB85JjA0+7NAYyF2DQusvb54QUO3WLlYcwZXXyxfZ0LQ3vAX/99ZjSeLxQFs4Cv1wuEZ vSOG5Cl1aZOIDCwGVNIC6qtGwLS8m96Ay8CrZLEoGmfoEmN77ax8H5a52/F+xOnGvxq12Z feuzMiAzZsyagy+oSTqjXtF+CaEKJhb6Rz4f9d709DHnJHSfCDEspKld0R5YHMqtLuq0oi Acpr2wUfI2DSPZ3pIQUVpTn3fRktXGzZsQ4wIyF9PsCa7TtIviKd9yehkOutRQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1631793570; h=from:from:sender:sender:reply-to:reply-to:subject:subject: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=BSDU1TtyZagcqyOboLaL62+Bw73cOugdGNlT67jjNiU=; b=JwcKyeYFgrxAiqFgPUQ21UOD95j499kNTNh2IlnGT2Jbzobd53phYIqh2brsrfuz0+PSP/ 30uKg1XB23yvL6Ag== From: "tip-bot2 for Yafang Shao" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched: Introduce task block time in schedstats Cc: Yafang Shao , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210905143547.4668-5-laoar.shao@gmail.com> References: <20210905143547.4668-5-laoar.shao@gmail.com> MIME-Version: 1.0 Message-ID: <163179356957.25758.2603980497962275087.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: a95f0507a1a4d6de8e9c8b2b61cb733947e9422b Gitweb: https://git.kernel.org/tip/a95f0507a1a4d6de8e9c8b2b61cb733947e9422b Author: Yafang Shao AuthorDate: Sun, 05 Sep 2021 14:35:43 Committer: Peter Zijlstra CommitterDate: Wed, 15 Sep 2021 17:48:59 +02:00 sched: Introduce task block time in schedstats Currently in schedstats we have sum_sleep_runtime and iowait_sum, but there's no metric to show how long the task is in D state. Once a task in D state, it means the task is blocked in the kernel, for example the task may be waiting for a mutex. The D state is more frequent than iowait, and it is more critital than S state. So it is worth to add a metric to measure it. Signed-off-by: Yafang Shao Signed-off-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20210905143547.4668-5-laoar.shao@gmail.com --- include/linux/sched.h | 2 ++ kernel/sched/debug.c | 6 ++++-- kernel/sched/stats.c | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 518e19c..549018e 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -441,6 +441,8 @@ struct sched_statistics { u64 block_start; u64 block_max; + s64 sum_block_runtime; + u64 exec_max; u64 slice_max; diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index ca0dd47..935dad7 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -534,10 +534,11 @@ print_task(struct seq_file *m, struct rq *rq, struct task_struct *p) (long long)(p->nvcsw + p->nivcsw), p->prio); - SEQ_printf(m, "%9Ld.%06ld %9Ld.%06ld %9Ld.%06ld", + SEQ_printf(m, "%9lld.%06ld %9lld.%06ld %9lld.%06ld %9lld.%06ld", SPLIT_NS(schedstat_val_or_zero(p->stats.wait_sum)), SPLIT_NS(p->se.sum_exec_runtime), - SPLIT_NS(schedstat_val_or_zero(p->stats.sum_sleep_runtime))); + SPLIT_NS(schedstat_val_or_zero(p->stats.sum_sleep_runtime)), + SPLIT_NS(schedstat_val_or_zero(p->stats.sum_block_runtime))); #ifdef CONFIG_NUMA_BALANCING SEQ_printf(m, " %d %d", task_node(p), task_numa_group_id(p)); @@ -971,6 +972,7 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, u64 avg_atom, avg_per_cpu; PN_SCHEDSTAT(sum_sleep_runtime); + PN_SCHEDSTAT(sum_block_runtime); PN_SCHEDSTAT(wait_start); PN_SCHEDSTAT(sleep_start); PN_SCHEDSTAT(block_start); diff --git a/kernel/sched/stats.c b/kernel/sched/stats.c index fad781c..07dde29 100644 --- a/kernel/sched/stats.c +++ b/kernel/sched/stats.c @@ -82,6 +82,7 @@ void __update_stats_enqueue_sleeper(struct rq *rq, struct task_struct *p, __schedstat_set(stats->block_start, 0); __schedstat_add(stats->sum_sleep_runtime, delta); + __schedstat_add(stats->sum_block_runtime, delta); if (p) { if (p->in_iowait) {