Re: K6 cache patch for 2.1.x ?

Kurt Garloff (garloff@kg1.ping.de)
Mon, 14 Dec 1998 18:33:08 +0100


--UlVJffcvxoiEqYs2
Content-Type: text/plain; charset=us-ascii

On Mon, Dec 14, 1998 at 09:56:47AM +0100, Lenart Gabor wrote:
> Yesterday I noticed that there's a patch for 2.0.36 which can make
> amd k6 based Linux systems about 10% faster with some L1 cache write
> allocation. My question is : is it planned to port this patch to 2.1.x,
> or even include it to the official 2.1.x kernels and to the 2.2.0 ?
> Sorry if it's offtopic.

It's not.

However, Linus and most people in this list consider the CPU setup (and the
setup of some other things) as the job of the BIOS. And they are right: The
BIOS should enable write allocation of your CPU. I don't believe it will
give you 10% performance increase, but typically something between 3 and 5%.
(And there are cases, where performance decreases w/ WRT_ALLOC.)
Still worth enabling it.

I append a module, which will enable write allocation on a K6-2 Stepping 0,
for the first 128MB of RAM. I believe the machanism will work for some other
K6 models is the same, whereas AMD changed it with the latest K6-2 chips
which have the K6-3 core (but not the L2 cache).
Another reasons, why most ppl don't want to have it in the kernel.

The module load will fail! Don't wonder about that: It's intended. We just
want to tweak a CPU register which we have to do from kernel space, but we
don't want to have a module to sit around and eat a page of kernel memory.
You will find a message in your logs ...

Hope this helps.

-- 
Kurt Garloff <K.Garloff@ping.de>  (Dortmund, FRG)
PGP key on http://student.physik.uni-dortmund.de/homepages/garloff

There is something frustrating about the quality and speed of Linux development. I.e. the quality is too high and the speed is too high, in other words, I can implement this XXXX feature, but I bet someone else has already done it and is just about to release his patch to Linus soon... [From a posting of Tigran Aivazian to linux-kernel, XXXX = disk stat]

--UlVJffcvxoiEqYs2 Content-Type: text/plain; charset=us-ascii Content-Description: k6mod.c Content-Disposition: attachment; filename="k6mod.c"

/* k6mod */

/* Sets write allocation on AMD K6(-2) processor */

/* Compile with * gcc -O2 -fomit-frame-pointer -D__KERNEL__ -I/usr/src/linux/include -c k6mod.c * * and insmod with insmod k6mod.o * or * copy to /lib/modules/2.1.125/misc * and depmod -a and modprobe k6mod */

#define MODULE #include <linux/module.h> #include <linux/kernel.h>

#define rdmsr(msr,val1,val2) \ __asm__ __volatile__("rdmsr" \ : "=a" (val1), "=d" (val2) \ : "c" (msr))

#define wrmsr(msr,val1,val2) \ __asm__ __volatile__("wrmsr" \ : /* no outputs */ \ : "c" (msr), "a" (val1), "d" (val2))

int init_module (void) { unsigned v1, v2; printk (KERN_INFO "Inserting K6 module ... \n"); rdmsr (0xc0000080, v1, v2); printk (KERN_INFO "EFER: %08x\n", v1); v1 |= 1; wrmsr (0xc0000080, v1, v2); rdmsr (0xc0000080, v1, v2); printk (KERN_INFO "EFER: %08x\n", v1); rdmsr (0xc0000082, v1, v2); printk (KERN_INFO "WHCR: %08x\n", v1); v1 = 0x41; wrmsr (0xc0000082, v1, v2); rdmsr (0xc0000082, v1, v2); printk (KERN_INFO "WHCR: %08x\n", v1); return 1; };

void cleanup_module (void) { printk (KERN_INFO "Removing K6 module ... \n"); };

--UlVJffcvxoiEqYs2--

- 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/