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

no false sharing

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