mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Qing Wang <wangqing7171@gmail.com>
To: kayracizmeci@gmail.com, kprateek.nayak@amd.com
Cc: bsegall@google.com, davichazbh@gmail.com,
	dietmar.eggemann@arm.com, juri.lelli@redhat.com,
	linux-kernel@vger.kernel.org, mgorman@suse.de, mingo@redhat.com,
	peterz@infradead.org, rostedt@goodmis.org,
	tim.c.chen@linux.intel.com, vincent.guittot@linaro.org,
	vschneid@redhat.com, wangqing7171@gmail.com, yu.c.chen@intel.com
Subject: Re: [PATCH v3] sched/fair: Replace random newidle_balance with Bresenham accumulator
Date: Thu, 29 Oct 2026 17:31:44 +0800	[thread overview]
Message-ID: <20261029093144.2469124-1-wangqing7171@gmail.com> (raw)
In-Reply-To: <auL5Yok7oZrX79GG@scheduler.schedules>

> IMO, I'd like to keep the current code if there are no numbers.
> It isn’t worth it.
> 
> The test results of Prateek on this version don't reflect v4,
> since they were taken with this bug.

You're right, there are no on-machine test results yet. All I have is
the output of a Python program I just wrote that compares the accuracy
of the two algorithms.

It re-randomizes the ratio to a value in [0, 1023] every 512 calls
(the actual update interval, since newidle_call is halved after
each update) and runs 20000 windows (~10M calls):

                      Bresenham      random dice
max per-window error  0.5 attempts   41 attempts (~16%)

Bresenham has a much lower error.

the python program code
```python
import random
random.seed(1)
W=512; NW=20000
pos=0; maxerr_win_b=0; maxerr_win_r=0
for _ in range(NW):
    w = 1 + random.randrange(1024)
    ideal = W*w/1024
    fb=0; fr=0
    for _ in range(W):
        pos += w
        if pos >= 1024: pos -= 1024; fb += 1
        if random.randrange(1024) <= w-1: fr += 1
    maxerr_win_b = max(maxerr_win_b, abs(fb-ideal))
    maxerr_win_r = max(maxerr_win_r, abs(fr-ideal))
print(f"bresenham: max per-window err = {maxerr_win_b:.1f}")
print(f"random   : max per-window err = {maxerr_win_r:.1f}")
```

Hi Prateek, I'll send a v4 soon that fixes a reset bug — it just
drops the "sd->newidle_window_pos = 0;" line in update_newidle_stats().
If you want to test before v4 lands, that's the only change needed.
Could you please re-run the tbench tests on it? Thanks!
Cc: K Prateek Nayak <kprateek.nayak@amd.com>

> BTW, this patch removes sched_rng() which breaks the build on Linus's
> tree and tip:
> 
> kernel/sched/fair.c:8663:55: error: implicit declaration of function ‘sched_rng’ [-Wimplicit-function-declaration]
> 
> Thanks,
> 
> Kayra :-)

Sorry about that. I'll fix the build in v4.

--
Best regards,
Qing

  reply	other threads:[~2026-10-29  9:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28  3:44 Qing Wang
2026-10-28  9:01 ` Kayra Cizmeci
2026-10-29  7:30   ` Qing Wang
2026-10-29  8:41     ` Kayra Cizmeci
2026-10-29  9:31       ` Qing Wang [this message]
2026-10-28  9:05 ` Peter Zijlstra
2026-10-29  8:41   ` Qing Wang

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=20261029093144.2469124-1-wangqing7171@gmail.com \
    --to=wangqing7171@gmail.com \
    --cc=bsegall@google.com \
    --cc=davichazbh@gmail.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kayracizmeci@gmail.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=tim.c.chen@linux.intel.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=yu.c.chen@intel.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 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®