linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Using in_8 and out_8 without module optimization
@ 2003-10-21 13:25 Seb James
  2003-10-21 13:48 ` Wolfgang Grandegger
  2003-10-22 15:41 ` linas
  0 siblings, 2 replies; 4+ messages in thread
From: Seb James @ 2003-10-21 13:25 UTC (permalink / raw)
  To: linuxppc-dev


Hello,

I have a kernel module that I wish to insmod into a linux kernel running
on a powerpc chip (mpc823).

It uses an inline function declared and defined in asm-ppc/io.h: out_8.

I #include io.h in my code, and call the function out_8. The code
compiles fine. The module insmods fine as long as I called gcc with -O
for some optimization when compiling.

I need to run the module without optimization as I really need a section
of the code to run exactly as I've coded it, but when I compile without
the -O, insmod fails to insert the module, complaining:

driver.o: unresolved symbol out_8

Something to do with the fact that -O inlines quite a lot of the
functions in my module, but I don't understand any further than this.
Can anyone suggest a way I can use out_8 without optimizing my module?

best regards,

Seb James.


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Using in_8 and out_8 without module optimization
  2003-10-21 13:25 Using in_8 and out_8 without module optimization Seb James
@ 2003-10-21 13:48 ` Wolfgang Grandegger
  2003-10-21 14:03   ` Holger Bettag
  2003-10-22 15:41 ` linas
  1 sibling, 1 reply; 4+ messages in thread
From: Wolfgang Grandegger @ 2003-10-21 13:48 UTC (permalink / raw)
  To: Seb James, linuxppc-dev


Hi Seb,

to get inline's expanded you need at least "-O" optimization.
To ensure that the asm-code is executed in sequence with your
C-code use:

  -fno-schedule-insns -fno-schedule-insns2

Hope that's what you are looking for.

Ciao, Wolfgang.


>-- Original Message --
>Subject: Using in_8 and out_8 without module optimization
>From: Seb James <seb@peak.uklinux.net>
>To: linuxppc-dev@lists.linuxppc.org
>Date: 21 Oct 2003 14:25:24 +0100
>
>
>
>Hello,
>
>I have a kernel module that I wish to insmod into a linux kernel running
>on a powerpc chip (mpc823).
>
>It uses an inline function declared and defined in asm-ppc/io.h: out_8.
>
>I #include io.h in my code, and call the function out_8. The code
>compiles fine. The module insmods fine as long as I called gcc with -O
>for some optimization when compiling.
>
>I need to run the module without optimization as I really need a section
>of the code to run exactly as I've coded it, but when I compile without
>the -O, insmod fails to insert the module, complaining:
>
>driver.o: unresolved symbol out_8
>
>Something to do with the fact that -O inlines quite a lot of the
>functions in my module, but I don't understand any further than this.
>Can anyone suggest a way I can use out_8 without optimizing my module?
>
>best regards,
>
>Seb James.
>
>
>


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Using in_8 and out_8 without module optimization
  2003-10-21 13:48 ` Wolfgang Grandegger
@ 2003-10-21 14:03   ` Holger Bettag
  0 siblings, 0 replies; 4+ messages in thread
From: Holger Bettag @ 2003-10-21 14:03 UTC (permalink / raw)
  To: linuxppc-dev


On Tue, 21 Oct 2003, Wolfgang Grandegger wrote:

> To ensure that the asm-code is executed in sequence with your
> C-code use:
>
>   -fno-schedule-insns -fno-schedule-insns2
>
Some other optimizations might still rearrange code, so consider
-fno-strength-reduce and -fno-move-all-moveables and possibly a few other
switches. Just compile with -S and see if the assembly code looks right.

I think there is also a switch to force inline functions to be
instantiated, could be -fno-inline or -fforce-no-inline, but the former
solution is likely a lot better.

  Holger

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Using in_8 and out_8 without module optimization
  2003-10-21 13:25 Using in_8 and out_8 without module optimization Seb James
  2003-10-21 13:48 ` Wolfgang Grandegger
@ 2003-10-22 15:41 ` linas
  1 sibling, 0 replies; 4+ messages in thread
From: linas @ 2003-10-22 15:41 UTC (permalink / raw)
  To: Seb James; +Cc: linuxppc-dev


On Tue, Oct 21, 2003 at 02:25:24PM +0100, Seb James wrote:
>
> I need to run the module without optimization as I really need a section
> of the code to run exactly as I've coded it, but when I compile without

re-write that section in assembly.

Note that even if the compiler doesn't reorder insn's or memory load/store's,
the CPU might still excecute out-of-order, and/or the memory controller
(if any) might store/load out of order.  If you need guarenteed order
of execution, you need to use memory/io barriers, e.g. eieio, sync;
if you are seeing cacheing of i/o loads/stores, you are probably not
using 'volatile' (or not using it correctly).

On Tue, Oct 21, 2003 at 04:03:33PM +0200, Holger Bettag wrote:
>
> On Tue, 21 Oct 2003, Wolfgang Grandegger wrote:
>
> > To ensure that the asm-code is executed in sequence with your
> > C-code use:
> >
> >   -fno-schedule-insns -fno-schedule-insns2
> >
> Some other optimizations might still rearrange code, so consider
> -fno-strength-reduce and -fno-move-all-moveables and possibly a few other
> switches. Just compile with -S and see if the assembly code looks right.

If a device driver breaks because of compiler optimizations, the answer
is to fix the device driver, not to disable optimization.  I'm guessing
that the driver isn't using eieio in all the right places. (and/or volatile).


--linas


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-10-22 15:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-21 13:25 Using in_8 and out_8 without module optimization Seb James
2003-10-21 13:48 ` Wolfgang Grandegger
2003-10-21 14:03   ` Holger Bettag
2003-10-22 15:41 ` linas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).