From 93b9873a562b11dfedf5f4e53ef87bf256d80207 Mon Sep 17 00:00:00 2001 From: Tomas Hruby Date: Wed, 15 Sep 2010 14:10:36 +0000 Subject: [PATCH] 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 --- kernel/arch/i386/memory.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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); -- 2.44.0