Le Sunday 21 June 2009 01:04:05 Jonas Gorski, vous avez écrit :
> 2009/6/21 Michael Buesch <m...@bu3sch.de>:
> > On Saturday 20 June 2009 23:56:51 Jonas Gorski wrote:
> >> 2009/6/20 Michael Buesch <m...@bu3sch.de>:
> >> > On Saturday 20 June 2009 00:09:56 Jonas Gorski wrote:
> >> >> > If we do _not_ gain performance, it certainly is not a good idea to
> >> >> > waste space.
> >> >>
> >> >> I would be very surprised if we wouldn't. Every kernel emulated
> >> >> floating point operation results in an exception and the appropriate
> >> >> handling (fpu emulation is ugly), while soft-float should stay
> >> >> completely in user space.
> >> >>
> >> >> Also, the mips fpu emulator itself suggests that.
> >> >>
> >> >> Quoting linux/arch/mips/math-emu/cp1emu.c:
> >> >> > * Note if you know that you won't have an fpu, then you'll get much
> >> >> > * better performance by compiling with -msoft-float!
> >> >>
> >> >> To get some numbers: Perhaps could somebody test with 'sample' from
> >> >> libmpcdec the difference in speed between in-kernel emulation and
> >> >> soft-float? https://dev.openwrt.org/ticket/4715 suggests that the
> >> >> library depends heavily on floating point when not using fixed point
> >> >> math.
> >> >
> >> > No you completely got me wrong. I am talking about the performance
> >> > gain in real life. userspace soft float certainly _is_ faster than
> >> > kernel float. But _if_ userspace soft float is bigger in size than
> >> > kernel float, it probably is not worth the space tradeoff, because
> >> > floating point is hardly used on a router.
> >>
> >> I apology, I really did misunderstand you.
> >>
> >> > Did somebody test this:
> >> > * Image with kernel FP emu disabled and userspace softemu enabled.
> >> > * Image with kernel FP emu enabled and userspace softemu disabled.
> >> >
> >> > Which one is smaller?
> >>
> >> Disabling the kernel fpu emu isn't intended in linux, so I had to hack
> >> the emulation away, mainly by removing any fpu references in
> >> arch/mips/kernel/ until it compiled.
> >> I don't know if it really works, I don't have a second device for
> >> testing.
> >>
> >> I used the brcm47xx/default profile for testing, making distclean
> >> before compiling.
> >>
> >> With kernel-fpuemu and no softfloat:
> >> 2560000 openwrt-brcm47xx-squashfs.trx
> >> Without fpuemu and with softfloat:
> >> 2625536 openwrt-brcm47xx-squashfs.trx
> >>
> >> So the image with soft-float instead of the in-kernel fpu emulation
> >> uses one block more. For me this would be an acceptable increase.
> >
> > So what about the following. We introduce another option in the kernel
> > config to disable fpuemu. This way the user can select either useremu,
> > kernelemu or no emu at all. This probably is a win-win situation then.
> > Because if I do care about space, I can turn off _both_ emulators. And
> > you, who do care about performance, can set the openwrt default to
> > kernelemu-off useremu-on.
>
> This would probably the best option. We should then test which
> applications/libraries need floating point support and mark these with
> an appropriate dependency.
> Going with no float support might require additional tweaking, as
> busybox seems to use floating point.

Here comes a quick'n'dirty compile tested only patch which allows disabling the 
in-kernel FPU emulator.
Could you guys test it with the toolchain having software floating point 
enabled and confirm that floating point operations still work ?
--
MIPS: allow disabling the kernel FPU emulator

This patch allows turning off the in-kernel Algorithmics
FPU emulator support, which allows one to save a couple of
precious blocks on an embedded system.

Without the MIPS_FPU_EMU option, the kernel size for AR7 is:
size vmlinux
   text    data     bss     dec     hex filename
5647163   90772   87904 5825839  58e52f vmlinux

With it enabled, same configuration:
   text    data     bss     dec     hex filename
5701403   90804   87904 5880111  59b92f vmlinux

In order nt to change the default behavior, this option
is default y.

Siged-off-by: Florian Fainelli <flor...@openwrt.org>
--
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 65d3b19..a467ee5 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -811,6 +811,17 @@ config I8259
 config MIPS_BONITO64
        bool
 
+config MIPS_FPU_EMU
+       bool
+       default y
+       help
+          This option allows building a kernel with or without the Algorithmics
+          FPU emulator enabled. Turning off this option results in a kernel 
which
+          does not catch floating operations exceptions. Make sure that your 
toolchain
+          is configured to enable software floating point emulation in that 
case.
+               
+          If unsure say Y here.
+
 config MIPS_MSC
        bool
 
diff --git a/arch/mips/math-emu/Makefile b/arch/mips/math-emu/Makefile
index d547efd..7fdef24 100644
--- a/arch/mips/math-emu/Makefile
+++ b/arch/mips/math-emu/Makefile
@@ -2,12 +2,14 @@
 # Makefile for the Linux/MIPS kernel FPU emulation.
 #
 
-obj-y  := cp1emu.o ieee754m.o ieee754d.o ieee754dp.o ieee754sp.o ieee754.o \
+obj-y  :=      kernel_linkage.o dsemul.o cp1emu.o
+
+obj-$(CONFIG_MIPS_FPU_EMU)     += ieee754m.o ieee754d.o ieee754dp.o 
ieee754sp.o ieee754.o \
           ieee754xcpt.o dp_frexp.o dp_modf.o dp_div.o dp_mul.o dp_sub.o \
           dp_add.o dp_fsp.o dp_cmp.o dp_logb.o dp_scalb.o dp_simple.o \
           dp_tint.o dp_fint.o dp_tlong.o dp_flong.o sp_frexp.o sp_modf.o \
           sp_div.o sp_mul.o sp_sub.o sp_add.o sp_fdp.o sp_cmp.o sp_logb.o \
           sp_scalb.o sp_simple.o sp_tint.o sp_fint.o sp_tlong.o sp_flong.o \
-          dp_sqrt.o sp_sqrt.o kernel_linkage.o dsemul.o
+          dp_sqrt.o sp_sqrt.o
 
 EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
index 890f779..9f4c767 100644
--- a/arch/mips/math-emu/cp1emu.c
+++ b/arch/mips/math-emu/cp1emu.c
@@ -56,6 +56,12 @@
 #endif
 #define __mips 4
 
+/* Further private data for which no space exists in mips_fpu_struct */
+
+struct mips_fpu_emulator_stats fpuemustats;
+
+#ifdef CONFIG_MIPS_FPU_EMU
+
 /* Function which emulates a floating point instruction. */
 
 static int fpu_emu(struct pt_regs *, struct mips_fpu_struct *,
@@ -66,10 +72,6 @@ static int fpux_emu(struct pt_regs *,
        struct mips_fpu_struct *, mips_instruction);
 #endif
 
-/* Further private data for which no space exists in mips_fpu_struct */
-
-struct mips_fpu_emulator_stats fpuemustats;
-
 /* Control registers */
 
 #define FPCREG_RID     0       /* $0  = revision id */
@@ -1273,6 +1275,13 @@ int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct 
mips_fpu_struct *ctx,
 
        return sig;
 }
+#else
+int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
+        int has_fpu)
+{
+       return 0;
+}
+#endif /* CONFIG_MIPS_FPU_EMU */
 
 #ifdef CONFIG_DEBUG_FS
 extern struct dentry *mips_debugfs_dir;
diff --git a/arch/mips/math-emu/dsemul.c b/arch/mips/math-emu/dsemul.c
index df7b9d9..9b42bfd 100644
--- a/arch/mips/math-emu/dsemul.c
+++ b/arch/mips/math-emu/dsemul.c
@@ -109,6 +109,7 @@ int mips_dsemul(struct pt_regs *regs, mips_instruction ir, 
unsigned long cpc)
        return SIGILL;          /* force out of emulation loop */
 }
 
+#ifdef CONFIG_MIPS_FPU_EMU
 int do_dsemulret(struct pt_regs *xcp)
 {
        struct emuframe __user *fr;
@@ -165,3 +166,9 @@ int do_dsemulret(struct pt_regs *xcp)
 
        return 1;
 }
+#else
+int do_dsemulret(struct pt_regs *xcp)
+{
+       return 0;
+}
+#endif /* CONFIG_MIPS_FPU_EMU */
diff --git a/arch/mips/math-emu/kernel_linkage.c 
b/arch/mips/math-emu/kernel_linkage.c
index 52e6c58..211a399 100644
--- a/arch/mips/math-emu/kernel_linkage.c
+++ b/arch/mips/math-emu/kernel_linkage.c
@@ -29,6 +29,7 @@
 
 #define SIGNALLING_NAN 0x7ff800007ff80000LL
 
+#ifdef CONFIG_MIPS_FPU_EMU
 void fpu_emulator_init_fpu(void)
 {
        static int first = 1;
@@ -112,4 +113,34 @@ int fpu_emulator_restore_context32(struct sigcontext32 
__user *sc)
 
        return err;
 }
-#endif
+#endif /* CONFIG_64BIT */
+#else
+
+void fpu_emulator_init_fpu(void)
+{
+       return;
+}
+
+int fpu_emulator_save_context(struct sigcontext __user *sc)
+{
+       return 0;
+}
+
+int fpu_emulator_restore_context(struct sigcontext __user *sc)
+{
+       return 0;
+}
+
+int fpu_emulator_save_context32(struct sigcontext32 __user *sc)
+{
+       return 0;
+}
+
+int fpu_emulator_restore_context32(struct sigcontext32 __user *sc)
+{
+       return 0;
+}
+
+#ifdef CONFIG_64BIT
+#endif /* CONFIG_64BIT */
+#endif /* CONFIG_MIPS_FPU_EMU */

-- 
Best regards, Florian Fainelli
Email : flor...@openwrt.org
http://openwrt.org
-------------------------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to