Affinity and Scheduler Instance Interaction

Sebastian Huber sebastian.huber at embedded-brains.de
Wed May 21 14:13:55 UTC 2014


On 2014-05-21 16:00, Joel Sherrill wrote:
> Hi
>
> We have an SMP behavioral decision to make and it isn't getting
> enough discussion.
>
> With cluster scheduling, there are potentially multiple scheduler
> instances associated with non-overlapping subsets of cores.
>
> With affinity, a thread can be restricted to execute on a subset
> of the cores associated with a scheduler instance.
>
> There are operations to change the scheduler associated with
> a thread and the affinity of a thread.
>
> The question is whether changing affinity should be able to
> implicitly change the scheduler instance?
>
> I lean to no because affinity and scheduler changes should
> should be so rare in practical use that nothing should be
> implicit.

The pthread_setaffinity_np() is the only way to set the scheduler via the 
non-portable POSIX API.  So I would keep the ability to change the scheduler 
with it.

How would you change the scheduler with the non-portable POSIX API?

>
> Consider this scenario:
>
> Scheduler A: cores 0-1
> Scheduler B: cores 2-3
>
> Thread 1 is associated with Scheduler B and with affinity 2-3
> can run on either processor scheduled by B.
>
> Thread 1 changes affinity 1-3. Should this change the scheduler,
> be an error, or just have an affinity for a core in the system
> that is not scheduled by this scheduler instance?

This is currently an error:

http://git.rtems.org/rtems/tree/testsuites/smptests/smpscheduler02/init.c#n141

>
> If you look at the current code for _Scheduler_Set_affinity(),
> it looks like the current behavior is none of the above and
> appears to just be broken. Scheduler A's set affinity operation
> is invoked and Scheduler B is not informed that it no longer
> has control of Thread 1.
>

It is informed in case _Scheduler_default_Set_affinity_body() is used.  What is 
broken is the _Scheduler_priority_affinity_SMP_Set_affinity() function.

Please have a look at the attached patch which I already sent to a similar thread.

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-score-_Scheduler_Set_affinity.patch
Type: text/x-patch
Size: 4898 bytes
Desc: not available
URL: <http://lists.rtems.org/pipermail/devel/attachments/20140521/b8baa02b/attachment.bin>


More information about the devel mailing list