Re: [POC][RFC][PATCH] sched: Extended Scheduler Time Slice

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

 



On Wed, Oct 25, 2023 at 05:42:19AM -0400, Steven Rostedt wrote:

> That is, there's this structure for every thread. It's assigned with:
> 
> 	fd = open("/sys/kernel/extend_sched", O_RDWR);
> 	extend_map = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
> 
> I don't actually like this interface, as it wastes a full page for just two
> bits :-p  Perhaps it should be a new system call, where it just locks in
> existing memory from the user application? The requirement is that each
> thread needs its own bits to play with. It should not be shared with other
> threads. It could be, as it will not mess up the kernel, but will mess up
> the application.

What was wrong with using rseq?

> Anyway, to tell the kernel to "extend" the time slice if possible because
> it's in a critical section, we have:
> 
>  static void extend(void)
>  {
> 	if (!extend_map)
> 		return;
> 
> 	extend_map->flags = 1;
>  }
> 
> And to say that's it's done:
> 
>  static void unextend(void)
>  {
> 	unsigned long prev;
> 
> 	if (!extend_map)
> 		return;
> 
> 	prev = xchg(&extend_map->flags, 0);
> 	if (prev & 2)
> 		sched_yield();
>  }
> 
> So, bit 1 is for user space to tell the kernel "please extend me", and bit
> two is for the kernel to tell user space "OK, I extended you, but call
> sched_yield() when done".

So what if it doesn't ? Can we kill it for not playing nice ?

[ aside from it being bit 0 and bit 1 as you yourself point out, it is
  also jarring you use a numeral for one and write out the other. ]

That said, I properly hate all these things, extending a slice doesn't
reliably work and we're always left with people demanding an ever longer
extension.

The *much* better heuristic is what the kernel uses, don't spin if the
lock holder isn't running.




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux