Re: [PATCH v11 1/2] sched/cache: Reduce the overhead of task_cache_work by only scan the visisted cpus

From: Chen Yu

Date: Mon Nov 16 2026 - 02:23:19 EST


On Wed, Nov 11, 2026 at 11:04:08AM +0000, Luo Gengkun wrote:
> Date: Wed, 11 Nov 2026 11:04:08 +0000
> From: Luo Gengkun <luogengkun@xxxxxxxxxxxxxxx>
> To: peterz@xxxxxxxxxxxxx, mingo@xxxxxxxxxx, juri.lelli@xxxxxxxxxx,
> vincent.guittot@xxxxxxxxxx, tim.c.chen@xxxxxxxxxxxxxxx,
> yu.c.chen@xxxxxxxxx, kprateek.nayak@xxxxxxx
> Cc: dietmar.eggemann@xxxxxxx, rostedt@xxxxxxxxxxx, bsegall@xxxxxxxxxx,
> mgorman@xxxxxxx, vschneid@xxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
> Subject: [PATCH v11 1/2] sched/cache: Reduce the overhead of
> task_cache_work by only scan the visisted cpus
> X-Mailer: git-send-email 2.34.1
>
> The overhead of task_cache_work() is high, especially in multi-NUMA systems.
> Currently, task_cache_work() tries to find the pref_llc by scanning all CPUs
> in the system. However, most of these scans are meaningless, such as those
> for CPUs that have never been visited or were accessed a long time ago.
>
> To address this problem, introduce visited_cpus to track the visited CPUs
> and evict them once they have not been accessed for a duration exceeding
> llc_epoch_affinity_timeout.
>
> Now that we know exactly which CPUs to scan from visited_cpus, we can remove
> get_scan_cpumasks().
>
> Below are the Redis test results conducted on AMD server.
>
> When NUMA balancing is disabled:
>
> valkey-benchmark rps | baseline | schedcache | schedcache_visit
> | (no cache aware) | (without this series) | (with this series)
> ----------------------+---------------------+---------------------+-----------+-------------------+--------
> | p99 latency(ms) | p99 latency(ms) | DIFF(%) | p99 latency(ms) | DIFF(%)
> 400000 | 0.436 | 0.554 | -25.68% | 0.441 | -1.14%
>
> Additionally, the output of perf top -e cycles:k highlights the overhead
> incurred by task_cache_work():
>
> valkey-benchmark rps | schedcache | schedcache_visit
> | (without this series) | (with this series)
> ----------------------+-------------------------------------------+---------------------------------------
> 400000 | 0.81% [kernel] [k] task_cache_work | 0.02% [kernel] [k] task_cache_work
>
> The trace data is shown below:
>
> echo NO_SC_VISIT > /sys/kernel/debug/sched/features
> redis-server-24660 [195] ..... 2916.005989: sched_cache_scan: comm=redis-server pid=24660 scan=384
> valkey-benchmar-48836 [317] ..... 2916.005993: sched_cache_scan: comm=valkey-benchmar pid=48836 scan=384
> valkey-benchmar-48487 [310] ..... 2916.006002: sched_cache_scan: comm=valkey-benchmar pid=48487 scan=384
>
> echo SC_VISIT > /sys/kernel/debug/sched/features
> redis-server-29080 [225] ..... 2876.257909: sched_cache_scan: comm=redis-server pid=29080 scan=14
> redis-server-26694 [018] ..... 2876.257909: sched_cache_scan: comm=redis-server pid=26694 scan=13
> valkey-benchmar-48198 [103] ..... 2876.257909: sched_cache_scan: comm=valkey-benchmar pid=48198 scan=16
>

SC_VISIT is not in the formal patch, so maybe adjust the comment above to say that this SC_VISIT is a trial
test feature and provide the link. But it is still OK to keep this as it is now.

Tim, may I know if this version looks good to you?

thanks,
Chenyu
>
> Tested-by: K Prateek Nayak <kprateek.nayak@xxxxxxx>
> Tested-by: Chen Yu <yu.c.chen@xxxxxxxxx>
> Reviewed-by: Chen Yu <yu.c.chen@xxxxxxxxx>
> Signed-off-by: Luo Gengkun <luogengkun@xxxxxxxxxxxxxxx>
>