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

Complie fail kernel 6.10 #498

Closed mikealanni closed 1 month ago

mikealanni commented 1 month ago

Hi was trying to rebuild from the source and I'm getting this Error after kernel 6.10 install

make -j8 cc -Wall -Wfatal-errors -pthread -D CORE_COUNT=256 -D TASK_ORDER=5 -D MAX_FREQ_HZ=7125000000 -D UBENCH=0 -D DELAY_TSC=1 \ -c x86_64/corefreqd.c -o build/corefreqd.o cc -Wall -Wfatal-errors -pthread -D CORE_COUNT=256 -D TASK_ORDER=5 -D MAX_FREQ_HZ=7125000000 -D UBENCH=0 -D DELAY_TSC=1 \ -c x86_64/corefreqm.c -o build/corefreqm.o cc -Wall -Wfatal-errors -D CORE_COUNT=256 -D TASK_ORDER=5 -D MAX_FREQ_HZ=7125000000 -D UBENCH=0 -D DELAY_TSC=1 \ -c x86_64/corefreq-cli.c -o build/corefreq-cli.o cc -Wall -Wfatal-errors -D CORE_COUNT=256 -D TASK_ORDER=5 -D MAX_FREQ_HZ=7125000000 -D UBENCH=0 -D DELAY_TSC=1 \ -c x86_64/corefreq-ui.c -o build/corefreq-ui.o cc -Wall -Wfatal-errors -D CORE_COUNT=256 -D TASK_ORDER=5 -D MAX_FREQ_HZ=7125000000 -D UBENCH=0 -D DELAY_TSC=1 \ -c x86_64/corefreq-cli-rsc.c -o build/corefreq-cli-rsc.o cc -Wall -Wfatal-errors -D CORE_COUNT=256 -D TASK_ORDER=5 -D MAX_FREQ_HZ=7125000000 -D UBENCH=0 -D DELAY_TSC=1 \ -c x86_64/corefreq-cli-json.c -o build/corefreq-cli-json.o cc -Wall -Wfatal-errors -D CORE_COUNT=256 -D TASK_ORDER=5 -D MAX_FREQ_HZ=7125000000 -D UBENCH=0 -D DELAY_TSC=1 \ -c x86_64/corefreq-cli-extra.c -o build/corefreq-cli-extra.o cc -o build/corefreqd \ build/corefreqd.o build/corefreqm.o -lpthread -lm -lrt -lc cc -o build/corefreq-cli \ build/corefreq-cli.o build/corefreq-ui.o \ build/corefreq-cli-rsc.o build/corefreq-cli-json.o \ build/corefreq-cli-extra.o -lm -lrt -lc make[1]: Entering directory '/home/majed/linux' CC [M] /home/majed/CoreFreq/build/module/corefreqk.o /home/majed/CoreFreq/build/module/corefreqk.c:510:35: error: initialization of ‘void (*)(struct cpufreq_policy *)’ from incompatible pointer type ‘int (*)(struct cpufreq_policy *)’ [-Werror=incompatible-pointer-types] 510 | .exit = CoreFreqK_Policy_Exit, | ^~~~~~~~~~~~~~~~~~~~~ compilation terminated due to -Wfatal-errors. cc1: some warnings being treated as errors make[3]: *** [scripts/Makefile.build:244: /home/majed/CoreFreq/build/module/corefreqk.o] Error 1 make[2]: *** [/home/majed/linux/Makefile:1934: /home/majed/CoreFreq/build] Error 2 make[1]: *** [Makefile:240: __sub-make] Error 2 make[1]: Leaving directory '/home/majed/linux' make: *** [Makefile:110: all] Error 2

cyring commented 1 month ago

I don't understand this issue.

Mainline function prototype within Linux 6.10

int     (*exit)(struct cpufreq_policy *policy);

CoreFreq function prototype

static int CoreFreqK_Policy_Exit(struct cpufreq_policy *policy)

Still the same prototype as previous Linux versions.

Which distribution are you using ? Is your kernel patched ?

cyring commented 1 month ago

ArchLinux: build and boot the kernel 6.10.

No compilation issues encountered

cc  -Wall -Wfatal-errors -pthread -D CORE_COUNT=256 -D TASK_ORDER=5 -D MAX_FREQ_HZ=7125000000 -D UBENCH=0 -D DELAY_TSC=1 -D ARCH_PMC=UMC \
  -c x86_64/corefreqd.c -o build/corefreqd.o
cc  -Wall -Wfatal-errors -pthread -D CORE_COUNT=256 -D TASK_ORDER=5 -D MAX_FREQ_HZ=7125000000 -D UBENCH=0 -D DELAY_TSC=1 -D ARCH_PMC=UMC \
  -c x86_64/corefreqm.c -o build/corefreqm.o
cc  -Wall -Wfatal-errors -D CORE_COUNT=256 -D TASK_ORDER=5 -D MAX_FREQ_HZ=7125000000 -D UBENCH=0 -D DELAY_TSC=1 -D ARCH_PMC=UMC  \
  -c x86_64/corefreq-cli.c -o build/corefreq-cli.o
cc  -Wall -Wfatal-errors -D CORE_COUNT=256 -D TASK_ORDER=5 -D MAX_FREQ_HZ=7125000000 -D UBENCH=0 -D DELAY_TSC=1 -D ARCH_PMC=UMC \
  -c x86_64/corefreq-ui.c -o build/corefreq-ui.o
cc  -Wall -Wfatal-errors -D CORE_COUNT=256 -D TASK_ORDER=5 -D MAX_FREQ_HZ=7125000000 -D UBENCH=0 -D DELAY_TSC=1 -D ARCH_PMC=UMC  \
  -c x86_64/corefreq-cli-rsc.c -o build/corefreq-cli-rsc.o
cc  -Wall -Wfatal-errors -D CORE_COUNT=256 -D TASK_ORDER=5 -D MAX_FREQ_HZ=7125000000 -D UBENCH=0 -D DELAY_TSC=1 -D ARCH_PMC=UMC \
  -c x86_64/corefreq-cli-json.c -o build/corefreq-cli-json.o
cc  -Wall -Wfatal-errors -D CORE_COUNT=256 -D TASK_ORDER=5 -D MAX_FREQ_HZ=7125000000 -D UBENCH=0 -D DELAY_TSC=1 -D ARCH_PMC=UMC \
  -c x86_64/corefreq-cli-extra.c -o build/corefreq-cli-extra.o
cc  -o build/corefreqd \
  build/corefreqd.o build/corefreqm.o -lpthread -lm -lrt -lc
cc  -o build/corefreq-cli \
  build/corefreq-cli.o build/corefreq-ui.o \
  build/corefreq-cli-rsc.o build/corefreq-cli-json.o \
  build/corefreq-cli-extra.o -lm -lrt -lc
make[1]: Entering directory '/usr/lib/modules/6.10.0-arch1-1/build'
  CC [M]  CoreFreq/build/module/corefreqk.o
  LD [M]  CoreFreq/build/corefreqk.o
  MODPOST CoreFreq/build/Module.symvers
  CC [M]  CoreFreq/build/corefreqk.mod.o
  LD [M]  CoreFreq/build/corefreqk.ko
  BTF [M] CoreFreq/build/corefreqk.ko
make[1]: Leaving directory '/usr/lib/modules/6.10.0-arch1-1/build'
mikealanni commented 1 month ago

Ubuntu 22.04, no extra kernel patch, just downloaded the source, compiled it and installed it

cyring commented 1 month ago

Ubuntu 22.04, no extra kernel patch, just downloaded the source, compiled it and installed it

Link to the kernel source code please ?

mikealanni commented 1 month ago

ChatGPT offered to change static init to static void and remove the return line and add & to the line 510 .exit = &CoreFreqK_Policy_Exit.

That's fixed the issue but I have no clue what is it and will that affect the app

cyring commented 1 month ago

ChatGPT offered to change static init to static void and remove the return line and add & to the line 510 .exit = &CoreFreqK_Policy_Exit.

That's fixed the issue but I have no clue what is it and will that affect the app

Sure. But why are you having a Linux source code apparently not official ?

mikealanni commented 1 month ago

Oh didn't know that. Sorry not expert but I got Linus git

cyring commented 1 month ago

Oh didn't know that. Sorry not expert but I got Linus git

From here ? https://kernel.org/

mikealanni commented 1 month ago

I did git clone to this git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git a while back then I did git pull and build it. I'm doing something wrong?

cyring commented 1 month ago

There is only one prototype in kernel.org so far and up to to 6.10

int     (*exit)(struct cpufreq_policy *policy);
cyring commented 1 month ago

I did git clone to this git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git a while back then I did git pull and build it. I'm doing something wrong?

Since kernel 3.0 that exit function within structure cpufreq_driver has not changed!

cyring commented 1 month ago

Make sur to clean everything up

  1. Clone again Linux kernel 6.10 and build it by hand: make distclean and make clean before your make defconfig

    • Install and reboot that kernel, including its kernel header files
  2. Clone latest CoreFreq version:

    • Make sure to uninstall any CoreFreq package if one used;
    • Remove any old binaries remaining on PATH corefreqk.ko corefreqd corefreq-cli
    • Clone straight from the GitHub repository
    • Clean and build CoreFreq
      make -j clean
      make -j
    • Start CoreFreq directly from the work directory
      insmod build/corefreqk.ko
      ./build/corefreqd -q &
      ./buid/corefreq-cli
cyring commented 1 month ago

Wait a minute; I found that major change in github.com/torvalds

struct cpufreq_driver {
...
void        (*exit)(struct cpufreq_policy *policy);
...
};
cyring commented 1 month ago

And here's the root cause https://github.com/torvalds/linux/commit/b4b1ddc9dfe997a5f492fa3a36487f8e7a5de30d

cyring commented 1 month ago

And it's part of Linux Next

cyring commented 1 month ago

Until I'm committing a change you can fix source code by yourself as below

  1. Edit CoreFreqK_Policy_Exit function in x86_64/corefreqk.c file

https://github.com/cyring/CoreFreq/blob/a03489feb3560bd7b1107da9701896ab0cb9ca57/x86_64/corefreqk.c#L21311

and replace with:

static void CoreFreqK_Policy_Exit(struct cpufreq_policy *policy)
{
    UNUSED(policy);
}
  1. Edit file x86_64/corefreqk.h

https://github.com/cyring/CoreFreq/blob/a03489feb3560bd7b1107da9701896ab0cb9ca57/x86_64/corefreqk.h#L8634

and replace with

static void CoreFreqK_Policy_Exit(struct cpufreq_policy *policy) ;
  1. Rebuild
make -j clean
make -j
  1. Start CoreFreq
insmod build/corefreqk.ko
./build/corefreqd
./build/corefreq-cli
mikealanni commented 1 month ago

Man I just want to thank for your fast response, will try it and feedback

mikealanni commented 1 month ago

It is working now, and I think this the same I did earlier when chatgpt asks about change int to void and remove return line. don't know that AI do these things tho 😅

cyring commented 1 month ago

Hello,

In Arch's CDN the latest testing linux 6.10.0-arch1-2 archive file is still based on the old cpufreq function prototype.

I'm releasing the change as a patch and will wait to commit until Linux-Next is showing up into Arch

CoreFreq_linux_6_10_cpufreq.patch.gz

cyring commented 1 month ago

@mikealanni Hello,

Fix is now available in commit 0db6f0a18d3b03a26287fd30d27bb3fd24a2a3c2

cyring commented 1 month ago

Now as part of Releases