2015-02-24 10:48:04

by Adrian Hunter

[permalink] [raw]
Subject: [PATCH] perf tools: Fix pthread_attr_setaffinity_np build error

Feature detection for pthread_attr_setaffinity_np was failing,
producing this error:

In file included from bench/futex-hash.c:17:0:
bench/futex.h:73:19: error: conflicting types for ‘pthread_attr_setaffinity_np’
static inline int pthread_attr_setaffinity_np(pthread_attr_t *attr,
^
In file included from bench/futex.h:72:0,
from bench/futex-hash.c:17:
/usr/include/pthread.h:407:12: note: previous declaration of ‘pthread_attr_setaffinity_np’ was here
extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
^
make[3]: *** [bench/futex-hash.o] Error 1
make[2]: *** [bench] Error 2
make[2]: *** Waiting for unfinished jobs....

This was because compiling test-pthread-attr-setaffinity-np.c
failed due to the function arguments:

test-pthread-attr-setaffinity-np.c: In function ‘main’:
test-pthread-attr-setaffinity-np.c:11:2: warning: null argument where non-null required (argument 3) [-Wnonnull]
ret = pthread_attr_setaffinity_np(&thread_attr, 0, NULL);
^
So fix the arguments.

Signed-off-by: Adrian Hunter <[email protected]>
---
tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c b/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
index 0a0d3ec..2b81b72 100644
--- a/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
+++ b/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
@@ -5,10 +5,11 @@ int main(void)
{
int ret = 0;
pthread_attr_t thread_attr;
+ cpu_set_t cs;

pthread_attr_init(&thread_attr);
/* don't care abt exact args, just the API itself in libpthread */
- ret = pthread_attr_setaffinity_np(&thread_attr, 0, NULL);
+ ret = pthread_attr_setaffinity_np(&thread_attr, sizeof(cs), &cs);

return ret;
}
--
1.9.1


2015-02-24 13:32:57

by Josh Boyer

[permalink] [raw]
Subject: Re: [PATCH] perf tools: Fix pthread_attr_setaffinity_np build error

On Tue, Feb 24, 2015 at 5:46 AM, Adrian Hunter <[email protected]> wrote:
> Feature detection for pthread_attr_setaffinity_np was failing,
> producing this error:
>
> In file included from bench/futex-hash.c:17:0:
> bench/futex.h:73:19: error: conflicting types for 'pthread_attr_setaffinity_np'
> static inline int pthread_attr_setaffinity_np(pthread_attr_t *attr,
> ^
> In file included from bench/futex.h:72:0,
> from bench/futex-hash.c:17:
> /usr/include/pthread.h:407:12: note: previous declaration of 'pthread_attr_setaffinity_np' was here
> extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
> ^
> make[3]: *** [bench/futex-hash.o] Error 1
> make[2]: *** [bench] Error 2
> make[2]: *** Waiting for unfinished jobs....
>
> This was because compiling test-pthread-attr-setaffinity-np.c
> failed due to the function arguments:
>
> test-pthread-attr-setaffinity-np.c: In function 'main':
> test-pthread-attr-setaffinity-np.c:11:2: warning: null argument where non-null required (argument 3) [-Wnonnull]
> ret = pthread_attr_setaffinity_np(&thread_attr, 0, NULL);
> ^
> So fix the arguments.

Erm, I sent a different fix for this a while ago. It's queued in some
-tip tree. The feature test wasn't defining _GNU_SOURCE, which is
required for pthread_attr_setaffinity_np. Once that was set (passed
via -D in the Makefile), the feature test worked fine.

Did you have to use your patch on top of the fix already queued?

josh

>
> Signed-off-by: Adrian Hunter <[email protected]>
> ---
> tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c b/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
> index 0a0d3ec..2b81b72 100644
> --- a/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
> +++ b/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
> @@ -5,10 +5,11 @@ int main(void)
> {
> int ret = 0;
> pthread_attr_t thread_attr;
> + cpu_set_t cs;
>
> pthread_attr_init(&thread_attr);
> /* don't care abt exact args, just the API itself in libpthread */
> - ret = pthread_attr_setaffinity_np(&thread_attr, 0, NULL);
> + ret = pthread_attr_setaffinity_np(&thread_attr, sizeof(cs), &cs);
>
> return ret;
> }
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2015-02-24 13:54:20

by Adrian Hunter

[permalink] [raw]
Subject: Re: [PATCH] perf tools: Fix pthread_attr_setaffinity_np build error

On 24/02/15 15:32, Josh Boyer wrote:
> On Tue, Feb 24, 2015 at 5:46 AM, Adrian Hunter <[email protected]> wrote:
>> Feature detection for pthread_attr_setaffinity_np was failing,
>> producing this error:
>>
>> In file included from bench/futex-hash.c:17:0:
>> bench/futex.h:73:19: error: conflicting types for 'pthread_attr_setaffinity_np'
>> static inline int pthread_attr_setaffinity_np(pthread_attr_t *attr,
>> ^
>> In file included from bench/futex.h:72:0,
>> from bench/futex-hash.c:17:
>> /usr/include/pthread.h:407:12: note: previous declaration of 'pthread_attr_setaffinity_np' was here
>> extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
>> ^
>> make[3]: *** [bench/futex-hash.o] Error 1
>> make[2]: *** [bench] Error 2
>> make[2]: *** Waiting for unfinished jobs....
>>
>> This was because compiling test-pthread-attr-setaffinity-np.c
>> failed due to the function arguments:
>>
>> test-pthread-attr-setaffinity-np.c: In function 'main':
>> test-pthread-attr-setaffinity-np.c:11:2: warning: null argument where non-null required (argument 3) [-Wnonnull]
>> ret = pthread_attr_setaffinity_np(&thread_attr, 0, NULL);
>> ^
>> So fix the arguments.
>
> Erm, I sent a different fix for this a while ago. It's queued in some
> -tip tree. The feature test wasn't defining _GNU_SOURCE, which is
> required for pthread_attr_setaffinity_np. Once that was set (passed
> via -D in the Makefile), the feature test worked fine.
>
> Did you have to use your patch on top of the fix already queued?

Yes.

The error (warning + Werror) I got definitely seemed to be about the use of
NULL as an argument.

>
> josh
>
>>
>> Signed-off-by: Adrian Hunter <[email protected]>
>> ---
>> tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c b/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
>> index 0a0d3ec..2b81b72 100644
>> --- a/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
>> +++ b/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
>> @@ -5,10 +5,11 @@ int main(void)
>> {
>> int ret = 0;
>> pthread_attr_t thread_attr;
>> + cpu_set_t cs;
>>
>> pthread_attr_init(&thread_attr);
>> /* don't care abt exact args, just the API itself in libpthread */
>> - ret = pthread_attr_setaffinity_np(&thread_attr, 0, NULL);
>> + ret = pthread_attr_setaffinity_np(&thread_attr, sizeof(cs), &cs);
>>
>> return ret;
>> }
>> --
>> 1.9.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at http://www.tux.org/lkml/
>
>

2015-02-24 14:31:25

by Josh Boyer

[permalink] [raw]
Subject: Re: [PATCH] perf tools: Fix pthread_attr_setaffinity_np build error

On Tue, Feb 24, 2015 at 8:52 AM, Adrian Hunter <[email protected]> wrote:
> On 24/02/15 15:32, Josh Boyer wrote:
>> On Tue, Feb 24, 2015 at 5:46 AM, Adrian Hunter <[email protected]> wrote:
>>> Feature detection for pthread_attr_setaffinity_np was failing,
>>> producing this error:
>>>
>>> In file included from bench/futex-hash.c:17:0:
>>> bench/futex.h:73:19: error: conflicting types for 'pthread_attr_setaffinity_np'
>>> static inline int pthread_attr_setaffinity_np(pthread_attr_t *attr,
>>> ^
>>> In file included from bench/futex.h:72:0,
>>> from bench/futex-hash.c:17:
>>> /usr/include/pthread.h:407:12: note: previous declaration of 'pthread_attr_setaffinity_np' was here
>>> extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
>>> ^
>>> make[3]: *** [bench/futex-hash.o] Error 1
>>> make[2]: *** [bench] Error 2
>>> make[2]: *** Waiting for unfinished jobs....
>>>
>>> This was because compiling test-pthread-attr-setaffinity-np.c
>>> failed due to the function arguments:
>>>
>>> test-pthread-attr-setaffinity-np.c: In function 'main':
>>> test-pthread-attr-setaffinity-np.c:11:2: warning: null argument where non-null required (argument 3) [-Wnonnull]
>>> ret = pthread_attr_setaffinity_np(&thread_attr, 0, NULL);
>>> ^
>>> So fix the arguments.
>>
>> Erm, I sent a different fix for this a while ago. It's queued in some
>> -tip tree. The feature test wasn't defining _GNU_SOURCE, which is
>> required for pthread_attr_setaffinity_np. Once that was set (passed
>> via -D in the Makefile), the feature test worked fine.
>>
>> Did you have to use your patch on top of the fix already queued?
>
> Yes.
>
> The error (warning + Werror) I got definitely seemed to be about the use of
> NULL as an argument.

Hm, ok. Which compiler/glibc are you using? Curious that I'm not
seeing that issue.

josh

2015-02-25 06:50:39

by Adrian Hunter

[permalink] [raw]
Subject: Re: [PATCH] perf tools: Fix pthread_attr_setaffinity_np build error

On 24/02/2015 4:31 p.m., Josh Boyer wrote:
> On Tue, Feb 24, 2015 at 8:52 AM, Adrian Hunter <[email protected]> wrote:
>> On 24/02/15 15:32, Josh Boyer wrote:
>>> On Tue, Feb 24, 2015 at 5:46 AM, Adrian Hunter <[email protected]> wrote:
>>>> Feature detection for pthread_attr_setaffinity_np was failing,
>>>> producing this error:
>>>>
>>>> In file included from bench/futex-hash.c:17:0:
>>>> bench/futex.h:73:19: error: conflicting types for 'pthread_attr_setaffinity_np'
>>>> static inline int pthread_attr_setaffinity_np(pthread_attr_t *attr,
>>>> ^
>>>> In file included from bench/futex.h:72:0,
>>>> from bench/futex-hash.c:17:
>>>> /usr/include/pthread.h:407:12: note: previous declaration of 'pthread_attr_setaffinity_np' was here
>>>> extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
>>>> ^
>>>> make[3]: *** [bench/futex-hash.o] Error 1
>>>> make[2]: *** [bench] Error 2
>>>> make[2]: *** Waiting for unfinished jobs....
>>>>
>>>> This was because compiling test-pthread-attr-setaffinity-np.c
>>>> failed due to the function arguments:
>>>>
>>>> test-pthread-attr-setaffinity-np.c: In function 'main':
>>>> test-pthread-attr-setaffinity-np.c:11:2: warning: null argument where non-null required (argument 3) [-Wnonnull]
>>>> ret = pthread_attr_setaffinity_np(&thread_attr, 0, NULL);
>>>> ^
>>>> So fix the arguments.
>>>
>>> Erm, I sent a different fix for this a while ago. It's queued in some
>>> -tip tree. The feature test wasn't defining _GNU_SOURCE, which is
>>> required for pthread_attr_setaffinity_np. Once that was set (passed
>>> via -D in the Makefile), the feature test worked fine.
>>>
>>> Did you have to use your patch on top of the fix already queued?
>>
>> Yes.
>>
>> The error (warning + Werror) I got definitely seemed to be about the use of
>> NULL as an argument.
>
> Hm, ok. Which compiler/glibc are you using? Curious that I'm not
> seeing that issue.

4.8.2

You could also see if you have the __nonnull attribute in the header e.g.

extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
size_t __cpusetsize,
const cpu_set_t *__cpuset)
__THROW __nonnull ((1, 3));