mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Prakash Sangappa <prakash.sangappa@oracle.com>
To: linux-kernel@vger.kernel.org
Cc: peterz@infradead.org, rostedt@goodmis.org,
	mathieu.desnoyers@efficios.com, tglx@linutronix.de,
	bigeasy@linutronix.de, kprateek.nayak@amd.com
Subject: [PATCH V3 3/4] Sched: Add scheduler stat for cpu time slice extension
Date: Fri,  2 May 2025 01:59:54 +0000	[thread overview]
Message-ID: <20250502015955.3146733-4-prakash.sangappa@oracle.com> (raw)
In-Reply-To: <20250502015955.3146733-1-prakash.sangappa@oracle.com>

Add scheduler stat to record number of times the thread was granted
cpu time slice extension.

Signed-off-by: Prakash Sangappa <prakash.sangappa@oracle.com>
---
 include/linux/sched.h | 2 ++
 kernel/rseq.c         | 1 +
 kernel/sched/core.c   | 5 +++++
 kernel/sched/debug.c  | 1 +
 4 files changed, 9 insertions(+)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index cce3a0496703..1367171b4a9e 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -340,6 +340,7 @@ extern void io_schedule_finish(int token);
 extern long io_schedule_timeout(long timeout);
 extern void io_schedule(void);
 extern void hrtick_local_start(u64 delay);
+extern void update_stat_preempt_delayed(struct task_struct *t);
 
 /* wrapper function to trace from this header file */
 DECLARE_TRACEPOINT(sched_set_state_tp);
@@ -563,6 +564,7 @@ struct sched_statistics {
 	u64				nr_wakeups_affine_attempts;
 	u64				nr_wakeups_passive;
 	u64				nr_wakeups_idle;
+	u64				nr_preempt_delay_granted;
 
 #ifdef CONFIG_SCHED_CORE
 	u64				core_forceidle_sum;
diff --git a/kernel/rseq.c b/kernel/rseq.c
index 0cfdaf5b6c8e..4c1586977f1b 100644
--- a/kernel/rseq.c
+++ b/kernel/rseq.c
@@ -475,6 +475,7 @@ bool rseq_delay_resched(void)
 		return false;
 
 	t->sched_time_delay = 1;
+	update_stat_preempt_delayed(t);
 
 	return true;
 }
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 05a952ec15ae..cb5bc0d41b01 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -936,6 +936,11 @@ void hrtick_local_start(u64 delay)
 	rq_unlock(rq, &rf);
 }
 
+void update_stat_preempt_delayed(struct task_struct *t)
+{
+	schedstat_inc(t->stats.nr_preempt_delay_granted);
+}
+
 static void hrtick_rq_init(struct rq *rq)
 {
 #ifdef CONFIG_SMP
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
index 4cba21f5d24d..6b753f56c312 100644
--- a/kernel/sched/debug.c
+++ b/kernel/sched/debug.c
@@ -1216,6 +1216,7 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns,
 		P_SCHEDSTAT(nr_wakeups_affine_attempts);
 		P_SCHEDSTAT(nr_wakeups_passive);
 		P_SCHEDSTAT(nr_wakeups_idle);
+		P_SCHEDSTAT(nr_preempt_delay_granted);
 
 		avg_atom = p->se.sum_exec_runtime;
 		if (nr_switches)
-- 
2.43.5


  parent reply	other threads:[~2025-05-02  2:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-02  1:59 [PATCH V3 0/4] Scheduler " Prakash Sangappa
2025-05-02  1:59 ` [PATCH V3 1/4] Sched: " Prakash Sangappa
2025-05-02  9:05   ` Peter Zijlstra
2025-05-02 13:06     ` Steven Rostedt
2025-05-05  1:51       ` Prakash Sangappa
2025-05-05 14:48         ` Steven Rostedt
2025-05-05 15:58           ` Prakash Sangappa
2025-05-05 16:34             ` Steven Rostedt
2025-05-05 16:45               ` Steven Rostedt
2025-05-06  1:23               ` Prakash Sangappa
2025-05-06 13:13                 ` Steven Rostedt
2025-05-02 15:39     ` Mathieu Desnoyers
2025-05-05  1:46       ` Prakash Sangappa
2025-05-05  1:42     ` Prakash Sangappa
2025-05-02 12:34   ` Sebastian Andrzej Siewior
2025-05-02 14:35     ` Peter Zijlstra
2025-05-02 15:27       ` Sebastian Andrzej Siewior
2025-05-02  1:59 ` [PATCH V3 2/4] Sched: Tunable to specify duration of " Prakash Sangappa
2025-05-02  1:59 ` Prakash Sangappa [this message]
2025-05-02  1:59 ` [PATCH V3 4/4] Sched: Add tracepoint for sched " Prakash Sangappa
2025-05-02  9:14   ` Peter Zijlstra
2025-05-02 11:02     ` Sebastian Andrzej Siewior
2025-05-02 11:10       ` Peter Zijlstra
2025-05-02 12:31         ` Sebastian Andrzej Siewior
2025-05-05  1:43     ` Prakash Sangappa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250502015955.3146733-4-prakash.sangappa@oracle.com \
    --to=prakash.sangappa@oracle.com \
    --cc=bigeasy@linutronix.de \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®