perf tools: Fix pthread_attr_setaffinity_np build error
Adrian Hunter
reviewerPATCH 1/1 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.
--- tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c +2 -1
@@ -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; }
Signature · 1 line
1.9.1
Quoted 16 lines · Adrian Hunter
Feature detection for
pthread_attr_setaffinity_npwas 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....
Quoted 8 lines
This was because compiling
test-pthread-attr-setaffinity-np.cfailed 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
Quoted 31 lines
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(-)tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c +2
-2@@ -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/
Adrian Hunter
reviewerQuoted 26 lines · Josh Boyer
Quoted 16 lines · Adrian Hunter
Feature detection for
pthread_attr_setaffinity_npwas 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....Quoted 8 lines
This was because compiling
test-pthread-attr-setaffinity-np.cfailed 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.
Quoted 6 lines
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 forpthread_attr_setaffinity_np. Once that was set (passed via -D in theMakefile), 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.
Quoted 36 lines
josh
Quoted 31 lines
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(-)tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c +2
-2@@ -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/
Quoted 32 lines · Adrian Hunter
Quoted 31 lines · Josh Boyer
Quoted 16 lines · Adrian Hunter
Feature detection for
pthread_attr_setaffinity_npwas 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....Quoted 8 lines
This was because compiling
test-pthread-attr-setaffinity-np.cfailed 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 forpthread_attr_setaffinity_np. Once that was set (passed via -D in theMakefile), the feature test worked fine.
Quoted 6 lines
Quoted 1 line
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
Adrian Hunter
reviewerQuoted 35 lines · Josh Boyer
Quoted 34 lines · Adrian Hunter
Quoted 32 lines · Josh Boyer
Quoted 16 lines · Adrian Hunter
Feature detection for
pthread_attr_setaffinity_npwas 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....Quoted 8 lines
This was because compiling
test-pthread-attr-setaffinity-np.cfailed 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 forpthread_attr_setaffinity_np. Once that was set (passed via -D in theMakefile), the feature test worked fine.Did you have to use your patch on top of the fix already queued?
Quoted 7 lines
Quoted 4 lines
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));
tip-bot for Adrian Hunter
merge botperf tools: Fix pthread_attr_setaffinity_np build error
Commit-ID: 95a09cfa3cdf94231ce511f1697754482b918d39 Gitweb: http://git.kernel.org/tip/95a09cfa3cdf94231ce511f1697754482b918d39 Author: Adrian Hunter <[email protected]> AuthorDate: Tue, 24 Feb 2015 12:46:06 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 25 Feb 2015 12:18:03 -0300
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.
--- tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c +2 -1
@@ -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; }
tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c int main(void) · line 12
Quoted 12 lines · tip-bot for Adrian Hunter
tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c +2
-1@@ -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);
So I'm splitting hairs, as we never run these testcases, but I think a CPU_ZERO(&cs) is needed, as 'cs' might be uninitialized.
Thanks,
Ingo
Adrian Hunter
reviewerPATCH 1/1 perf tools: Initialize cpu set in pthread_attr_setaffinity_np feature test
Feature tests are compiled but not executed, however it might avoid a future uninitialized variable warning, so initialize the cpu set.
--- tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c +3 -1
@@ -1,5 +1,6 @@#include <stdint.h> #include <pthread.h> +#include <sched.h> int main (void ) {
@@ -8,7 +9,8 @@ int main(void)cpu_set_t cs;pthread_attr_init (&thread_attr); -/* don't care abt exact args, just the API itself in libpthread */ +CPU_ZERO (&cs); + ret =pthread_attr_setaffinity_np (&thread_attr,sizeof (cs), &cs);return ret;
Signature · 1 line
1.9.1
tip-bot for Adrian Hunter
merge bot[tip:perf/core] perf tools: Initialize cpu set in pthread_attr_setaffinity_np feature test
perf tools: Initialize cpu set in pthread_attr_setaffinity_np feature test
Commit-ID: 543d976fa2ebf5543bd07b5d487bf3a6144c0886 Gitweb: http://git.kernel.org/tip/543d976fa2ebf5543bd07b5d487bf3a6144c0886 Author: Adrian Hunter <[email protected]> AuthorDate: Mon, 2 Mar 2015 09:59:05 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 2 Mar 2015 12:48:16 -0300
perf tools: Initialize cpu set in pthread_attr_setaffinity_np feature test
Feature tests are compiled but not executed, however it might avoid a future uninitialized variable warning, so initialize the cpu set.
--- tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c +3 -1
@@ -1,5 +1,6 @@#include <stdint.h> #include <pthread.h> +#include <sched.h> int main (void ) {
@@ -8,7 +9,8 @@ int main(void)cpu_set_t cs;pthread_attr_init (&thread_attr); -/* don't care abt exact args, just the API itself in libpthread */ +CPU_ZERO (&cs); + ret =pthread_attr_setaffinity_np (&thread_attr,sizeof (cs), &cs);return ret;