cyring / CoreFreq

CoreFreq : CPU monitoring and tuning software designed for 64-bit processors.
https://www.cyring.fr
GNU General Public License v2.0
1.97k stars 126 forks source link

[SOLVED] Project-C patch makes corefreq fail compilation in 5.16.x #322

Closed inglor closed 2 years ago

inglor commented 2 years ago

Although officially the projectc 1 hasn't officially published any new patchset for 5.16 users ported this into the latest 5.16 branch 2 4. Also zen-kernel ported this as well here: https://github.com/zen-kernel/zen-kernel/blob/5.16/prjc/include/linux/sched.h

With changes happening from 5.16 the task_struct remove the cpu field 6 which results in a compilation error.

cyring commented 2 years ago

The CoreFreq driver part is making use of cpu on these lines: https://github.com/cyring/CoreFreq/blob/b9fa2c12f8b8c51a3399a7b5db1d01317f7fca61/corefreqk.c#L10187

#if defined(CONFIG_SCHED_BMQ) \
 || defined(CONFIG_SCHED_PDS)
        SysGate->taskList[cnt].wake_cpu = (short int) thread->cpu;
#else
        SysGate->taskList[cnt].wake_cpu = (short int) thread->wake_cpu;
#endif /* CONFIG_SCHED_BMQ  */

Not sure about the impacts from the Project-C patchset but if changes can be solved with wake_cpu then it is just a matter of adding a Project-C build definition to the condition #if defined(CONFIG_SCHED_BMQ) || defined(CONFIG_SCHED_PDS) According to the zen-kernel, CONFIG_SCHED_ALT should be the one. I don't have a Project-C environment, can you try with CONFIG_SCHED_ALT ?

inglor commented 2 years ago

Project-C is the "new" name of the BMQ scheduler which by itself derived from PDS (and PDS-mq): https://cchalpha.blogspot.com/2020/06/project-c-repositories.html

cyring commented 2 years ago

Project-C is the "new" name of the BMQ scheduler which by itself derived from PDS (and PDS-mq): https://cchalpha.blogspot.com/2020/06/project-c-repositories.html

Without CONFIG_SCHED_ALT in your .config, wake_cpu appears usuable. https://gitlab.com/alfredchen/linux-prjc/-/blob/linux-5.15.y-prjc/include/linux/sched.h#L762 Can you post what you get as build error output ?

inglor commented 2 years ago

Sure, this is from trying to generate the kernel module with dkms from 1.89.3 against the linux-prjc 5.16.8.

make: Entering directory '/usr/src/corefreq-1.89.3'
cc   corefreqd.c corefreqm.c \
  -D CORE_COUNT=256 -D TASK_ORDER=5 -D MAX_FREQ_HZ=5250000000 -D UBENCH=0 \
  -o corefreqd -lpthread -lm -lrt
cc   \
  corefreq-cli.c corefreq-ui.c corefreq-cli-rsc.c \
  corefreq-cli-json.c corefreq-cli-extra.c \
  -D CORE_COUNT=256 -D TASK_ORDER=5 -D MAX_FREQ_HZ=5250000000 -D UBENCH=0  \
  -o corefreq-cli -lm -lrt
make -j1 -C /usr/lib/modules/5.16.8-1-prjc/build M=/var/lib/dkms/corefreq/1.89.3/build modules
make[1]: Entering directory '/usr/src/corefreq-1.89.3'
make[1]: warning: -j1 forced in submake: resetting jobserver mode.
  CC [M]  /var/lib/dkms/corefreq/1.89.3/build/corefreqk.o
/var/lib/dkms/corefreq/1.89.3/build/corefreqk.c: In function ‘Sys_DumpTask’:
/var/lib/dkms/corefreq/1.89.3/build/corefreqk.c:10190:71: error: ‘struct task_struct’ has no member named ‘wake_cpu’; did you mean ‘wake_q’?
10190 |                 SysGate->taskList[cnt].wake_cpu = (short int) thread->wake_cpu;
      |                                                                       ^~~~~~~~
      |                                                                       wake_q
compilation terminated due to -Wfatal-errors.
make[2]: *** [scripts/Makefile.build:287: /var/lib/dkms/corefreq/1.89.3/build/corefreqk.o] Error 1
make[1]: *** [Makefile:1846: /var/lib/dkms/corefreq/1.89.3/build] Error 2
make[1]: Leaving directory '/usr/lib/modules/5.16.8-1-prjc/build'
make: *** [Makefile:76: all] Error 2
make: Leaving directory '/usr/src/corefreq-1.89.3'

You can check it yourself if you install the packages from my unofficial repository: https://wiki.archlinux.org/title/Unofficial_user_repositories#artafinde

linux-prjc linux-prjc-headers corefreq-client corefreq-dkms corefreq-server

Pacman can support installing from urls if you don't want to install a whole repo.

pacman -U /url/to/package1 /url/to/package2 ...
cyring commented 2 years ago

Ok let me try to build with your package

cyring commented 2 years ago
pacman -Syu --ignore=linux --ignore=linux-docs --ignore=linux-headers --ignore=archiso
git clone https://aur.archlinux.org/linux-prjc.git
cd linux-prjc
makepkg -cCsfir
:: Retrieving packages...
 python-idna-3.3-3-any.pkg.tar.zst failed to download
error: failed retrieving file 'python-idna-3.3-3-any.pkg.tar.zst' from mir.archlinux.fr : The requested URL returned error: 404
warning: failed to retrieve some files
error: failed to commit transaction (failed to retrieve some files)
Errors occurred, no packages were upgraded.
==> Validating source files with b2sums...
    linux-5.16.8.tar.xz ... Passed
    linux-5.16.8.tar.sign ... Skipped
    linux-prjc-5.16.8-config ... Passed
    prjc_v5.16.patch ... Passed
    more-uarches-20211114.tar.gz ... Passed
    0001-linux-prjc-5.16.8-ZEN-Add-sysctl-and-CONFIG-to-disallow-unprivileged-C.patch ... FAILED
    0002-linux-prjc-5.16.8-Bluetooth-btintel-Fix-bdaddress-comparison-with-garb.patch ... FAILED
    0003-linux-prjc-5.16.8-Bluetooth-Read-codec-capabilities-only-if-supported.patch ... FAILED
    0003-linux-prjc-5.16.8-Bluetooth-fix-deadlock-for-RFCOMM-sk-state-change.patch ... FAILED
==> ERROR: One or more files did not pass the validity check!

pacman -S python-idna
makepkg_subarch=12  -cCsfir --skipchecksums

6 minutes of build and install later ... Now booting linux-prjc

cyring commented 2 years ago

2022-02-10-234424_644x550_scrot

Ugh, thread->on_cpu is definitively not the good candidat for tasks monitoring

cyring commented 2 years ago

But static inline unsigned int task_cpu(const struct task_struct *p) does the trick.

cyring commented 2 years ago

Now you test from the branch develop

inglor commented 2 years ago

Yeah I can confirm the develop branch works fine

cyring commented 2 years ago

Built 5.16.9-1-prjc: no regression observed with develop branch

2022-02-17-000256_1284x550_scrot

Btw, I have to add --skipchecksums option to makepkg

inglor commented 2 years ago

@cyring It seems 1.89.4 doesn't have the patch for this issue. I was expecting it to be there since the tag was made after your commit. Is that intentional?

cyring commented 2 years ago

@cyring It seems 1.89.4 doesn't have the patch for this issue. I was expecting it to be there since the tag was made after your commit. Is that intentional?

Still part of the develop branch. I wasn't aware you need it immediately. If you are blocked then I have to release 1.90 ASAP. Do you want me to ?

inglor commented 2 years ago

Nope, it's fine keep working on the new intel chps on develop and I can just backport that commit. Thanks for the reply ;)

cyring commented 2 years ago

I think we can close this one.