firelzrd / bore-scheduler

BORE (Burst-Oriented Response Enhancer) CPU Scheduler
GNU General Public License v2.0
330 stars 14 forks source link

Kernel 5.4 Patch Request #52

Open rifsxd opened 1 week ago

rifsxd commented 1 week ago

Is it possible for bore to work on 5.4? Since 4.19 and 5.15 backports doesnt boot but builds fine after a bit of manual patching

firelzrd commented 6 days ago

Can I see your "backported" patch, please?

rifsxd commented 6 days ago

Can I see your "backported" patch, please?

Bummer I deleted that backport branch, which patch you want me to apply to show you the changes? 5.15 backport would a better approach imo

firelzrd commented 6 days ago

It seems that 4.19 is more similar to 5.4. For example, the usage of min() macro and also the variable types in sysctl should be more like 4.19's.

rifsxd commented 5 days ago

linux5.4.y-bore5.1.0.patch.txt

CC kernel/sched/fair.o ../kernel/sched/fair.c:152:26: error: implicit declaration of function 'task_of' [-Werror,-Wimplicit-function-declaration] struct task_struct p = task_of(se); ^ ../kernel/sched/fair.c:152:22: error: incompatible integer to pointer conversion initializing 'struct task_struct ' with an expression of type 'int' [-Werror,-Wint-conversion] struct task_struct p = task_of(se); ^ ~~~ ../kernel/sched/fair.c:152:22: error: ISO C90 forbids mixing declarations and code [-Werror,-Wdeclaration-after-statement] ../kernel/sched/fair.c:347:35: error: static declaration of 'task_of' follows non-static declaration static inline struct task_struct task_of(struct sched_entity se) ^ ../kernel/sched/fair.c:152:26: note: previous implicit declaration is here struct task_struct p = task_of(se); ^ 4 errors generated. make[3]: [../scripts/Makefile.build:288: kernel/sched/fair.o] Error 1 make[2]: [../scripts/Makefile.build:556: kernel/sched] Error 2

rifsxd commented 5 days ago

https://github.com/rifsxd/android_kernel_realme_RMX3511/commit/5bcf5f8aae26f7fcd4fa95efaa621bbb02463d8c

firelzrd commented 5 days ago

For implicit declaration of function 'task_of', It seems that in fair.c static inline struct task_struct *task_of() is used before declared. Please try declaring it before the use. Insert the below line before the BORE function block. (anywhere before #150 in patched fair.c)

static inline struct task_struct *task_of(struct sched_entity *se);

For ISO C90 forbids mixing declarations and code, you have 2 options:

rifsxd commented 5 days ago
static void update_burst_score(struct sched_entity *se) {
    struct task_struct *p;
    u8 prio;
    u8 prev_prio;
    u8 new_prio;

    // Check if sched_entity corresponds to a task
    if (!entity_is_task(se))
        return;

    // Resolve task_struct from sched_entity
    p = container_of(se, struct task_struct, se);
    prio = p->static_prio - MAX_RT_PRIO;

    // Calculate previous priority
    prev_prio = min(39, prio + se->burst_score);

    // Update the burst score
    se->burst_score = se->burst_penalty >> 2;

    // Calculate new priority
    new_prio = min(39, prio + se->burst_score);
    if (new_prio != prev_prio) {
        reweight_task(p, new_prio); // Adjust task weight if priority changes
    }
}

I did this and it built without errors but as always whatever I do bore makes my kernel panic and doesn't boot

firelzrd commented 5 days ago

I see. Is there any kernel panic log?

rifsxd commented 5 days ago

If I could get out logs from this, then I wouldn't even need to hit you up lol the device gets stuck at boot logo (not boot animation) so no way to get logs, I know this is a kernel panic that's all

firelzrd commented 5 days ago

Okay, got it. I'll build my own 5.4 kernel when I next find free time.

firelzrd commented 4 days ago

https://github.com/firelzrd/bore-scheduler/blob/main/patches/legacy/linux-5.4-bore/0001-linux5.4.y-bore5.1.0.patch

confirmed bootable

rifsxd commented 4 days ago

https://github.com/rifsxd/android_kernel_realme_RMX3511/commits/bore/

still not booting and kernel panics but built succesfully after a little bit of code changes for my kernel source

0001-linux5.4.y-bore5.1.0.patch.txt 0002-constgran-vanilla-max.patch.txt

these are the new patches

and also now i can give you the kernel panic logs, could you inspect?

console-ramoops-0.log dmesg-ramoops-0.log

firelzrd commented 3 days ago

Thank you for providing those files.

<14>[    0.831215]c6 [    T1] init: [libfs_mgr]ReadFstabFromDt(): failed to read fstab from dt
<14>[    0.832569]c6 [    T1] init: Using Android DT directory /proc/device-tree/firmware/android/
<14>[    0.885179]c6 [    T1] init: bool android::init::BlockDevInitializer::InitDevices(std::set<std::string>): partition(s) not found in /sys, waiting for their uevent(s): boot_b, dtbo_b, l_agdsp_b, l_gdsp_b, l_ldsp_b, l_modem_b, metadata, pm_sys_b, super, vbmeta_b, vbmeta_product_b, vbmeta_system_b, vbmeta_system_ext_b, vbmeta_vendor_b, vendor_boot_b
<14>[   10.895536]c6 [    T1] init: Wait for partitions returned after 10010ms
<11>[   10.895585]c6 [    T1] init: bool android::init::BlockDevInitializer::InitDevices(std::set<std::string>): partition(s) not found after polling timeout: boot_b, dtbo_b, l_agdsp_b, l_gdsp_b, l_ldsp_b, l_modem_b, metadata, pm_sys_b, super, vbmeta_b, vbmeta_product_b, vbmeta_system_b, vbmeta_system_ext_b, vbmeta_vendor_b, vendor_boot_b
<10>[   10.895709]c6 [    T1] init: Failed to mount required partitions early ...
<0>[   10.895821]c6 [    T1] Kernel panic - not syncing: Attempted to kill the init task!

It looks to be a partition detection error to me. Can you try without BORE and see if it still fails?

rifsxd commented 3 days ago

Thank you for providing those files.

<14>[    0.831215]c6 [    T1] init: [libfs_mgr]ReadFstabFromDt(): failed to read fstab from dt
<14>[    0.832569]c6 [    T1] init: Using Android DT directory /proc/device-tree/firmware/android/
<14>[    0.885179]c6 [    T1] init: bool android::init::BlockDevInitializer::InitDevices(std::set<std::string>): partition(s) not found in /sys, waiting for their uevent(s): boot_b, dtbo_b, l_agdsp_b, l_gdsp_b, l_ldsp_b, l_modem_b, metadata, pm_sys_b, super, vbmeta_b, vbmeta_product_b, vbmeta_system_b, vbmeta_system_ext_b, vbmeta_vendor_b, vendor_boot_b
<14>[   10.895536]c6 [    T1] init: Wait for partitions returned after 10010ms
<11>[   10.895585]c6 [    T1] init: bool android::init::BlockDevInitializer::InitDevices(std::set<std::string>): partition(s) not found after polling timeout: boot_b, dtbo_b, l_agdsp_b, l_gdsp_b, l_ldsp_b, l_modem_b, metadata, pm_sys_b, super, vbmeta_b, vbmeta_product_b, vbmeta_system_b, vbmeta_system_ext_b, vbmeta_vendor_b, vendor_boot_b
<10>[   10.895709]c6 [    T1] init: Failed to mount required partitions early ...
<0>[   10.895821]c6 [    T1] Kernel panic - not syncing: Attempted to kill the init task!

It looks to be a partition detection error to me. Can you try without BORE and see if it still fails?

Exactly when I went through the logs I was so confused like why it doesn't get the partitions correctly loaded? What does it have to do with a scheduler? It doesn't occur when I do CONFIG_SCHED_BORE=n

rifsxd commented 3 days ago

Could it be cuz of sched_init_bore?

firelzrd commented 3 days ago
void sched_post_fork(struct task_struct *p)
{
#ifdef CONFIG_SCHED_BORE
    sched_post_fork_bore(p);
#endif // CONFIG_SCHED_BORE
    uclamp_post_fork(p);
}

I couldn't find the definition of uclamp_post_fork in Linux 5.4 (at least in 5.4.0 and 5.4.286), but in Linux 5.10 there is.

    p->last_sleep_ts        = 0;
#ifdef CONFIG_SCHED_BORE
    sched_fork_bore(p);
#endif // CONFIG_SCHED_BORE
    INIT_LIST_HEAD(&p->se.group_node);

And I couldn't find anything like last_sleep_ts in core.c of Linux 5.4 or 5.10.

Are you using a modified Linux source code?

rifsxd commented 3 days ago

This is my device kernel source

https://github.com/rifsxd/android_kernel_realme_RMX3511/tree/bore

Which closely follows this android_common_kernel branch android12-5.4 which I upstream from

https://github.com/aosp-mirror/kernel_common/tree/0c2544add9fc25c0e54a2167d6a2cfd2e696cf58

I upstreamed UpTo 5.4.256 and those functions exists

I tried with my stock oem kernel source patch 254 , my own 255, 256 and all fails to boot with bore on

EDIT: Wait p->last_sleep_ts doesn't have exist on android_common_kernel!

firelzrd commented 3 days ago

Thank you. I'll investigate it.

rifsxd commented 3 days ago

Thank you. I'll investigate it.

Edited above

rifsxd commented 3 days ago

Thank you. I'll investigate it.

And thanks ^^

firelzrd commented 3 days ago

0001-linux5.4.256-android-bore5.1.0.patch.txt I don't see any fault in the modifications. A little (but not much) difference between your patch and the one I made. Please recheck Kconfigs and filesystem-related config files.

firelzrd commented 3 days ago

[ 0.830188]c6 [ T1] sprd_wdt_fiq: disagrees about version of symbol module_layout

This may be indicating that there's a version mismatch between the kernel and the sprd_wdt_fiq module.

rifsxd commented 3 days ago

[ 0.830188]c6 [ T1] sprd_wdt_fiq: disagrees about version of symbol module_layout

This may be indicating that there's a version mismatch between the kernel and the sprd_wdt_fiq module.

You are not getting it, the kernel boots if I turn off CONFIG_SCHED_BORE in defconfig but doesn't if I turn it on and bore is included in the kernel

firelzrd commented 2 days ago

Alright. I've got to go for 2-day Tokyo trip. Please let me think over.

rifsxd commented 2 days ago

Alright. I've got to go for 2-day Tokyo trip. Please let me think over.

Sure thing!

backslashxx commented 1 day ago

@rifsxd can you try to patch out modversions check for now? atleast for testing do something like

https://github.com/rifsxd/android_kernel_realme_RMX3511/blob/bore/kernel/module.c#L1349 return 1 on this

like https://github.com/backslashxx/mojito_krenol/commit/0ad68a503f03ad788c92133dd84c5252fa882868

rifsxd commented 1 day ago

@rifsxd can you try to patch out modversions check for now? atleast for testing do something like

https://github.com/rifsxd/android_kernel_realme_RMX3511/blob/bore/kernel/module.c#L1349 return 1 on this

like backslashxx/mojito_krenol@0ad68a5

Sure, I will try it tomorrow.. I'm going out for something.