On 2011-08-25 10:33, Martin Steigerwald wrote: > Hi! > > I am putting upstream author Jens Axboe on CC. > > Am Donnerstag, 25. August 2011 schrieb Nobuhiro Iwamatsu: >> Hi, > [...] >> >> 2011/8/3 Martin Steigerwald <m...@teamix.de>: >>> Hello Nobuhiro, Paul, hello Debian SuperH maintainers, hello Jens, >>> >>> I am seeking information on the current status regarding >>> >>> Please support sh4 >>> http://bugs.debian.org/561891 >>> >>> and eventually help in resolving it if it has not already been >>> resolved. >>> >>> When I am reading >>> >>> http://buildd.debian-ports.org/status/package.php?p=fio&suite=unstabl >>> e >>> >>> correctly, then fio 1.50-1 has been build 167d before on buildd >>> kongou. >>> >>> So is this issue resolved? >>> >>> If not, please offer help. There is a partial patch mentioned earlier >>> in the bug report. >> >> By this method, we cannot support both SH4 and SH4A. When we build >> with machine of SH4A, a binary to work only in SH4A is built. >> Because Debian SH team are supporting sh4 and sh4a in one binary, this >> becomes the problem. >> And this is a problem peculiar to Debian. It will not become the >> problem in other distribution. (e.g., Gentoo) >> It is necessary to check whether you do not do it whether we support >> synco when we support both CPU's when we execute *_barrier. >> I think that this has a big overhead. >> >> I attached quick hack patch. > > Jens, what do you think about such a patch? Please advice. > > Nobuhiro, where do you think comes the big overhead from? In your patch > you check once at beginning for sinco capability. Do you refer to the if > statement you added in arch/arch-sh.h? > > Ciao,
How about something like the below, it's a bit more cleanly implemented? It still has the branch overhead per memory barrier, but I would not worry about that too much. diff --git a/arch/arch-sh.h b/arch/arch-sh.h index 08c5fb3..ef4ee03 100644 --- a/arch/arch-sh.h +++ b/arch/arch-sh.h @@ -22,13 +22,38 @@ #define nop __asm__ __volatile__ ("nop": : :"memory") -#if defined(__SH4A__) -#define mb() __asm__ __volatile__ ("synco": : :"memory") -#else -#define mb() __asm__ __volatile__ (" " : : : "memory") -#endif +#define mb() \ + do { \ + if (arch_flags & ARCH_FLAG_1) \ + __asm__ __volatile__ ("synco": : :"memory"); \ + else \ + __asm__ __volatile__ (" " : : : "memory"); \ + } while (0) #define read_barrier() mb() #define write_barrier() mb() +#define CPU_HAS_LLSC 0x0040 + +static inline int arch_init(char *envp[]) +{ + Elf32_auxv_t *auxv; + + while (*envp++ != NULL) + ; + + for (auxv = (Elf32_auxv_t *) envp; auxv->a_type != AT_NULL; auxv++) { + if (auxv->a_type == AT_HWCAP) { + if (auxv->a_un.a_val & CPU_HAS_LLSC) { + arch_flags |= ARCH_FLAG_1; + break; + } + } + } + + return 0; +} + +#define ARCH_HAVE_INIT + #endif diff --git a/arch/arch.h b/arch/arch.h index 8cafa11..16f4c3a 100644 --- a/arch/arch.h +++ b/arch/arch.h @@ -58,4 +58,18 @@ enum { #include "../lib/ffz.h" #endif +#ifndef ARCH_HAVE_INIT +static inline int arch_init(char *envp[]) +{ + return 0; +} +#endif + +enum { + ARCH_FLAG_1 = 1 << 0, + ARCH_FLAG_2 = 1 << 1, + ARCH_FLAG_3 = 1 << 2, + ARCH_FLAG_4 = 1 << 3, +}; + #endif diff --git a/fio.c b/fio.c index 7396421..9c1bed3 100644 --- a/fio.c +++ b/fio.c @@ -70,6 +70,8 @@ static pthread_t disk_util_thread; static struct flist_head *cgroup_list; static char *cgroup_mnt; +unsigned long arch_flags = 0; + struct io_log *agg_io_log[2]; #define TERMINATE_ALL (-1) @@ -1690,10 +1692,12 @@ static void run_threads(void) fio_unpin_memory(); } -int main(int argc, char *argv[]) +int main(int argc, char *argv[], char *envp[]) { long ps; + arch_init(envp); + sinit(); init_rand(&__fio_rand_state); -- Jens Axboe -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org