From: Rachid Koucha <rachid.koucha@gmail.com>
To: John Kacur <jkacur@redhat.com>
Cc: williams@redhat.com, linux-rt-users@vger.kernel.org
Subject: Re: Little bug in cyclictest
Date: Wed, 14 Aug 2019 20:41:22 +0200 [thread overview]
Message-ID: <7e292a1e-b52d-e8c6-37b0-05270df81539@gmail.com> (raw)
In-Reply-To: <alpine.LFD.2.21.1908141524020.5420@planxty>
[-- Attachment #1: Type: text/plain, Size: 1389 bytes --]
Find attach the patch file :
$ cd rt-tests
$ patch -p1 < ../cyclictest_affinity_check.patch
On 14/08/2019 15:25, John Kacur wrote:
>
> On Wed, 14 Aug 2019, Rachid Koucha wrote:
>
>> 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,
>>
> Thanks, that looks correct. Please generate a patch and I'll apply it.
>
> John Kacur
--
[-- Attachment #2: cyclictest_affinity_check.patch --]
[-- Type: text/x-diff, Size: 833 bytes --]
--- old_rt-tests/src/cyclictest/cyclictest.c 2019-08-14 20:28:48.547725419 +0200
+++ new_rt-tests/src/cyclictest/cyclictest.c 2019-08-14 20:20:58.415297592 +0200
@@ -985,6 +985,7 @@
cpu_set_t mask;
pthread_t thread;
unsigned long smi_now, smi_old;
+ int status;
/* if we're running in numa mode, set our memory node */
if (par->node != -1)
@@ -994,9 +995,9 @@
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);
+ 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);
}
interval.tv_sec = par->interval / USEC_PER_SEC;
next prev parent reply other threads:[~2019-08-14 18:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2019-08-15 13:49 ` John Kacur
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7e292a1e-b52d-e8c6-37b0-05270df81539@gmail.com \
--to=rachid.koucha@gmail.com \
--cc=jkacur@redhat.com \
--cc=linux-rt-users@vger.kernel.org \
--cc=williams@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).