Re: [PATCH sched_ext/for-6.11] sched, sched_ext: Replace scx_next_task_picked() with sched_class->switch_class()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 20, 2024 at 03:42:48PM -0700, Linus Torvalds wrote:
> Btw, indirect calls are now expensive enough that when you have only a
> handful of choices, instead of a variable
> 
>         class->some_callback(some_arguments);
> 
> you might literally be better off with a macro that does
> 
>        #define call_sched_fn(class, name, arg...) switch (class) { \
>         case &fair_name_class: fair_name_class.name(arg); break; \
>         ... unroll them all here..
> 
> which then just generates a (very small) tree of if-statements.
> 
> Again, this is entirely too ugly to do unless people *really* care.
> But for situations where you have a small handful of cases known at
> compile-time, it's not out of the question, and it probably does
> generate better code.
> 
> NOTE NOTE NOTE! This is a comp[letely independent aside, and has
> nothing to do with sched_ext except for the very obvious indirect fact
> that sched_ext would be one of the classes in this kind of code.
> 
> And yes, I suspect it is too ugly to actually do this.

Very early on in the retpoline mess I briefly considered doing this, but
I decided against doing the ugly until someone came with numbers bad
enough to warrant them.

We're now many years later and I'm very glad we never really *had* to go
down that route.




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux