From: Tomas Hruby Date: Wed, 15 Sep 2010 14:10:36 +0000 (+0000) Subject: SMP - Free PDE slots are split among CPU X-Git-Tag: v3.2.0~853 X-Git-Url: http://zhaoyanbai.com/repos/%22../static/howto.html?a=commitdiff_plain;h=93b9873a562b11dfedf5f4e53ef87bf256d80207;p=minix.git SMP - Free PDE slots are split among CPU - cross-address space copies use these slots to map user memory for kernel. This avoid any collisions between CPUs - well, we only have a single CPU running at a time, this is just to be safe for the future --- diff --git a/kernel/arch/i386/memory.c b/kernel/arch/i386/memory.c index 35fa5f687..e1307df69 100644 --- a/kernel/arch/i386/memory.c +++ b/kernel/arch/i386/memory.c @@ -31,7 +31,8 @@ PUBLIC int i386_paging_enabled = 0; PRIVATE int psok = 0; -#define MAX_FREEPDES (3 * CONFIG_MAX_CPUS) +#define FREE_PDES_PER_CPU 3 +#define MAX_FREEPDES (FREE_PDES_PER_CPU * CONFIG_MAX_CPUS) PRIVATE int nfreepdes = 0, freepdes[MAX_FREEPDES]; #define HASPT(procptr) ((procptr)->p_seg.p_cr3 != 0) @@ -79,7 +80,12 @@ PRIVATE phys_bytes createpde( phys_bytes offset; int pde; - assert(free_pde_idx >= 0 && free_pde_idx < nfreepdes); + assert(free_pde_idx >= 0 && free_pde_idx < FREE_PDES_PER_CPU); + + /* make the index CPU local */ + free_pde_idx += cpuid * FREE_PDES_PER_CPU; + assert(free_pde_idx < nfreepdes); + pde = freepdes[free_pde_idx]; assert(pde >= 0 && pde < 1024);