Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMD Pref Core Support #1206

Open
ferrreo opened this issue Jan 16, 2025 · 1 comment
Open

AMD Pref Core Support #1206

ferrreo opened this issue Jan 16, 2025 · 1 comment

Comments

@ferrreo
Copy link

ferrreo commented Jan 16, 2025

Currently the way most of the scheds seem to work for assigning work to specific CPUs/threads is they query the cache layout, numa/topo layout or go off of frequency or some combination of all of those.

AMD CPUs in particular already have a ranking per CPU core called pref core. It should be preferable in most cases to use these values over self-baked topo rules for the following reasons:

  1. There are built in heuristics we don't have access to that goes into these values e.g all cores report the same max freq but will actually boost to different max freq.
  2. These can change at runtime via tunables e.g for dual CCD 3D vCache CPUs the user can tell the kernel to either rank for frequency or for cache (I have written a tool to do this for games based on profiles as some games want cache and others frequency).
  3. AMD can update these to factor in new things or alter how they are calculated at any time, so by using it you get that for free without needing to modify scheduler code in the future.

You can see these values by doing:

grep -v /sys/devices/system/cpu/cpu*/cpufreq/amd_pstate_prefcore_ranking

It should output something like:

/sys/devices/system/cpu/cpu1/cpufreq/amd_pstate_prefcore_ranking:231 /sys/devices/system/cpu/cpu2/cpufreq/amd_pstate_prefcore_ranking:226 /sys/devices/system/cpu/cpu3/cpufreq/amd_pstate_prefcore_ranking:236 /sys/devices/system/cpu/cpu4/cpufreq/amd_pstate_prefcore_ranking:221 /sys/devices/system/cpu/cpu5/cpufreq/amd_pstate_prefcore_ranking:236 /sys/devices/system/cpu/cpu6/cpufreq/amd_pstate_prefcore_ranking:216 /sys/devices/system/cpu/cpu7/cpufreq/amd_pstate_prefcore_ranking:206 /sys/devices/system/cpu/cpu8/cpufreq/amd_pstate_prefcore_ranking:171 /sys/devices/system/cpu/cpu9/cpufreq/amd_pstate_prefcore_ranking:196 /sys/devices/system/cpu/cpu10/cpufreq/amd_pstate_prefcore_ranking:201 /sys/devices/system/cpu/cpu11/cpufreq/amd_pstate_prefcore_ranking:181 /sys/devices/system/cpu/cpu12/cpufreq/amd_pstate_prefcore_ranking:176 /sys/devices/system/cpu/cpu13/cpufreq/amd_pstate_prefcore_ranking:186 /sys/devices/system/cpu/cpu14/cpufreq/amd_pstate_prefcore_ranking:166 /sys/devices/system/cpu/cpu15/cpufreq/amd_pstate_prefcore_ranking:191 /sys/devices/system/cpu/cpu16/cpufreq/amd_pstate_prefcore_ranking:211 /sys/devices/system/cpu/cpu17/cpufreq/amd_pstate_prefcore_ranking:231 /sys/devices/system/cpu/cpu18/cpufreq/amd_pstate_prefcore_ranking:226 /sys/devices/system/cpu/cpu19/cpufreq/amd_pstate_prefcore_ranking:236 /sys/devices/system/cpu/cpu20/cpufreq/amd_pstate_prefcore_ranking:221 /sys/devices/system/cpu/cpu21/cpufreq/amd_pstate_prefcore_ranking:236 /sys/devices/system/cpu/cpu22/cpufreq/amd_pstate_prefcore_ranking:216 /sys/devices/system/cpu/cpu23/cpufreq/amd_pstate_prefcore_ranking:206 /sys/devices/system/cpu/cpu24/cpufreq/amd_pstate_prefcore_ranking:171 /sys/devices/system/cpu/cpu25/cpufreq/amd_pstate_prefcore_ranking:196 /sys/devices/system/cpu/cpu26/cpufreq/amd_pstate_prefcore_ranking:201 /sys/devices/system/cpu/cpu27/cpufreq/amd_pstate_prefcore_ranking:181 /sys/devices/system/cpu/cpu28/cpufreq/amd_pstate_prefcore_ranking:176 /sys/devices/system/cpu/cpu29/cpufreq/amd_pstate_prefcore_ranking:186 /sys/devices/system/cpu/cpu30/cpufreq/amd_pstate_prefcore_ranking:166 /sys/devices/system/cpu/cpu31/cpufreq/amd_pstate_prefcore_ranking:191

I'll be making a PR shortly to add these values in topology.rs and would not be against also updating a sched or two to make use of it but I might need a bit of guidance on what are the appropriate ones to do so with and the preferred way of doing it.

@likewhatevs
Copy link
Contributor

@kkdwivedi btw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants