Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4634597pxb; Tue, 5 Oct 2021 07:15:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJpsw/Gcqmh/Mf4MoxYV4Cv7856+IxcTfIAz03wSyMJCSvOqli714kv2mEyeZpNAYVaSbM X-Received: by 2002:a17:906:1f49:: with SMTP id d9mr25610628ejk.150.1633443351919; Tue, 05 Oct 2021 07:15:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633443351; cv=none; d=google.com; s=arc-20160816; b=x83GpLLlUZdt+cqXSf/ZKGPb+snzU98O/FhKxkwOHggyMI2Sd2cKn9HsZx4wjFPWxl Tjk73AvmVGLQaswY0bfYFfwfWntreCjFVOJECPsJZO34tqyFXt6L1m5kzfwOGzryUxlC LYjMvU6K4kDTHkQ8bn+CoSX9SBCcyyUlNnGNXPZIsnPKmfY4xDCKvyBC9Nb0QEu5CADn dFHEijSxmYbQmgxatTWWyLYKpJx4d+95J5t5oM+GmPvgFlxoqytoIxNpntIKdFMIm/BV U9oLOd1Q2S+rPWJtJnA+MtZhdkpFmm0IeOn7/zpc2BBYoAdCCbqI2/sVRdUQQLijwrk0 ANyw== 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=zIAvYn42rhROY5E6oqRvQcMIt/GxIN+XR+yIa+6O5Pw=; b=RDlqG7Mw3FKxFUNrcf3MXi7DqSHiYcw47Cy7FUaRN/dwQCIPa/Esj5b3zr19Y1c9+L NlBldRrkvIEoMc9rOmEd5D0m1jvWHwSlGSOarykYnSe+l/nVaJ9K4HpwIHpCoQOyzVuT Wdh7BKTuTVb+GbtLzhJ5PKAxHKAdgaUNYbABVYA1UxcrP15pspYxw8ANRrgPYoUffZi+ 1vJBZvbMAk2cPKD9aeeST6K457r0hja5MVqRFskwoCpDJnEuLUeFuOsgOkbIa1ENJbmI gHKpqU+IIiWISYs4ZyUszqP/gigzYAoLaTCYQyCBV9rJARSzDEGA2b3UhQJm91m5fuKJ JsAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Nlkwv49n; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 nb20si2691171ejc.49.2021.10.05.07.15.23; Tue, 05 Oct 2021 07:15:51 -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=Nlkwv49n; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S236440AbhJEOPB (ORCPT + 99 others); Tue, 5 Oct 2021 10:15:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235599AbhJEOOC (ORCPT ); Tue, 5 Oct 2021 10:14:02 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FE59C061786; Tue, 5 Oct 2021 07:12:10 -0700 (PDT) Date: Tue, 05 Oct 2021 14:12:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1633443129; 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=zIAvYn42rhROY5E6oqRvQcMIt/GxIN+XR+yIa+6O5Pw=; b=Nlkwv49nuhTTnhOYN7xz2FqoCZRVnXMTzhZdzqd3uCMKF1mtXr4gXIKzhp/WAFz+uO7uMf Dj8T4lapWW+IR+GrmMdSNKMfLGUWFDteO6cvJmFIU31WywBme9CSfyXnajVr3124s5VyuG ZIZ0kzh3N06NAxLwvEh0ZdzPbZcGUFqqzF6z8CJP1VuSoLJ8a5GHHZ4pvyXiFSVN7xrk6v pr5oEYzCYqUNXV4IDxErSL6ntd6QGWMzTZ6A89AWLsqatNe5sBKwLoSr/A5ODa2c6j/jhZ HwAdL6CS1cBv7vbiMpM+waLrtw4+QnLxDO7OtZPVQeV/yblt1thFucIbfueBOA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1633443129; 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=zIAvYn42rhROY5E6oqRvQcMIt/GxIN+XR+yIa+6O5Pw=; b=ZT/Lk69ATGolcPINR8p/7TfNHypsEHv8M6hk0goiJclSBNuAnx2bv5F2Q5lza5xtTPgIPD b+/wnjB47aQ8pYCA== 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: <163344312843.25758.4573162866545999201.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: 847fc0cd0664fcb2a08ac66df6b85935361ec454 Gitweb: https://git.kernel.org/tip/847fc0cd0664fcb2a08ac66df6b85935361ec454 Author: Yafang Shao AuthorDate: Sun, 05 Sep 2021 14:35:43 Committer: Peter Zijlstra CommitterDate: Tue, 05 Oct 2021 15:51:48 +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 2bc4c72..193e16e 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -503,6 +503,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 76fd38e..26fac5e 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -540,10 +540,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)); @@ -977,6 +978,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) {