Re: Problem with 1G RAM

Jakub Jelinek (jj@sunsite.ms.mff.cuni.cz)
Tue, 8 Dec 1998 16:03:55 +0100 (CET)


> > Um, have you tried this Ingo? Given
>
> [yes i've tried it before posting :)]
>
> >
> > #define foo ((int)&__foo)
> > int bar(int *x)
> > {
> > return x[foo+45];
> > }
> >
> > or suchlike you should see __foo combined with other operations.
> >
> > movl $__foo+45,%eax
> > movl (%edx,%eax,4),%eax
> >
> > in this case due to the shift.
>
> this is what it does:
>
> 0: 8b 54 24 04 movl 0x4(%esp,1),%edx
> 4: b8 2d 00 00 00 movl $0x2d,%eax
> 9: 8b 04 82 movl (%edx,%eax,4),%eax
> c: c3 ret
>
> so yes it has combined it into a constant, but not into an immediate
> instruction constant. The thing we can get with
>
> #define foo1 0x12340000
>
> is:
> 0: 8b 44 24 04 movl 0x4(%esp,1),%eax
> 4: 8b 80 b4 00 d0 movl 0x48d000b4(%eax),%eax
> 9: 48
> a: c3 ret
>
> which is smaller and faster.

Ok, this is of course true, but it is not that important for kernel, as if
I'm not wrong, the i386 port is not shifting expressions with PAGE_OFFSET in
it very much (two such cases come to my mind, MAP_NR(), but that usually
works on a variable, so it cannot be optimized anyway (must first have been
subtracted and then shifted), and USER_PTRS_PER_PGD, but that is easily
solvable by introducing yet another precomputed btfixuped variable).
As far as I can see, PAGE_OFFSET is mostly added/subtracted to something and
in that case the code quality is exactly the same, even __io_virt/__io_phys
which or/andn it with something should be fine unless you'd want to
__io_virt/__io_phys a constant.
I know some cases will be less efficient, if the expressions are too
complicated, but such things I'm sure will be rare in the kernel.
I'll try to code it (if I find some PC somewhere with enough space on disk)
and let's talk on the resulting kernel differences, ok?

Cheers,
Jakub
___________________________________________________________________
Jakub Jelinek | jj@sunsite.mff.cuni.cz | http://sunsite.mff.cuni.cz
Administrator of SunSITE Czech Republic, MFF, Charles University
___________________________________________________________________
Ultralinux - first 64bit OS to take full power of the UltraSparc
Linux version 2.1.130 on a sparc64 machine (3958.37 BogoMips)
___________________________________________________________________

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/