提交 7a560836 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

no false sharing

上级 d99255d2
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
#include "file.h" #include "file.h"
#include "stat.h" #include "stat.h"
struct devsw devsw[NDEV]; struct devsw __attribute__ ((aligned (CACHELINE))) devsw[NDEV];
struct { struct {
struct spinlock lock; struct spinlock lock;
struct file file[NFILE]; struct file file[NFILE];
} ftable; } __attribute__ ((aligned (CACHELINE))) ftable;
void void
fileinit(void) fileinit(void)
......
...@@ -134,7 +134,7 @@ bfree(int dev, uint b) ...@@ -134,7 +134,7 @@ bfree(int dev, uint b)
struct { struct {
struct spinlock lock; struct spinlock lock;
struct inode inode[NINODE]; struct inode inode[NINODE];
} icache; } __attribute__ ((aligned (CACHELINE))) icache;
void void
iinit(void) iinit(void)
......
...@@ -18,7 +18,7 @@ void kminit(void); ...@@ -18,7 +18,7 @@ void kminit(void);
struct kmem kmems[NCPU]; struct kmem kmems[NCPU];
extern char end[]; // first address after kernel loaded from ELF file extern char end[]; // first address after kernel loaded from ELF file
static int kinited; static int kinited __attribute__ ((aligned (CACHELINE)));
static void __attribute__((unused)) static void __attribute__((unused))
kmemprint(void) kmemprint(void)
......
...@@ -2,11 +2,12 @@ ...@@ -2,11 +2,12 @@
#include "x86.h" #include "x86.h"
#include "defs.h" #include "defs.h"
#include "kbd.h" #include "kbd.h"
#include "param.h"
int int
kbdgetc(void) kbdgetc(void)
{ {
static uint shift; static uint shift __attribute__ ((aligned (CACHELINE)));
static uchar *charcode[4] = { static uchar *charcode[4] = {
normalmap, shiftmap, ctlmap, ctlmap normalmap, shiftmap, ctlmap, ctlmap
}; };
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "traps.h" #include "traps.h"
#include "mmu.h" #include "mmu.h"
#include "x86.h" #include "x86.h"
#include "param.h"
// Local APIC registers, divided by 4 for use as uint[] indices. // Local APIC registers, divided by 4 for use as uint[] indices.
#define ID (0x0020/4) // ID #define ID (0x0020/4) // ID
...@@ -125,7 +126,7 @@ cpunum(void) ...@@ -125,7 +126,7 @@ cpunum(void)
// almost everything, including cprintf and panic, calls cpu, // almost everything, including cprintf and panic, calls cpu,
// often indirectly through acquire and release. // often indirectly through acquire and release.
if(readeflags()&FL_IF){ if(readeflags()&FL_IF){
static int n; static int n __attribute__ ((aligned (CACHELINE)));
if(n++ == 0) if(n++ == 0)
cprintf("cpu called from %x with interrupts enabled\n", cprintf("cpu called from %x with interrupts enabled\n",
__builtin_return_address(0)); __builtin_return_address(0));
......
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
#include "proc.h" #include "proc.h"
struct cpu cpus[NCPU]; struct cpu cpus[NCPU];
static struct cpu *bcpu; static struct cpu *bcpu __attribute__((aligned (CACHELINE)));
int ismp; int ismp __attribute__((aligned (CACHELINE)));
int ncpu; int ncpu __attribute__((aligned (CACHELINE)));
uchar ioapicid; uchar ioapicid __attribute__((aligned (CACHELINE)));
int int
mpbcpu(void) mpbcpu(void)
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
#include "xv6-mtrace.h" #include "xv6-mtrace.h"
struct runq runqs[NCPU]; struct runq runqs[NCPU];
int idle[NCPU]; int __attribute__ ((aligned (CACHELINE))) idle[NCPU];
struct ns *nspid; struct ns *nspid __attribute__ ((aligned (CACHELINE)));
static struct proc *initproc; static struct proc *initproc __attribute__ ((aligned (CACHELINE)));
extern void forkret(void); extern void forkret(void);
extern void trapret(void); extern void trapret(void);
......
...@@ -16,13 +16,13 @@ struct rcu { ...@@ -16,13 +16,13 @@ struct rcu {
struct rcu *rcu; struct rcu *rcu;
void (*dofree)(void *); void (*dofree)(void *);
}; };
static struct rcu *rcu_delayed_head; static struct rcu *rcu_delayed_head __attribute__ ((aligned (CACHELINE)));
static struct rcu *rcu_delayed_tail; static struct rcu *rcu_delayed_tail __attribute__ ((aligned (CACHELINE)));
static struct rcu *rcu_freelist; static struct rcu *rcu_freelist __attribute__ ((aligned (CACHELINE)));
static uint global_epoch; static uint global_epoch __attribute__ ((aligned (CACHELINE))); static
static uint min_epoch; uint min_epoch __attribute__ ((aligned (CACHELINE))); static struct
static struct spinlock rcu_lock; spinlock rcu_lock __attribute__ ((aligned (CACHELINE))); static int
static int delayed_nfree; delayed_nfree __attribute__ ((aligned (CACHELINE)));
void void
rcuinit(void) rcuinit(void)
......
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
// Interrupt descriptor table (shared by all CPUs). // Interrupt descriptor table (shared by all CPUs).
struct gatedesc idt[256]; struct gatedesc idt[256];
extern uint vectors[]; // in vectors.S: array of 256 entry pointers extern uint vectors[]; // in vectors.S: array of 256 entry pointers
struct spinlock tickslock; struct spinlock tickslock __attribute__ ((aligned (CACHELINE)));
struct condvar cv_ticks; struct condvar cv_ticks __attribute__ ((aligned (CACHELINE)));
uint ticks; uint ticks __attribute__ ((aligned (CACHELINE)));
void void
tvinit(void) tvinit(void)
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
extern char data[]; // defined in data.S extern char data[]; // defined in data.S
static pde_t *kpgdir; // for use in scheduler() static pde_t *kpgdir __attribute__ ((aligned (CACHELINE))); // for use in scheduler()
// Set up CPU's kernel segment descriptors. // Set up CPU's kernel segment descriptors.
// Run once at boot time on each CPU. // Run once at boot time on each CPU.
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论