affinity of main thread is bound to current core

Lange Norbert norbert.lange at andritz.com
Thu Aug 22 17:16:25 CEST 2019


> -----Original Message-----
> From: Jan Kiszka <jan.kiszka at siemens.com>
> Sent: Donnerstag, 22. August 2019 16:52
> To: Lange Norbert <norbert.lange at andritz.com>; Xenomai
> (xenomai at xenomai.org) <xenomai at xenomai.org>
> Subject: Re: affinity of main thread is bound to current core
>
> E-MAIL FROM A NON-ANDRITZ SOURCE: AS A SECURITY MEASURE, PLEASE
> EXERCISE CAUTION WITH E-MAIL CONTENT AND ANY LINKS OR
> ATTACHMENTS.
>
>
> On 21.08.19 14:12, Lange Norbert via Xenomai wrote:
> > Hello,
> >
> > I use Xenomai master on ipipe-core-4.19.60-x86-5.
> > I start out with an affinity mask of 0xF, in the function cobalt_init_2,
> pthread_setschedparam will get called, after the syscall
> sc_cobalt_thread_setschedparam_ex the affinity mask will contain a single
> CPU (supposedly the current one).
> >
> > All methods to control affinity are executed before this point (cmdline args,
> /proc/xenomai/affinity), so there is no working way to control it.
> >
>
> Not sure I get the problem yet: "some-xenomai-app --cpu-affinity X" seems
> to work fine, so does setting /proc/xenomai/affinity. Can you describe more
> concretely what behaves unexpectedly, maybe with a test case?

Well, it does not work for me.

------------------ file test.c
#define _GNU_SOURCE
#include <stdio.h>

#include <sched.h>
#include <pthread.h>

static void printaff()
{
    cpu_set_t cpuset;
    pthread_getaffinity_np(pthread_self(), sizeof(cpuset), &cpuset);
    printf("Affinity: ");
    for(unsigned i = 0; i < 256; ++i)
    {
        if(CPU_ISSET(i, &cpuset))
            printf("%u,", i);
    }
    printf("\n");
}

int main(int argc, char const *argv[])
{
printaff();
return 0;
}
------------------

root at buildroot:~# cat /proc/xenomai/affinity
0000000f

root at buildroot:~# /tmp/a.out
Affinity: 2,

root at buildroot:~# /tmp/a.out app --cpu-affinity 0,1,2,3
Affinity: 3,

I traced the point where affinity collapsed to the
sc_cobalt_thread_setschedparam_ex call.

Norbert
________________________________

This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.

ANDRITZ HYDRO GmbH


Rechtsform/ Legal form: Gesellschaft mit beschränkter Haftung / Corporation

Firmensitz/ Registered seat: Wien

Firmenbuchgericht/ Court of registry: Handelsgericht Wien

Firmenbuchnummer/ Company registration: FN 61833 g

DVR: 0605077

UID-Nr.: ATU14756806


Thank You
________________________________


More information about the Xenomai mailing list