Linux-rt-users archive on lore.kernel.org
 help / color / 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

* Re: Little bug in cyclictest
  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
  0 siblings, 1 reply; 4+ messages in thread
From: John Kacur @ 2019-08-14 13:25 UTC (permalink / raw)
  To: Rachid Koucha; +Cc: williams, linux-rt-users

[-- Attachment #1: Type: text/plain, Size: 1217 bytes --]



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

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

* Re: Little bug in cyclictest
  2019-08-14 13:25 ` John Kacur
@ 2019-08-14 18:41   ` Rachid Koucha
  2019-08-15 13:49     ` John Kacur
  0 siblings, 1 reply; 4+ messages in thread
From: Rachid Koucha @ 2019-08-14 18:41 UTC (permalink / raw)
  To: John Kacur; +Cc: williams, linux-rt-users

[-- 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 --]

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

* Re: Little bug in cyclictest
  2019-08-14 18:41   ` Rachid Koucha
@ 2019-08-15 13:49     ` John Kacur
  0 siblings, 0 replies; 4+ messages in thread
From: John Kacur @ 2019-08-15 13:49 UTC (permalink / raw)
  To: Rachid Koucha; +Cc: williams, linux-rt-users

[-- Attachment #1: Type: text/plain, Size: 2045 bytes --]



On Wed, 14 Aug 2019, Rachid Koucha wrote:

> 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
> 

It would be easy for me to take the attachment and apply the patch, but if 
you want to work or play in the open source world, you have to follow 
certain rules for submitting patches.

The Linux Kernel source has a lot of documentation on how to do this, look 
here if you don't know how to access that

https://www.kernel.org/doc/html/v5.0/process/submitting-patches.html

So, you're going to need to describe the changes, and give your 
signed-off-by and no attachments, you have to use plain text.

Thanks!

John Kacur

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

end of thread, back to index

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

Linux-rt-users archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rt-users/0 linux-rt-users/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rt-users linux-rt-users/ https://lore.kernel.org/linux-rt-users \
		linux-rt-users@vger.kernel.org linux-rt-users@archiver.kernel.org
	public-inbox-index linux-rt-users


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rt-users


AGPL code for this site: git clone https://public-inbox.org/ public-inbox