From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,59ca3b26f2b9f750 X-Google-Attributes: gid111c93,public From: anton@mips.complang.tuwien.ac.at (Anton Ertl) Subject: 21064A D-cache is *KB under Linux (was: lmbench on Linux and DU...) Date: 1999/03/11 Message-ID: <7c8oqm$a9r$1@news.tuwien.ac.at>#1/1 X-Deja-AN: 453827959 References: <7c36ao$fnm$1@news.tuwien.ac.at> <7c50a1$btd$1@prince.dataforce.net> <7c633v$b$1@news.tuwien.ac.at> <7c6a9r$pr3$1@prince.dataforce.net> <7c6jsp$97o$1@news.tuwien.ac.at> <7c6ps1$up3$1@prince.dataforce.net> Organization: Institut fuer Computersprachen, Technische Universitaet Wien Newsgroups: comp.os.linux.alpha In article <7c6ps1$up3$1@prince.dataforce.net>, Solar Designer writes: > Anton Ertl wrote: > > Bit 12 (DC_16K) of the ABOX_CTL register controls whether the D-cache > > is 8K (clear) or 16K (set). I looked at the kernel source (2.2.1), the milo-2.0.30 source, and the palcode source included with milo-2.0.30. As far as I see the DC_16K bit is set nowhere. > > Would simply setting the DC_16K bit be enough? I doubt it; OSs > > typically need special magic to deal with virtually-indexed caches. Can anyone comment on this? > [ Sorry for bringing up a slightly different topic; I think that the > information below is funny enough, and might be interesting for other > readers of this newsgroup. ] Thanks, this inspired me for my solution below. Your membench.c now gives 1478.98 Mb/sec even with 16K, and our LaTeX benchmark improves from 32.67s to 31.17s (still some way to go to the DU result of 24.8s). - anton Here's the source code for the module: /* D-cache control on an 21064A Just compile it with gcc -O -c toggle_dc_16k.c and invoke it with insmod toggle_dc_16k.o Never mind the error message. To see the result, invoke dmesg |tail which should contain a message like "abox_ctl=0x142c" or "abox_ctl=0x42c". In the former case, the D-cache now has 16K, in the latter 8K. Invoke the module again to toggle the state. When you try to install this module, it toggles the state of the D-cache between 8K and 16K and then prints the resulting value of the ABOX_CTL register in hex. If bit 12 (mask: 0x1000) is set, the D-cache is 16KB, if it is clear, the D-cache is 8KB. The module produces an error, so it is not installed, but the effect is there nevertheless. Warnings: It is not clear if Linux handles virtually indexed caches correctly on a 21064A (there might be problems with cache consistency, if the same physical page is mapped to several virtual addresses). It is not clear if it is safe to switch during operation (this module does not flush the cache). However, we have experienced no problems during our experiments and benchmarks with this module (on a non-critical machine:-) */ #define MODULE #define __KERNEL__ #include static long rd_abox_ctl() { long abox_ctl; asm("mov 3, $18; call_pal 9; mov $0, %0": "=r" (abox_ctl): /* no inputs */ : "$0","$16","$17","$18"); /* read abox_ctl register */ return abox_ctl; } /* toggle bit 12 of the ABOX_CTL register; this bit controls whether the Dache is 8KB or 16KB (virtually-indexed in the latter case) */ static void toggle_dc_16k() { long abox_ctl; asm("mov 3, $18; call_pal 9; mov $0, %0": "=r" (abox_ctl): /* no inputs */ : "$0","$16","$17","$18"); /* read abox_ctl register */ abox_ctl^=0x1000; asm("mov 6, $18; mov %0, $16; call_pal 9": : "r" (abox_ctl) : "$0","$16","$17","$18"); /* write abox_ctl register */ } int init_module() { toggle_dc_16k(); printk("abox_ctl=0x%x\n",rd_abox_ctl()); return 1; /* device or resource busy, so the module is not installed */ } void cleanup_module() { }