All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li kunyu <likunyu10@163.com>
To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	vschneid@redhat.com, kprateek.nayak@amd.com
Cc: linux-kernel@vger.kernel.org, Li kunyu <likunyu10@163.com>
Subject: [PATCH v2] kernel/sched/fair: Fix the issue of virtual runtime conversion error
Date: Wed, 27 May 2026 15:21:13 +0800	[thread overview]
Message-ID: <20260527072113.359604-1-likunyu10@163.com> (raw)
In-Reply-To: <20260526071537.17460-1-likunyu10@163.com>

The logic of the function here should be to convert the virtual runtime
into actual time by combining it with the weight of the scheduling
entity.
However, it cannot be converted by simply converting actual time into
virtual running time. A reverse conversion is required to obtain the
correct time.

Signed-off-by: Li kunyu <likunyu10@163.com>
---
v2: Use the div64_ul function to perform division operation

 kernel/sched/fair.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 69361c63353a..53f3373c1735 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7033,7 +7033,9 @@ static void hrtick_start_fair(struct rq *rq, struct task_struct *p)
 			resched_curr(rq);
 		return;
 	}
-	delta = (se->load.weight * vdelta) / NICE_0_LOAD;
+
+	if (unlikely(se->load.weight != NICE_0_LOAD))
+		delta = div64_ul(NICE_0_LOAD * vdelta, se->load.weight);
 
 	/*
 	 * Correct for instantaneous load of other classes.
-- 
2.47.3


  parent reply	other threads:[~2026-05-27  7:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-26  7:15 [PATCH] kernel/sched/fair: Fix the issue of virtual runtime conversion error Li kunyu
2026-05-27  1:16 ` kernel test robot
2026-05-27  6:48   ` Geert Uytterhoeven
2026-05-27  7:21 ` Li kunyu [this message]
2026-05-27 11:59   ` [PATCH v2] " Peter Zijlstra
2026-05-28  6:07     ` Li kunyu
2026-05-28  9:58   ` kernel test robot

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=20260527072113.359604-1-likunyu10@163.com \
    --to=likunyu10@163.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.