hamadmarri / cacule-cpu-scheduler

The CacULE CPU scheduler is based on interactivity score mechanism. The interactivity score is inspired by the ULE scheduler (FreeBSD scheduler).
266 stars 32 forks source link

Error when compiling #29

Closed alfzki closed 3 years ago

alfzki commented 3 years ago

kernel/sysctl.c:1696:13: error: ‘sysctl_sched_migration_cost’ undeclared here (not in a function); did you mean ‘sysctl_timer_migration’? 1696 | .data = &sysctl_sched_migration_cost, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ | sysctl_timer_migration

kernel 5.10.27

hamadmarri commented 3 years ago

Hi @alfzki

Could you please attach the .config file

alfzki commented 3 years ago

config.txt here is my .config file

hamadmarri commented 3 years ago

config.txt here is my .config file

Please try this fix patch rdb-fix-5.10.zip

diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
index 54ed48f8bd58..1a02df97c086 100644
--- a/include/linux/sched/sysctl.h
+++ b/include/linux/sched/sysctl.h
@@ -48,13 +48,11 @@ extern unsigned int sysctl_numa_balancing_scan_period_min;
 extern unsigned int sysctl_numa_balancing_scan_period_max;
 extern unsigned int sysctl_numa_balancing_scan_size;

-#ifdef CONFIG_CACULE_RDB
 #ifdef CONFIG_SCHED_DEBUG
 extern __read_mostly unsigned int sysctl_sched_migration_cost;
-#else
+#elif CONFIG_CACULE_RDB
 extern unsigned int sysctl_sched_migration_cost;
 #endif
-#endif

 #ifdef CONFIG_SCHED_DEBUG
 extern __read_mostly unsigned int sysctl_sched_nr_migrate;
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index aaa1e679a48a..bf9b0eb038d4 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7872,7 +7872,7 @@ static int task_hot(struct rq *src_rq)
    if (sysctl_sched_migration_cost == 0)
        return 0;

-   delta = rq_clock_task(src_rq) - p->se.exec_start;
+   delta = sched_clock() - p->se.exec_start;

    return delta < (s64)sysctl_sched_migration_cost;
 }
alfzki commented 3 years ago

no error for now, still compiling...

alfzki commented 3 years ago

Should I open another issue because sudo sysctl kernel.sched_harsh_mode_enabled and sudo sysctl kernel.sched_max_lifetime_ms returned cannot stat /proc/sys/kernel/sched_... : No such file or directory?

sudo sysctl kernel.sched_interactivity_factor is fine and returned kernel.sched_interactivity_factor = 32768

hamadmarri commented 3 years ago

Should I open another issue because sudo sysctl kernel.sched_harsh_mode_enabled and sudo sysctl kernel.sched_max_lifetime_ms returned cannot stat /proc/sys/kernel/sched_... : No such file or directory?

sudo sysctl kernel.sched_interactivity_factor is fine and returned kernel.sched_interactivity_factor = 32768

Hi @alfzki I will fix it asap

Thank you

hamadmarri commented 3 years ago

Should I open another issue because sudo sysctl kernel.sched_harsh_mode_enabled and sudo sysctl kernel.sched_max_lifetime_ms returned cannot stat /proc/sys/kernel/sched_... : No such file or directory?

sudo sysctl kernel.sched_interactivity_factor is fine and returned kernel.sched_interactivity_factor = 32768

Could you please try this fix patch

sysctl-fix.zip

diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
index 1a02df97c086..774de59e8111 100644
--- a/include/linux/sched/sysctl.h
+++ b/include/linux/sched/sysctl.h
@@ -33,6 +33,8 @@ extern unsigned int sysctl_sched_child_runs_first;

 #ifdef CONFIG_CACULE_SCHED
 extern int interactivity_factor;
+extern int cacule_max_lifetime;
+extern int cacule_harsh_mode;
 #endif

 enum sched_tunable_scaling {
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b68069d9ce05..8a4d220a2589 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3359,7 +3359,10 @@ void wake_up_new_task(struct task_struct *p)
    post_init_entity_util_avg(p);

 #ifdef CONFIG_CACULE_SCHED
-   p->se.cacule_node.cacule_start_time = sched_clock();
+   if (cacule_harsh_mode)
+       p->se.cacule_node.cacule_start_time = p->start_time;
+   else
+       p->se.cacule_node.cacule_start_time = sched_clock();
 #endif

    activate_task(rq, p, ENQUEUE_NOCLOCK);
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index d5835604b98f..5c6067a8c02c 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -44,6 +44,7 @@ static unsigned int normalized_sysctl_sched_latency   = 6000000ULL;

 #ifdef CONFIG_CACULE_SCHED
 int cacule_max_lifetime                    = 30000; // in ms
+int cacule_harsh_mode                  = 0;
 int interactivity_factor               = 32768;
 #endif

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 7c8968584678..3b3ad0da0c54 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1667,6 +1667,20 @@ static struct ctl_table kern_table[] = {
        .mode       = 0644,
        .proc_handler   = proc_dointvec,
    },
+   {
+       .procname   = "sched_max_lifetime_ms",
+       .data       = &cacule_max_lifetime,
+       .maxlen     = sizeof(int),
+       .mode       = 0644,
+       .proc_handler   = proc_dointvec,
+   },
+   {
+       .procname   = "sched_harsh_mode_enabled",
+       .data       = &cacule_harsh_mode,
+       .maxlen     = sizeof(int),
+       .mode       = 0644,
+       .proc_handler   = proc_dointvec,
+   },
 #endif
 #if defined(CONFIG_CACULE_RDB) || defined(CONFIG_SCHED_DEBUG)
    {
hamadmarri commented 3 years ago

I hate the auto close mechanism. Please let me know if the issue is resolved.

Thank you @alfzki

ptr1337 commented 3 years ago

Tried the patch and got also an error when patching doing the patches. Trying 5.11 kernel. But mostly I’m not a expert at creating PKGBUILDS.

Edit: Using this repository: https://github.com/kevall474/Linux/tree/main/Linux Changed at the PKGBUILD the cacule Patch also tried your fixes, not getting better. but maybe because there a so many patches in.

Right now not on my computer, can you send the logs later.

hamadmarri commented 3 years ago

Tried the patch and got also an error when patching doing the patches. Trying 5.11 kernel. But mostly I’m not a expert at creating PKGBUILDS.

Edit: Using this repository: https://github.com/kevall474/Linux/tree/main/Linux Changed at the PKGBUILD the cacule Patch also tried your fixes, not getting better. but maybe because there a so many patches in.

Right now not on my computer, can you send the logs later.

Hi @ptr1337

For 5.11 you don't need the last fix since 5.11 has the syscalls. I already updated the patches, you can use this patch directly on main stream kernel https://github.com/hamadmarri/cacule-cpu-scheduler/blob/master/patches/CacULE/v5.11/cacule-5.11.patch

I think you only need to replace the source+=("${patchsource}/cacule-patches/cacule-5.11.patch") with the new one. I am not sure where ${patchsource}/cacule-patches/cacule-5.11.patch is located in the kevall474 repo. If it downloads the patch with wget or git clone then I think it will download the updated patch.

Please let me know if need further help Thanks

ptr1337 commented 3 years ago

Ah, there is the issue. Im sorry. Ill try now :)

ptr1337 commented 3 years ago

@hamadmarri

Thats the only error which i get. 1 out of 117 hunks FAILED -- saving rejects to file kernel/sched/fair.c.rej

hamadmarri commented 3 years ago

@hamadmarri

Thats the only error which i get. 1 out of 117 hunks FAILED -- saving rejects to file kernel/sched/fair.c.rej

Which patch you are using? https://github.com/hamadmarri/cacule-cpu-scheduler/blob/master/patches/CacULE/v5.11/cacule-5.11.patch?

Which linux tree you are trying to apply the patch on?

ptr1337 commented 3 years ago

Got it working so far. The Kernel is compiling. Was just some configurations things. Compiling right now.

alfzki commented 3 years ago

Should I open another issue because sudo sysctl kernel.sched_harsh_mode_enabled and sudo sysctl kernel.sched_max_lifetime_ms returned cannot stat /proc/sys/kernel/sched_... : No such file or directory? sudo sysctl kernel.sched_interactivity_factor is fine and returned kernel.sched_interactivity_factor = 32768

Could you please try this fix patch

sysctl-fix.zip

the patch is working perfectly