Re: [RFC PATCH RESEND 05/10] sched/fair: Introduce select_task_rq_fair_thin() to select rq when LB_PROMOTE

From: Xin Zhao

Date: Thu Sep 10 2026 - 11:42:33 EST


On Thu, 10 Sep 2026 15:00:29 +0300 Kayra Cizmeci <kayracizmeci@xxxxxxxxx> wrote:

> > Testing has shown that in our system with 18 CPUs running at 2.1GHz, where
> > the first three sd_llc domains each contains 4 CPUs and the last sd_llc
> > contains 2 CPUs, under same fillback scenario, select_task_rq_fair_thin()
> > executes 25% faster than the original select_task_rq_fair(). It saves 22ms
> > over a 10-second period, with this optimization accounting for 0.174% of
> > total system time. Additionally, we measured the execution time of
> > update_idle_cpu_scan, which took 0.5ms over the same 10-second period. If
> > we use select_task_rq_fair_thin() instead, this time can be eliminated,
> > accounting for 0.04% of total system time. Therefore, the overall
> > optimization contributes to a reduction of 0.214% of total system time.
>
> Okay. Can you specify which tests you ran or what you used? If you can?

I used a relatively crude and straightforward method, which involves
subtracting the time at the beginning and end of the select_task_rq_fair()
function and then accumulating the per-CPU time. I retrieve this accumulated
value a kernel module (ko). The detailed script is as follows:

Below is the test script for comparing the effect of select_task_rq_fair()
with and without the patch:

#!/bin/bash

insmod testselecttask. patch=0 on=1
sleep 10
insmod testselecttask.ko patch=0 on=0
cat testselecttask_patch_0.txt

sleep 1
insmod testselecttask.ko patch=1 on=1sleep 10
insmod testselecttask.ko patch=1 on=0
cat testselecttask_patch_1.txt

Test results:

root@hobot:/map/zhaoxin# ./smalltest.sh
ins: ERROR: could not insert module testselecttask.ko: Invalid parameters
insmod: ERROR: could not insert module testselecttask.ko: Invalid parameters
zhaoxin: enable[0] count[179226] timens[09325] avg[460]
insmod: ERROR: could not insert module testselecttask.ko: Invalid parameters
insmod: ERROR: could not insert module testselecttask.ko: Invalid parameters
zhaoxin: enable[1 count[180836] timens[59444800] avg[328]

>From the test results, combined with the following information:

Currently, the machine's overall sys time is about 7%, multiplied by 18
cores, which results approximately 126% for a multi-core CPU. The test
duration is 10 seconds, and within that time, 22 ms is saved, which
translates to 2.2 ms per second, equating to 0.0022 for multi, or 0.22%.
The time taken by this function is generally linked to the total sys time,
and the optimized portion accounts for about 0.174% of the total sys time.

Below are the test results for the execution time ofupdate_idle_cpu_scan`:

root@hobot:/map/zhaoxin# ./smalltest.sh
insmod: ERROR: could not insert module testselecttask.ko: Invalid parameters
insmod: ERROR: could not insert moduleselecttask.ko: Invalid parameters
zhaoxin: enable[0] count[179226] timens[82509325] avg[460]
insmod: ERROR: could not insert module testselecttask.ko: Invalid parameters
mod: ERROR: could not insert module testselecttask.ko: Invalid parameters
zhaoxin: enable[1] count[180836] timens[59444800] avg[328]

>From the test results, combined with following information:

Currently, the machine's overall sys time is about 7%, multiplied by 18
cores, which results in approximately 126% for a multi-core CPU. The test
duration is 10 seconds, and within that time, 22 is saved, which translates
to 2.2 ms per second, equating to 0.0022 for multi-core, or 0.22%. The time
taken by this function is generally linked to the total sys time, and the
optimized accounts for about 0.174% of the total sys time.

--
Xin Zhao