firelzrd/bore-scheduler

3.1.0-stable causes compilation warnings

DrakoDom opened this issue · 7 comments

In kernel 6.4.8, I noticed some warnings in the latest version of bore-stable that didn't appear in the previous 3.0.0-stable. I'm using Clang 16.0.6 for compilation, so these warnings may not appear with GCC.

kernel/sched/fair.c:163:9: warning: comparison of distinct pointer types ('typeof (((40UL << 8) - 1)) *' (aka 'unsigned long *') and 'typeof (scaled_penalty) *' (aka 'unsigned int *')) [-Wcompare-distinct-pointer-types]
        return min(MAX_BURST_PENALTY, scaled_penalty);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/minmax.h:67:19: note: expanded from macro 'min'
#define min(x, y)       __careful_cmp(x, y, <)
                        ^~~~~~~~~~~~~~~~~~~~~~
./include/linux/minmax.h:36:24: note: expanded from macro '__careful_cmp'
        __builtin_choose_expr(__safe_cmp(x, y), \
                              ^~~~~~~~~~~~~~~~
./include/linux/minmax.h:26:4: note: expanded from macro '__safe_cmp'
                (__typecheck(x, y) && __no_side_effects(x, y))
                 ^~~~~~~~~~~~~~~~~
./include/linux/minmax.h:20:28: note: expanded from macro '__typecheck'
        (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                   ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~
kernel/sched/fair.c:1067:20: warning: comparison of distinct pointer types ('typeof (1) *' (aka 'int *') and 'typeof (__calc_delta_fair(delta_exec, curr, false)) *' (aka 'unsigned long long *')) [-Wcompare-distinct-pointer-types]
        curr->vruntime += max(1, calc_delta_fair(delta_exec, curr));
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/minmax.h:74:19: note: expanded from macro 'max'
#define max(x, y)       __careful_cmp(x, y, >)
                        ^~~~~~~~~~~~~~~~~~~~~~
./include/linux/minmax.h:36:24: note: expanded from macro '__careful_cmp'
        __builtin_choose_expr(__safe_cmp(x, y), \
                              ^~~~~~~~~~~~~~~~
./include/linux/minmax.h:26:4: note: expanded from macro '__safe_cmp'
                (__typecheck(x, y) && __no_side_effects(x, y))
                 ^~~~~~~~~~~~~~~~~
./include/linux/minmax.h:20:28: note: expanded from macro '__typecheck'
        (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                   ~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~

My bad.
Will Clang silence by appending 'ULL' to specify it's an u64?

--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1087,7 +1087,7 @@ static void update_curr(struct cfs_rq *cfs_rq)
 	curr->burst_time += delta_exec;
 	update_burst_penalty(curr);
 #endif // CONFIG_SCHED_BORE
-	curr->vruntime += max(1, calc_delta_fair(delta_exec, curr));
+	curr->vruntime += max(1ULL, calc_delta_fair(delta_exec, curr));
 	update_min_vruntime(cfs_rq);
 
 	if (entity_is_task(curr)) {

@mu I checked it and it seems to have partially solved the problem, but some warnings still occur.

kernel/sched/fair.c:186:9: warning: comparison of distinct pointer types ('typeof (((40UL << 8) - 1)) *' (aka 'unsigned long *') and 'typeof (scaled_penalty) *' (aka 'unsigned int *')) [-Wcompare-distinct-pointer-types]
        return min(MAX_BURST_PENALTY, scaled_penalty);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/minmax.h:67:19: note: expanded from macro 'min'
#define min(x, y)       __careful_cmp(x, y, <)
                        ^~~~~~~~~~~~~~~~~~~~~~
./include/linux/minmax.h:36:24: note: expanded from macro '__careful_cmp'
        __builtin_choose_expr(__safe_cmp(x, y), \
                              ^~~~~~~~~~~~~~~~
./include/linux/minmax.h:26:4: note: expanded from macro '__safe_cmp'
                (__typecheck(x, y) && __no_side_effects(x, y))
                 ^~~~~~~~~~~~~~~~~
./include/linux/minmax.h:20:28: note: expanded from macro '__typecheck'
        (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))

Thank you for testing.

--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -164,7 +164,7 @@ static int three          = 3;
 static int sixty_four     = 64;
 static int maxval_12_bits = 4095;
 
-#define MAX_BURST_PENALTY ((40UL << 8) - 1)
+#define MAX_BURST_PENALTY ((40U << 8) - 1)
 
 static inline u32 log2plus1_u64_u32f8(u64 v) {
 	x32 result;

Will this do?

Yay :D

  CC      kernel/vhost_task.o
  CC      mm/mmzone.o
  CC      arch/x86/hyperv/mmu.o
  CC      kernel/sched/core.o
  CC      mm/vmstat.o
  CC      fs/super.o
  CC      arch/x86/hyperv/nested.o
  CC      mm/backing-dev.o
  CC      fs/char_dev.o
  CC      arch/x86/hyperv/irqdomain.o
  CC      arch/x86/hyperv/ivm.o
  CC      fs/stat.o
  CC      mm/mm_init.o
  CC      arch/x86/hyperv/hv_apic.o

I used both fixes and it looks like CLANG no longer shows warnings. I also checked GG and there is nothing there either.

Thank you for your assistance!

Those two patches seem to have eliminated the warnings for me too. Thank you for your help.

Closing now.

Thank you for the report!