Flexible I/O Tester development
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Aaron Carroll <xaaronc@gmail.com>
Cc: "Krishnamurthy, Anush" <anush.krishnamurthy@intel.com>,
	"fio@vger.kernel.org" <fio@vger.kernel.org>
Subject: Re: Make FIO for Android
Date: Fri, 12 Apr 2013 09:16:01 +0200	[thread overview]
Message-ID: <20130412071601.GJ12244@kernel.dk> (raw)
In-Reply-To: <CAKCZDgmS0mL=7Yiya2yWmfBY5EyE79kwQt66hSxfVOSwHWUCfA@mail.gmail.com>

On Fri, Apr 12 2013, Aaron Carroll wrote:
> On 12 April 2013 17:00, Jens Axboe <axboe@kernel.dk> wrote:
> > On Fri, Apr 12 2013, Aaron Carroll wrote:
> >> tuff
> >> > should be basic enough that it isn't a lot of trouble to carry it. At
> >> > least when we figure out why the Android NDK doesn't like the current
> >> > restraints :-)
> >>
> >> Digging around the GCC headers seems to have helped.  If you change
> >> the constraint on ebx to:
> >>         : "=a" (*eax), "=r" (*ebx), "=c" (*ecx), "=d" (*edx)
> >> then it builds.
> >
> > But it doesn't work, we lose the output :-)
> 
> Ahh, I missed some important stuff.  The ASM from cpuid.h looks like
> this on my Android/x86 GCC:
> 
> #define __cpuid(level, a, b, c, d)          \
>   __asm__ ("xchg{l}\t{%%}ebx, %1\n\t"           \
>        "cpuid\n\t"                  \
>        "xchg{l}\t{%%}ebx, %1\n\t"           \
>        : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \
>        : "0" (level))
> 
> Hopefully someone who knows what they're doing can turn that into an fio fix :)

How about this?

diff --git a/arch/arch-x86-common.h b/arch/arch-x86-common.h
index 78fd40c..179572d 100644
--- a/arch/arch-x86-common.h
+++ b/arch/arch-x86-common.h
@@ -3,15 +3,6 @@
 
 #include <string.h>
 
-static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
-			    unsigned int *ecx, unsigned int *edx)
-{
-	asm volatile("cpuid"
-		: "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
-		: "0" (*eax), "2" (*ecx)
-		: "memory");
-}
-
 static inline void cpuid(unsigned int op,
 			 unsigned int *eax, unsigned int *ebx,
 			 unsigned int *ecx, unsigned int *edx)
diff --git a/arch/arch-x86.h b/arch/arch-x86.h
index 69cf60b..49e64dd 100644
--- a/arch/arch-x86.h
+++ b/arch/arch-x86.h
@@ -1,6 +1,15 @@
 #ifndef ARCH_X86_H
 #define ARCH_X86_H
 
+static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
+			    unsigned int *ecx, unsigned int *edx)
+{
+	asm volatile("xchgl %%ebx, %1\ncpuid\nxchgl %%ebx, %1"
+		: "=a" (*eax), "=r" (*ebx), "=c" (*ecx), "=d" (*edx)
+		: "0" (*eax)
+		: "memory");
+}
+
 #include "arch-x86-common.h"
 
 #define FIO_ARCH	(arch_i386)
diff --git a/arch/arch-x86_64.h b/arch/arch-x86_64.h
index cea0451..8bdf01e 100644
--- a/arch/arch-x86_64.h
+++ b/arch/arch-x86_64.h
@@ -1,6 +1,15 @@
 #ifndef ARCH_X86_64_h
 #define ARCH_X86_64_h
 
+static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
+			    unsigned int *ecx, unsigned int *edx)
+{
+	asm volatile("cpuid"
+		: "=a" (*eax), "=b" (*ebx), "=r" (*ecx), "=d" (*edx)
+		: "0" (*eax), "2" (*ecx)
+		: "memory");
+}
+
 #include "arch-x86-common.h"
 
 #define FIO_ARCH	(arch_x86_64)

> > Patch is garbled?
> 
> Ok, so gmail sucks for dev work.  Sorry.  The Android bit follows inline.
> 
> diff --git a/os/os-android.h b/os/os-android.h
> index b844982..df22333 100644
> --- a/os/os-android.h
> +++ b/os/os-android.h
> @@ -13,6 +13,7 @@
>  #include <sched.h>
>  #include <linux/unistd.h>
>  #include <linux/major.h>
> +#include <asm/byteorder.h>
> 
>  #include "binject.h"
>  #include "../file.h"

Applied! That just leaves the cgroup problems:

cgroup.c: In function 'find_cgroup_mnt':
cgroup.c:29:2: warning: implicit declaration of function 'setmntent'
[-Wimplicit-function-declaration]
cgroup.c:29:4: warning: assignment makes pointer from integer without a
cast [enabled by default]
cgroup.c:35:2: warning: implicit declaration of function 'getmntent_r'
[-Wimplicit-function-declaration]
cgroup.c:35:14: warning: assignment makes pointer from integer without a
cast [enabled by default]
cgroup.c:46:2: warning: implicit declaration of function 'endmntent'
[-Wimplicit-function-declaration]
cgroup.c: At top level:
cgroup.c:78:6: error: redefinition of 'cgroup_kill'
cgroup.h:24:20: note: previous definition of 'cgroup_kill' was here
cgroup.c:147:5: error: redefinition of 'cgroup_setup'
cgroup.h:13:19: note: previous definition of 'cgroup_setup' was here
cgroup.c:189:6: error: redefinition of 'cgroup_shutdown'
cgroup.h:20:20: note: previous definition of 'cgroup_shutdown' was here
make: *** [cgroup.o] Error 1

-- 
Jens Axboe


  parent reply	other threads:[~2013-04-12  7:16 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-11 17:57 Make FIO for Android Krishnamurthy, Anush
     [not found] ` <CAKCZDgnM85AcwD6Ss5YWNjXwY-OE7QFQh22nFdEFHkta_N0hRA@mail.gmail.com>
2013-04-12  1:20   ` Krishnamurthy, Anush
2013-04-12  2:48     ` Aaron Carroll
2013-04-12  3:17       ` Krishnamurthy, Anush
2013-04-12  3:28         ` Aaron Carroll
2013-04-12  3:37           ` Aaron Carroll
2013-04-12  5:58             ` Jens Axboe
2013-04-12  6:10               ` Aaron Carroll
2013-04-12  6:18                 ` Jens Axboe
2013-04-12  6:24                   ` Aaron Carroll
2013-04-12  6:30                     ` Jens Axboe
2013-04-12  6:34                       ` Aaron Carroll
2013-04-12  6:38                         ` Jens Axboe
2013-04-12  6:51                           ` Aaron Carroll
2013-04-12  7:00                             ` Jens Axboe
2013-04-12  7:10                               ` Aaron Carroll
2013-04-12  7:12                                 ` Aaron Carroll
2013-04-12  7:16                                 ` Jens Axboe [this message]
2013-04-12  7:22                                   ` Aaron Carroll
2013-04-12  8:04                                     ` Jens Axboe
2013-04-13  3:47                                       ` Aaron Carroll
2013-04-13 18:05                                         ` Jens Axboe
2013-04-14  5:28                                           ` Aaron Carroll
2013-04-14  8:13                                             ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130412071601.GJ12244@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=anush.krishnamurthy@intel.com \
    --cc=fio@vger.kernel.org \
    --cc=xaaronc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox