reserve nocache based on RAM size
Hi Marcelo,
Since there's no official sparc32 maintainer, I'm sending this patch directly to you. It has now been tested in various configurations (released in the default Aurora 0.3 kernel) and appears to be causing no undesired side effects.
Please apply.
-Tomas
fw:
Date: Mon, 10 Jun 2002 16:59:27 +0200
From: Tomas Szepe <[email protected]>
To: [email protected]
Subject: [RFC] sparc32: reserve nocache acc. to the amount of system RAM
The following patch settles Anton Blanchard's FIXME from asm-sparc/vaddrs.h. For sparc32 systems, it makes the kernel allocate nocache memory based on the amount of system RAM, abandoning the old behavior of always reserving 256 pages.
Together with Colin Gibb's patches that made it into -pre9, this should make 2.4 perform just ok on sparc32s. Sure, it's still possible to run out of nocache mem, but the unfortunate event should more likely only happen when the machine is running out of system RAM too.
I've set the allocation ratio to "let's have 256 pages of nocache per 64MB of system RAM," see SRMMU_NOCACHE_ALCRATIO in vaddrs.h. Might have to be tuned somewhat for systems with very little RAM. (256 pages is often insufficient.)
The patch applies to 2.4.19-pre9, pre10, and rc1.
-Tomas
arch/sparc/mm/init.c +3 -1
@@ -61,13 +61,15 @@pte_t *kmap_pte;pgprot_t kmap_prot; +extern unsigned long fix_kmap_begin;/* calculated in srmmu.c */ +#define kmap_get_fixed_pte (vaddr) \ pte_offset(pmd_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr))void __init kmap_init (void ) {/* cache the first kmap pte */ - kmap_pte =kmap_get_fixed_pte (FIX_KMAP_BEGIN ); + kmap_pte =kmap_get_fixed_pte (fix_kmap_begin); kmap_prot =__pgprot (SRMMU_ET_PTE |SRMMU_PRIV |SRMMU_CACHE ); }
arch/sparc/mm/srmmu.c +54 -16
131 lines not on this page · raw message
include/asm-sparc/highmem.h +10 -6
@@ -36,6 +36,10 @@extern pgprot_t kmap_prot;extern pte_t *pkmap_page_table; +/* these two get calculated in arch/sparc/mm/srmmu.c */ +extern unsigned long fix_kmap_begin; +extern unsigned long pkmap_base; +extern void kmap_init (void )__init ;/*
@@ -45,9 +49,9 @@*/ #define LAST_PKMAP 1024 -#define LAST_PKMAP_MASK (LAST_PKMAP-1) -#define PKMAP_NR (virt) ((virt-PKMAP_BASE) >> PAGE_SHIFT) -#define PKMAP_ADDR (nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) +#define LAST_PKMAP_MASK (LAST_PKMAP - 1) +#define PKMAP_NR (virt) ((virt - pkmap_base) >> PAGE_SHIFT) +#define PKMAP_ADDR (nr) (pkmap_base + ((nr) << PAGE_SHIFT))extern void *kmap_high (struct page *page);extern void kunmap_high (struct page *page);
@@ -85,7 +89,7 @@return page_address (page); idx = type +KM_TYPE_NR *smp_processor_id (); - vaddr =FIX_KMAP_BEGIN + idx *PAGE_SIZE ; + vaddr = fix_kmap_begin + idx *PAGE_SIZE ;/* XXX Fix - Anton */ #if 0
@@ -114,10 +118,10 @@unsigned long vaddr = (unsigned long ) kvaddr;unsigned long idx = type +KM_TYPE_NR *smp_processor_id (); -if (vaddr <FIX_KMAP_BEGIN )// FIXME +if (vaddr < fix_kmap_begin)// FIXME return ; -if (vaddr !=FIX_KMAP_BEGIN + idx *PAGE_SIZE ) +if (vaddr != fix_kmap_begin + idx *PAGE_SIZE )BUG ();/* XXX Fix - Anton */
include/asm-sparc/vaddrs.h +13 -10
@@ -14,23 +14,26 @@#define SRMMU_MAXMEM 0x0c000000 -#define SRMMU_NOCACHE_VADDR 0xfc000000/* KERNBASE + SRMMU_MAXMEM */ -/* XXX Make this dynamic based on ram size - Anton */ -#define SRMMU_NOCACHE_NPAGES 256 -#define SRMMU_NOCACHE_SIZE (SRMMU_NOCACHE_NPAGES * PAGE_SIZE) -#define SRMMU_NOCACHE_END (SRMMU_NOCACHE_VADDR + SRMMU_NOCACHE_SIZE) +#define SRMMU_NOCACHE_VADDR (KERNBASE + SRMMU_MAXMEM) +/* = 0x0fc000000 */ -#define FIX_KMAP_BEGIN 0xfc100000 -#define FIX_KMAP_END (FIX_KMAP_BEGIN + ((KM_TYPE_NR*NR_CPUS)-1)*PAGE_SIZE) - -#define PKMAP_BASE 0xfc140000 -#define PKMAP_BASE_END (PKMAP_BASE+LAST_PKMAP*PAGE_SIZE) +/* The following constant is used in mm/srmmu.c::srmmu_nocache_calcsize() +* to determine the amount of memory that will be reserved as nocache: +* +* 256 pages will be taken as nocache per each +* SRMMU_NOCACHE_ALCRATIO MB of system memory. +* +* limits enforced: nocache minimum = 256 pages +* nocache maximum = 1280 pages +*/ +#define SRMMU_NOCACHE_ALCRATIO 64/* 256 pages per 64MB of system RAM */ #define SUN4M_IOBASE_VADDR 0xfd000000/* Base for mapping pages */ #define IOBASE_VADDR 0xfe000000#define IOBASE_END 0xfe300000#define VMALLOC_START 0xfe300000 +/* XXX Alter this when I get around to fixing sun4c - Anton */ #define VMALLOC_END 0xffc00000
From: Tomas Szepe <[email protected]>
Date: Sun, 14 Jul 2002 17:38:05 +0200
Since there's no official sparc32 maintainer, I'm sending this patch directly to you. It has now been tested in various configurations (released in the default Aurora 0.3 kernel) and appears to be causing no undesired side effects.
I'm still reviewing the patch and it is in my backlog AND I was on a 12 day vacation. Be patient and I didn't want this in until 2.4.20 anyways, thanks.