Re: [PATCH] Alternative patching for prefetches & cleanup

From: Linus Torvalds (torvalds@transmeta.com)
Date: Sat Apr 26 2003 - 22:09:45 EST


On Sun, 27 Apr 2003, Andi Kleen wrote:
>
> It also adds nop types for various CPUs straight from their optimization
> manuals. Now you can always get the fastest nops for K7,K8 and Intel.
> I moved them into the include files to make it easy to use them
> for padding alternative()s. Some cleanups in the patch function to use this.

Please, this part I definitely want cleaned up.

> +++ linux-gencpu/arch/i386/kernel/setup.c 2003-04-27 04:12:32.000000000 +0200
> @@ -795,41 +795,42 @@
> pci_mem_start = low_mem_size;
> }
>
> +asm("nops: "
> + ASM_NOP1 ASM_NOP2 ASM_NOP3 ASM_NOP4 ASM_NOP5 ASM_NOP6
> + ASM_NOP7 ASM_NOP8);
> +

This in particular is just too ugly for words. Why can't you just have a

        static const char *intel_nops[] = {
                NULL,
                INOP1, INOP2, INOP3, INOP4, INOP5, INOP6, INOP7, INOP8
        };

        static const char *k7_nops[] = {
                NULL,
                K7NOP1, K7NOP2, ...
        }

        ....

        /*
         * This will be overridden at boot once we find out what kind of
         * CPU we actually have
         */
        static char **nops = intel_nops;

and then just use

        .. nops[size] ..

when you want a nop of size "size".

                Linus

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



This archive was generated by hypermail 2b29 : Wed Apr 30 2003 - 22:00:25 EST