From: Thomas Petazzoni Date: Sun, 29 Dec 2013 17:03:55 +0000 (+0100) Subject: iozone: add fix for missing pthread_setaffinity_np() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8bc28f5be004d9c3bc033b2bc394e5b92c942d38;p=buildroot.git iozone: add fix for missing pthread_setaffinity_np() The iozone code uses the pthread_setaffinity_np() function, but with uClibc this function is only available when the NPTL thread implementation is used. Some architectures, such as AVR32 and ARC do not support the NPTL thread implementation, and therefore lack the pthread_setaffinity_np() function. This commit adds a patch that provides an empty implementation of pthread_setaffinity_np() when we're using uClibc, but not with the NPTL thread implementation. The reasoning is that there is a very high chance that the few architectures that do not implement NPTL are non-SMP architectures, and therefore setting the affinity is not very useful. In addition to this, this commit: * Renames the existing patch to use a sequence number, in order to guarantee a proper ordering when applying patches. * Removes the Kconfig dependency on !uClibc 0.9.31, which was introduced to prevent AVR32 from failing due to the pthread_setaffinity_np(). This conditional is no longer necessary due to the new patch, and the conditional was anyway not completely working since it was not taking into account the case of external toolchains. Signed-off-by: Thomas Petazzoni --- diff --git a/package/iozone/Config.in b/package/iozone/Config.in index 33e12ca77c..26d4daafe0 100644 --- a/package/iozone/Config.in +++ b/package/iozone/Config.in @@ -1,7 +1,6 @@ config BR2_PACKAGE_IOZONE bool "iozone" depends on BR2_USE_MMU # fork() - depends on !BR2_UCLIBC_VERSION_0_9_31 # no pthread_setaffinity_np help IOzone is a filesystem benchmark tool. The benchmark generates and measures a variety of file operations diff --git a/package/iozone/iozone-01-targets.patch b/package/iozone/iozone-01-targets.patch new file mode 100644 index 0000000000..258b960928 --- /dev/null +++ b/package/iozone/iozone-01-targets.patch @@ -0,0 +1,92 @@ +Add new targets for iozone: + +linux-noaio is for linux targets without AIO (use case: uClibc) +linux-noth is for linux target without threads or AIO + +And make largefile support optional via CFLAGS. + +Signed-off-by: Gustavo Zacarias + +diff -Nura iozone3_414.orig/src/current/makefile iozone3_414/src/current/makefile +--- iozone3_414.orig/src/current/makefile 2013-06-11 09:48:18.257837091 -0300 ++++ iozone3_414/src/current/makefile 2013-06-11 13:05:56.338162144 -0300 +@@ -166,10 +166,28 @@ + # GNU 'C' compiler Linux build with threads, largefiles, async I/O + # + linux: iozone_linux.o libasync.o libbif.o fileop_linux.o pit_server.o +- $(CC) -O3 $(LDFLAGS) iozone_linux.o libasync.o libbif.o -lpthread \ ++ $(CC) $(CFLAGS) $(LDFLAGS) iozone_linux.o libasync.o libbif.o \ ++ -lpthread -lrt -o iozone ++ $(CC) $(CFLAGS) -Dlinux fileop_linux.o -o fileop ++ $(CC) $(CFLAGS) -Dlinux pit_server.o -o pit_server ++ ++# ++# GNU 'C' compiler Linux build with threads, largefiles ++# ++linux-noaio: iozone_linux-noaio.o libbif.o fileop_linux.o pit_server.o ++ $(CC) $(CFLAGS) $(LDFLAGS) iozone_linux-noaio.o libbif.o \ ++ -lpthread -lrt -o iozone ++ $(CC) $(CFLAGS) -Dlinux fileop_linux.o -o fileop ++ $(CC) $(CFLAGS) -Dlinux pit_server.o -o pit_server ++ ++# ++# GNU 'C' compiler Linux build with largefiles ++# ++linux-noth: iozone_linux-noth.o libbif.o fileop_linux.o pit_server.o ++ $(CC) $(CFLAGS) $(LDFLAGS) iozone_linux-noth.o libbif.o \ + -lrt -o iozone +- $(CC) -O3 -Dlinux fileop_linux.o -o fileop +- $(CC) -O3 -Dlinux pit_server.o -o pit_server ++ $(CC) $(CFLAGS) -Dlinux fileop_linux.o -o fileop ++ $(CC) $(CFLAGS) -Dlinux pit_server.o -o pit_server + + # + # GNU 'C' compiler Linux build for powerpc chip with threads, largefiles, async I/O +@@ -795,13 +813,33 @@ + @echo "" + @echo "Building iozone for Linux" + @echo "" +- $(CC) -Wall -c -O3 -Dunix -DHAVE_ANSIC_C -DASYNC_IO -DHAVE_PREAD \ +- -DSHARED_MEM -Dlinux -D_LARGEFILE64_SOURCE $(CFLAGS) iozone.c \ ++ $(CC) -Wall -c -Dunix -DHAVE_ANSIC_C -DASYNC_IO -DHAVE_PREAD \ ++ -DSHARED_MEM -Dlinux $(CFLAGS) iozone.c \ + -DNAME='"linux"' -o iozone_linux.o +- $(CC) -Wall -c -O3 -Dunix -DHAVE_ANSIC_C -DASYNC_IO -D_LARGEFILE64_SOURCE \ ++ $(CC) -Wall -c -Dunix -DHAVE_ANSIC_C -DASYNC_IO \ ++ -DSHARED_MEM -Dlinux $(CFLAGS) libbif.c -o libbif.o ++ $(CC) -Wall -c -Dunix -Dlinux -DHAVE_ANSIC_C -DASYNC_IO \ ++ $(CFLAGS) libasync.c -o libasync.o ++ ++iozone_linux-noaio.o: iozone.c libbif.c ++ @echo "" ++ @echo "Building iozone for Linux no AIO" ++ @echo "" ++ $(CC) -Wall -c -Dunix -DHAVE_ANSIC_C -DHAVE_PREAD \ ++ -DSHARED_MEM -Dlinux $(CFLAGS) iozone.c \ ++ -DNAME='"linux"' -o iozone_linux-noaio.o ++ $(CC) -Wall -c -Dunix -DHAVE_ANSIC_C \ ++ -DSHARED_MEM -Dlinux $(CFLAGS) libbif.c -o libbif.o ++ ++iozone_linux-noth.o: iozone.c libbif.c ++ @echo "" ++ @echo "Building iozone for Linux with no threads" ++ @echo "" ++ $(CC) -Wall -c -Dunix -DHAVE_ANSIC_C -DNO_THREADS -DHAVE_PREAD \ ++ -DSHARED_MEM -Dlinux $(CFLAGS) iozone.c \ ++ -DNAME='"linux"' -o iozone_linux-noth.o ++ $(CC) -Wall -c -Dunix -DHAVE_ANSIC_C -DNO_THREADS \ + -DSHARED_MEM -Dlinux $(CFLAGS) libbif.c -o libbif.o +- $(CC) -Wall -c -O3 -Dunix -Dlinux -DHAVE_ANSIC_C -DASYNC_IO \ +- -D_LARGEFILE64_SOURCE $(CFLAGS) libasync.c -o libasync.o + + fileop_AIX.o: fileop.c + @echo "" +@@ -893,7 +931,7 @@ + @echo "" + @echo "Building fileop for Linux" + @echo "" +- $(CC) -Wall -c -O3 $(CFLAGS) fileop.c -o fileop_linux.o ++ $(CC) -Wall -c $(CFLAGS) fileop.c -o fileop_linux.o + + fileop_openbsd.o: fileop.c + @echo "" diff --git a/package/iozone/iozone-02-no-nptl-support.patch b/package/iozone/iozone-02-no-nptl-support.patch new file mode 100644 index 0000000000..493f52cc77 --- /dev/null +++ b/package/iozone/iozone-02-no-nptl-support.patch @@ -0,0 +1,37 @@ +Dummy pthread_setaffinity_np() when not available + +On uClibc configurations that do not use the NPTL thread +implementation, pthread_setaffinity_np() is not available. This patch +defines a dummy (empty) implementation of this function for such +cases. + +The only few architectures that do not provide the NPTL thread +implementation are very likely to be non-SMP architectures, and +therefore, setting the affinity of the thread is not doing anything +useful, so having an empty stub for pthread_setaffinity_np() is not a +problem. + +Signed-off-by: Thomas Petazzoni + +Index: b/src/current/iozone.c +=================================================================== +--- a/src/current/iozone.c ++++ b/src/current/iozone.c +@@ -306,6 +306,17 @@ + #endif + #endif + ++#if defined (__linux__) ++#include ++#if defined (__UCLIBC__) && !defined (__UCLIBC_HAS_THREADS_NATIVE__) ++static int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize, ++ const cpu_set_t *cpuset) ++{ ++ return 0; ++} ++#endif ++#endif ++ + #if ((defined(solaris) && defined(__LP64__)) || defined(__s390x__)) + /* If we are building for 64-bit Solaris, all functions that return pointers + * must be declared before they are used; otherwise the compiler will assume diff --git a/package/iozone/iozone-targets.patch b/package/iozone/iozone-targets.patch deleted file mode 100644 index 258b960928..0000000000 --- a/package/iozone/iozone-targets.patch +++ /dev/null @@ -1,92 +0,0 @@ -Add new targets for iozone: - -linux-noaio is for linux targets without AIO (use case: uClibc) -linux-noth is for linux target without threads or AIO - -And make largefile support optional via CFLAGS. - -Signed-off-by: Gustavo Zacarias - -diff -Nura iozone3_414.orig/src/current/makefile iozone3_414/src/current/makefile ---- iozone3_414.orig/src/current/makefile 2013-06-11 09:48:18.257837091 -0300 -+++ iozone3_414/src/current/makefile 2013-06-11 13:05:56.338162144 -0300 -@@ -166,10 +166,28 @@ - # GNU 'C' compiler Linux build with threads, largefiles, async I/O - # - linux: iozone_linux.o libasync.o libbif.o fileop_linux.o pit_server.o -- $(CC) -O3 $(LDFLAGS) iozone_linux.o libasync.o libbif.o -lpthread \ -+ $(CC) $(CFLAGS) $(LDFLAGS) iozone_linux.o libasync.o libbif.o \ -+ -lpthread -lrt -o iozone -+ $(CC) $(CFLAGS) -Dlinux fileop_linux.o -o fileop -+ $(CC) $(CFLAGS) -Dlinux pit_server.o -o pit_server -+ -+# -+# GNU 'C' compiler Linux build with threads, largefiles -+# -+linux-noaio: iozone_linux-noaio.o libbif.o fileop_linux.o pit_server.o -+ $(CC) $(CFLAGS) $(LDFLAGS) iozone_linux-noaio.o libbif.o \ -+ -lpthread -lrt -o iozone -+ $(CC) $(CFLAGS) -Dlinux fileop_linux.o -o fileop -+ $(CC) $(CFLAGS) -Dlinux pit_server.o -o pit_server -+ -+# -+# GNU 'C' compiler Linux build with largefiles -+# -+linux-noth: iozone_linux-noth.o libbif.o fileop_linux.o pit_server.o -+ $(CC) $(CFLAGS) $(LDFLAGS) iozone_linux-noth.o libbif.o \ - -lrt -o iozone -- $(CC) -O3 -Dlinux fileop_linux.o -o fileop -- $(CC) -O3 -Dlinux pit_server.o -o pit_server -+ $(CC) $(CFLAGS) -Dlinux fileop_linux.o -o fileop -+ $(CC) $(CFLAGS) -Dlinux pit_server.o -o pit_server - - # - # GNU 'C' compiler Linux build for powerpc chip with threads, largefiles, async I/O -@@ -795,13 +813,33 @@ - @echo "" - @echo "Building iozone for Linux" - @echo "" -- $(CC) -Wall -c -O3 -Dunix -DHAVE_ANSIC_C -DASYNC_IO -DHAVE_PREAD \ -- -DSHARED_MEM -Dlinux -D_LARGEFILE64_SOURCE $(CFLAGS) iozone.c \ -+ $(CC) -Wall -c -Dunix -DHAVE_ANSIC_C -DASYNC_IO -DHAVE_PREAD \ -+ -DSHARED_MEM -Dlinux $(CFLAGS) iozone.c \ - -DNAME='"linux"' -o iozone_linux.o -- $(CC) -Wall -c -O3 -Dunix -DHAVE_ANSIC_C -DASYNC_IO -D_LARGEFILE64_SOURCE \ -+ $(CC) -Wall -c -Dunix -DHAVE_ANSIC_C -DASYNC_IO \ -+ -DSHARED_MEM -Dlinux $(CFLAGS) libbif.c -o libbif.o -+ $(CC) -Wall -c -Dunix -Dlinux -DHAVE_ANSIC_C -DASYNC_IO \ -+ $(CFLAGS) libasync.c -o libasync.o -+ -+iozone_linux-noaio.o: iozone.c libbif.c -+ @echo "" -+ @echo "Building iozone for Linux no AIO" -+ @echo "" -+ $(CC) -Wall -c -Dunix -DHAVE_ANSIC_C -DHAVE_PREAD \ -+ -DSHARED_MEM -Dlinux $(CFLAGS) iozone.c \ -+ -DNAME='"linux"' -o iozone_linux-noaio.o -+ $(CC) -Wall -c -Dunix -DHAVE_ANSIC_C \ -+ -DSHARED_MEM -Dlinux $(CFLAGS) libbif.c -o libbif.o -+ -+iozone_linux-noth.o: iozone.c libbif.c -+ @echo "" -+ @echo "Building iozone for Linux with no threads" -+ @echo "" -+ $(CC) -Wall -c -Dunix -DHAVE_ANSIC_C -DNO_THREADS -DHAVE_PREAD \ -+ -DSHARED_MEM -Dlinux $(CFLAGS) iozone.c \ -+ -DNAME='"linux"' -o iozone_linux-noth.o -+ $(CC) -Wall -c -Dunix -DHAVE_ANSIC_C -DNO_THREADS \ - -DSHARED_MEM -Dlinux $(CFLAGS) libbif.c -o libbif.o -- $(CC) -Wall -c -O3 -Dunix -Dlinux -DHAVE_ANSIC_C -DASYNC_IO \ -- -D_LARGEFILE64_SOURCE $(CFLAGS) libasync.c -o libasync.o - - fileop_AIX.o: fileop.c - @echo "" -@@ -893,7 +931,7 @@ - @echo "" - @echo "Building fileop for Linux" - @echo "" -- $(CC) -Wall -c -O3 $(CFLAGS) fileop.c -o fileop_linux.o -+ $(CC) -Wall -c $(CFLAGS) fileop.c -o fileop_linux.o - - fileop_openbsd.o: fileop.c - @echo ""