linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Little bug in cyclictest
@ 2019-08-14 12:07 Rachid Koucha
  2019-08-14 13:25 ` John Kacur
  0 siblings, 1 reply; 4+ messages in thread
From: Rachid Koucha @ 2019-08-14 12:07 UTC (permalink / raw)
  To: williams, jkacur; +Cc: linux-rt-users

Hi,

First of all, many thanks for such useful tools.

In the source code of cyclictest, I can see a mistake concerning the
error checking of pthread_setaffinity_np():

Upon error, pthread functions return an error ant not -1. So, the
following code:

    if (par->cpu != -1) {
        CPU_ZERO(&mask);
        CPU_SET(par->cpu, &mask);
        thread = pthread_self();
        if (pthread_setaffinity_np(thread, sizeof(mask), &mask) == -1)
            warn("Could not set CPU affinity to CPU #%d\n",
                 par->cpu);
    }

should be fixed as follow:

int status;

    if (par->cpu != -1) {
        CPU_ZERO(&mask);
        CPU_SET(par->cpu, &mask);
        thread = pthread_self();
        if ((status = pthread_setaffinity_np(thread, sizeof(mask), &mask)) != 0)
            warn("Could not set CPU affinity to CPU #%d: %s (%d)\n",                  par->cpu, strerror(status), status);
    }


Regards,

-- 
Rachid Koucha
 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-08-15 13:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-14 12:07 Little bug in cyclictest Rachid Koucha
2019-08-14 13:25 ` John Kacur
2019-08-14 18:41   ` Rachid Koucha
2019-08-15 13:49     ` John Kacur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).