direct-io.hg

changeset 9314:78b8b0d9acc8

merge with xen-ia64-unstable.hg
author kaf24@firebug.cl.cam.ac.uk
date Sat Mar 18 10:59:11 2006 +0100 (2006-03-18)
parents 25003dd43a92 ea67b8a9c7e0
children 4d4a700bea7a
files
line diff
     1.1 --- a/buildconfigs/mk.linux-2.6-xen	Fri Mar 17 15:37:28 2006 -0700
     1.2 +++ b/buildconfigs/mk.linux-2.6-xen	Sat Mar 18 10:59:11 2006 +0100
     1.3 @@ -2,8 +2,8 @@
     1.4  OS           = linux
     1.5  
     1.6  LINUX_SERIES = 2.6
     1.7 -LINUX_VER    = 2.6.16-rc5
     1.8 -LINUX_SRCS = linux-2.6.15.tar.bz2 patch-2.6.16-rc5.bz2
     1.9 +LINUX_VER    = 2.6.16-rc6
    1.10 +LINUX_SRCS = linux-2.6.15.tar.bz2 patch-2.6.16-rc6.bz2
    1.11  LINUX_PDIR = linux-$(LINUX_VER)
    1.12  
    1.13  EXTRAVERSION ?= xen
    1.14 @@ -34,7 +34,7 @@ pristine-$(LINUX_PDIR)/.valid-srcs: $(LI
    1.15  	touch $(@D)/.hgskip
    1.16  	touch $@
    1.17  
    1.18 -pristine-linux-%.16-rc5/.valid-pristine: pristine-$(LINUX_PDIR)/.valid-srcs
    1.19 +pristine-linux-%.16-rc6/.valid-pristine: pristine-$(LINUX_PDIR)/.valid-srcs
    1.20  	touch $@ # update timestamp to avoid rebuild
    1.21  
    1.22  $(LINUX_DIR)/include/linux/autoconf.h: ref-$(OS)-$(LINUX_VER)/.valid-ref
     2.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/Makefile	Fri Mar 17 15:37:28 2006 -0700
     2.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/Makefile	Sat Mar 18 10:59:11 2006 +0100
     2.3 @@ -11,7 +11,7 @@ obj-y	:= process.o semaphore.o signal.o 
     2.4  
     2.5  obj-y				+= cpu/
     2.6  obj-y				+= timers/
     2.7 -obj-$(CONFIG_ACPI)		+= acpi/
     2.8 +obj-y				+= acpi/
     2.9  obj-$(CONFIG_X86_BIOS_REBOOT)	+= reboot.o
    2.10  obj-$(CONFIG_MCA)		+= mca.o
    2.11  obj-$(CONFIG_X86_MSR)		+= msr.o
     3.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/acpi/Makefile	Fri Mar 17 15:37:28 2006 -0700
     3.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/acpi/Makefile	Sat Mar 18 10:59:11 2006 +0100
     3.3 @@ -1,4 +1,4 @@
     3.4 -obj-y				:= boot.o
     3.5 +obj-$(CONFIG_ACPI)		+= boot.o
     3.6  obj-$(CONFIG_X86_IO_APIC)	+= earlyquirk.o
     3.7  obj-$(CONFIG_ACPI_SLEEP)	+= sleep.o wakeup.o
     3.8  
     4.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/acpi/boot-xen.c	Fri Mar 17 15:37:28 2006 -0700
     4.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/acpi/boot-xen.c	Sat Mar 18 10:59:11 2006 +0100
     4.3 @@ -44,6 +44,9 @@ extern void __init clustered_apic_check(
     4.4  extern int gsi_irq_sharing(int gsi);
     4.5  #include <asm/proto.h>
     4.6  
     4.7 +static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id) { return 0; }
     4.8 +
     4.9 +
    4.10  #else				/* X86 */
    4.11  
    4.12  #ifdef	CONFIG_X86_LOCAL_APIC
    4.13 @@ -1111,9 +1114,6 @@ int __init acpi_boot_table_init(void)
    4.14  		disable_acpi();
    4.15  		return error;
    4.16  	}
    4.17 -#ifdef __i386__
    4.18 -	check_acpi_pci();
    4.19 -#endif
    4.20  
    4.21  	acpi_table_parse(ACPI_BOOT, acpi_parse_sbf);
    4.22  
     5.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/cpu/common-xen.c	Fri Mar 17 15:37:28 2006 -0700
     5.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/cpu/common-xen.c	Sat Mar 18 10:59:11 2006 +0100
     5.3 @@ -283,10 +283,10 @@ void __devinit generic_identify(struct c
     5.4  			c->x86_capability[4] = excap;
     5.5  			c->x86 = (tfms >> 8) & 15;
     5.6  			c->x86_model = (tfms >> 4) & 15;
     5.7 -			if (c->x86 == 0xf) {
     5.8 +			if (c->x86 == 0xf)
     5.9  				c->x86 += (tfms >> 20) & 0xff;
    5.10 +			if (c->x86 >= 0x6)
    5.11  				c->x86_model += ((tfms >> 16) & 0xF) << 4;
    5.12 -			} 
    5.13  			c->x86_mask = tfms & 15;
    5.14  		} else {
    5.15  			/* Have CPUID level 0 only - unheard of */
     6.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/io_apic-xen.c	Fri Mar 17 15:37:28 2006 -0700
     6.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/io_apic-xen.c	Sat Mar 18 10:59:11 2006 +0100
     6.3 @@ -93,6 +93,8 @@ static struct { int pin, apic; } ioapic_
     6.4  
     6.5  static DEFINE_SPINLOCK(ioapic_lock);
     6.6  
     6.7 +int timer_over_8254 __initdata = 1;
     6.8 +
     6.9  /*
    6.10   *	Is the SiS APIC rmw bug present ?
    6.11   *	-1 = don't know, 0 = no, 1 = yes
    6.12 @@ -2329,7 +2331,8 @@ static inline void check_timer(void)
    6.13  	apic_write_around(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
    6.14  	init_8259A(1);
    6.15  	timer_ack = 1;
    6.16 -	enable_8259A_irq(0);
    6.17 +	if (timer_over_8254 > 0)
    6.18 +		enable_8259A_irq(0);
    6.19  
    6.20  	pin1  = find_isa_irq_pin(0, mp_INT);
    6.21  	apic1 = find_isa_irq_apic(0, mp_INT);
    6.22 @@ -2459,6 +2462,20 @@ void __init setup_IO_APIC(void)
    6.23  		print_IO_APIC();
    6.24  }
    6.25  
    6.26 +static int __init setup_disable_8254_timer(char *s)
    6.27 +{
    6.28 +	timer_over_8254 = -1;
    6.29 +	return 1;
    6.30 +}
    6.31 +static int __init setup_enable_8254_timer(char *s)
    6.32 +{
    6.33 +	timer_over_8254 = 2;
    6.34 +	return 1;
    6.35 +}
    6.36 +
    6.37 +__setup("disable_8254_timer", setup_disable_8254_timer);
    6.38 +__setup("enable_8254_timer", setup_enable_8254_timer);
    6.39 +
    6.40  /*
    6.41   *	Called after all the initialization is done. If we didnt find any
    6.42   *	APIC bugs then we can allow the modify fast path
     7.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c	Fri Mar 17 15:37:28 2006 -0700
     7.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/microcode-xen.c	Sat Mar 18 10:59:11 2006 +0100
     7.3 @@ -25,6 +25,7 @@
     7.4  #include <linux/kernel.h>
     7.5  #include <linux/init.h>
     7.6  #include <linux/sched.h>
     7.7 +#include <linux/cpumask.h>
     7.8  #include <linux/module.h>
     7.9  #include <linux/slab.h>
    7.10  #include <linux/vmalloc.h>
     8.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c	Fri Mar 17 15:37:28 2006 -0700
     8.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c	Sat Mar 18 10:59:11 2006 +0100
     8.3 @@ -1819,6 +1819,10 @@ void __init setup_arch(char **cmdline_p)
     8.4  	op.u.set_iopl.iopl = 1;
     8.5  	HYPERVISOR_physdev_op(&op);
     8.6  
     8.7 +#ifdef CONFIG_X86_IO_APIC
     8.8 +	check_acpi_pci();	/* Checks more than just ACPI actually */
     8.9 +#endif
    8.10 +
    8.11  #ifdef CONFIG_ACPI
    8.12  	if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
    8.13  		printk(KERN_INFO "ACPI in unprivileged domain disabled\n");
     9.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Fri Mar 17 15:37:28 2006 -0700
     9.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/time-xen.c	Sat Mar 18 10:59:11 2006 +0100
     9.3 @@ -840,9 +840,9 @@ static int timer_resume(struct sys_devic
     9.4  	write_seqlock_irqsave(&xtime_lock, flags);
     9.5  	xtime.tv_sec = sec;
     9.6  	xtime.tv_nsec = 0;
     9.7 +	jiffies_64 += sleep_length;
     9.8 +	wall_jiffies += sleep_length;
     9.9  	write_sequnlock_irqrestore(&xtime_lock, flags);
    9.10 -	jiffies += sleep_length;
    9.11 -	wall_jiffies += sleep_length;
    9.12  	if (last_timer->resume)
    9.13  		last_timer->resume();
    9.14  	cur_timer = last_timer;
    10.1 --- a/linux-2.6-xen-sparse/drivers/char/tty_io.c	Fri Mar 17 15:37:28 2006 -0700
    10.2 +++ b/linux-2.6-xen-sparse/drivers/char/tty_io.c	Sat Mar 18 10:59:11 2006 +0100
    10.3 @@ -305,7 +305,7 @@ static struct tty_buffer *tty_buffer_fin
    10.4  			t->commit = 0;
    10.5  			t->read = 0;
    10.6  			/* DEBUG ONLY */
    10.7 -			memset(t->data, '*', size);
    10.8 +/*			memset(t->data, '*', size); */
    10.9  /* 			printk("Flip recycle %p\n", t); */
   10.10  			return t;
   10.11  		}
    11.1 --- a/linux-2.6-xen-sparse/include/asm-i386/apic.h	Fri Mar 17 15:37:28 2006 -0700
    11.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/apic.h	Sat Mar 18 10:59:11 2006 +0100
    11.3 @@ -139,6 +139,8 @@ void switch_ipi_to_APIC_timer(void *cpum
    11.4  #define ARCH_APICTIMER_STOPS_ON_C3	1
    11.5  #endif
    11.6  
    11.7 +extern int timer_over_8254;
    11.8 +
    11.9  #else /* !CONFIG_X86_LOCAL_APIC */
   11.10  static inline void lapic_shutdown(void) { }
   11.11  
    12.1 --- a/linux-2.6-xen-sparse/include/linux/gfp.h	Fri Mar 17 15:37:28 2006 -0700
    12.2 +++ b/linux-2.6-xen-sparse/include/linux/gfp.h	Sat Mar 18 10:59:11 2006 +0100
    12.3 @@ -161,9 +161,9 @@ extern void FASTCALL(free_cold_page(stru
    12.4  
    12.5  void page_alloc_init(void);
    12.6  #ifdef CONFIG_NUMA
    12.7 -void drain_remote_pages(void);
    12.8 +void drain_node_pages(int node);
    12.9  #else
   12.10 -static inline void drain_remote_pages(void) { };
   12.11 +static inline void drain_node_pages(int node) { };
   12.12  #endif
   12.13  
   12.14  #endif /* __LINUX_GFP_H */
    13.1 --- a/linux-2.6-xen-sparse/mm/page_alloc.c	Fri Mar 17 15:37:28 2006 -0700
    13.2 +++ b/linux-2.6-xen-sparse/mm/page_alloc.c	Sat Mar 18 10:59:11 2006 +0100
    13.3 @@ -591,21 +591,20 @@ static int rmqueue_bulk(struct zone *zon
    13.4  }
    13.5  
    13.6  #ifdef CONFIG_NUMA
    13.7 -/* Called from the slab reaper to drain remote pagesets */
    13.8 -void drain_remote_pages(void)
    13.9 +/*
   13.10 + * Called from the slab reaper to drain pagesets on a particular node that
   13.11 + * belong to the currently executing processor.
   13.12 + */
   13.13 +void drain_node_pages(int nodeid)
   13.14  {
   13.15 -	struct zone *zone;
   13.16 -	int i;
   13.17 +	int i, z;
   13.18  	unsigned long flags;
   13.19  
   13.20  	local_irq_save(flags);
   13.21 -	for_each_zone(zone) {
   13.22 +	for (z = 0; z < MAX_NR_ZONES; z++) {
   13.23 +		struct zone *zone = NODE_DATA(nodeid)->node_zones + z;
   13.24  		struct per_cpu_pageset *pset;
   13.25  
   13.26 -		/* Do not drain local pagesets */
   13.27 -		if (zone->zone_pgdat->node_id == numa_node_id())
   13.28 -			continue;
   13.29 -
   13.30  		pset = zone_pcp(zone, smp_processor_id());
   13.31  		for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) {
   13.32  			struct per_cpu_pages *pcp;
    14.1 --- a/patches/linux-2.6.16-rc5/i386-mach-io-check-nmi.patch	Fri Mar 17 15:37:28 2006 -0700
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,45 +0,0 @@
    14.4 -diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/kernel/traps.c ./arch/i386/kernel/traps.c
    14.5 ---- ../pristine-linux-2.6.16-rc5/arch/i386/kernel/traps.c	2006-02-27 15:46:58.000000000 +0000
    14.6 -+++ ./arch/i386/kernel/traps.c	2006-02-27 15:55:23.000000000 +0000
    14.7 -@@ -567,18 +567,11 @@ static void mem_parity_error(unsigned ch
    14.8 - 
    14.9 - static void io_check_error(unsigned char reason, struct pt_regs * regs)
   14.10 - {
   14.11 --	unsigned long i;
   14.12 --
   14.13 - 	printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n");
   14.14 - 	show_registers(regs);
   14.15 - 
   14.16 - 	/* Re-enable the IOCK line, wait for a few seconds */
   14.17 --	reason = (reason & 0xf) | 8;
   14.18 --	outb(reason, 0x61);
   14.19 --	i = 2000;
   14.20 --	while (--i) udelay(1000);
   14.21 --	reason &= ~8;
   14.22 --	outb(reason, 0x61);
   14.23 -+	clear_io_check_error(reason);
   14.24 - }
   14.25 - 
   14.26 - static void unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
   14.27 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/mach-default/mach_traps.h ./include/asm-i386/mach-default/mach_traps.h
   14.28 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/mach-default/mach_traps.h	2006-01-03 03:21:10.000000000 +0000
   14.29 -+++ ./include/asm-i386/mach-default/mach_traps.h	2006-02-27 15:55:23.000000000 +0000
   14.30 -@@ -15,6 +15,18 @@ static inline void clear_mem_error(unsig
   14.31 - 	outb(reason, 0x61);
   14.32 - }
   14.33 - 
   14.34 -+static inline void clear_io_check_error(unsigned char reason)
   14.35 -+{
   14.36 -+	unsigned long i;
   14.37 -+
   14.38 -+	reason = (reason & 0xf) | 8;
   14.39 -+	outb(reason, 0x61);
   14.40 -+	i = 2000;
   14.41 -+	while (--i) udelay(1000);
   14.42 -+	reason &= ~8;
   14.43 -+	outb(reason, 0x61);
   14.44 -+}
   14.45 -+
   14.46 - static inline unsigned char get_nmi_reason(void)
   14.47 - {
   14.48 - 	return inb(0x61);
    15.1 --- a/patches/linux-2.6.16-rc5/net-csum.patch	Fri Mar 17 15:37:28 2006 -0700
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,41 +0,0 @@
    15.4 -diff -pruN ../pristine-linux-2.6.16-rc5/net/ipv4/netfilter/ip_nat_proto_tcp.c ./net/ipv4/netfilter/ip_nat_proto_tcp.c
    15.5 ---- ../pristine-linux-2.6.16-rc5/net/ipv4/netfilter/ip_nat_proto_tcp.c	2006-02-27 15:47:38.000000000 +0000
    15.6 -+++ ./net/ipv4/netfilter/ip_nat_proto_tcp.c	2006-02-27 15:55:25.000000000 +0000
    15.7 -@@ -129,10 +129,14 @@ tcp_manip_pkt(struct sk_buff **pskb,
    15.8 - 	if (hdrsize < sizeof(*hdr))
    15.9 - 		return 1;
   15.10 - 
   15.11 --	hdr->check = ip_nat_cheat_check(~oldip, newip,
   15.12 -+	if ((*pskb)->proto_csum_blank) {
   15.13 -+		hdr->check = ip_nat_cheat_check(oldip, ~newip, hdr->check);
   15.14 -+	} else {
   15.15 -+		hdr->check = ip_nat_cheat_check(~oldip, newip,
   15.16 - 					ip_nat_cheat_check(oldport ^ 0xFFFF,
   15.17 - 							   newport,
   15.18 - 							   hdr->check));
   15.19 -+	}
   15.20 - 	return 1;
   15.21 - }
   15.22 - 
   15.23 -diff -pruN ../pristine-linux-2.6.16-rc5/net/ipv4/netfilter/ip_nat_proto_udp.c ./net/ipv4/netfilter/ip_nat_proto_udp.c
   15.24 ---- ../pristine-linux-2.6.16-rc5/net/ipv4/netfilter/ip_nat_proto_udp.c	2006-02-27 15:47:38.000000000 +0000
   15.25 -+++ ./net/ipv4/netfilter/ip_nat_proto_udp.c	2006-02-27 15:55:25.000000000 +0000
   15.26 -@@ -113,11 +113,16 @@ udp_manip_pkt(struct sk_buff **pskb,
   15.27 - 		newport = tuple->dst.u.udp.port;
   15.28 - 		portptr = &hdr->dest;
   15.29 - 	}
   15.30 --	if (hdr->check) /* 0 is a special case meaning no checksum */
   15.31 --		hdr->check = ip_nat_cheat_check(~oldip, newip,
   15.32 -+	if (hdr->check) { /* 0 is a special case meaning no checksum */
   15.33 -+		if ((*pskb)->proto_csum_blank) {
   15.34 -+			hdr->check = ip_nat_cheat_check(oldip, ~newip, hdr->check);
   15.35 -+		} else {
   15.36 -+			hdr->check = ip_nat_cheat_check(~oldip, newip,
   15.37 - 					ip_nat_cheat_check(*portptr ^ 0xFFFF,
   15.38 - 							   newport,
   15.39 - 							   hdr->check));
   15.40 -+		}
   15.41 -+	}
   15.42 - 	*portptr = newport;
   15.43 - 	return 1;
   15.44 - }
    16.1 --- a/patches/linux-2.6.16-rc5/pmd-shared.patch	Fri Mar 17 15:37:28 2006 -0700
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,111 +0,0 @@
    16.4 -diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/mm/pageattr.c ./arch/i386/mm/pageattr.c
    16.5 ---- ../pristine-linux-2.6.16-rc5/arch/i386/mm/pageattr.c	2006-02-27 15:46:58.000000000 +0000
    16.6 -+++ ./arch/i386/mm/pageattr.c	2006-02-27 15:55:31.000000000 +0000
    16.7 -@@ -78,7 +78,7 @@ static void set_pmd_pte(pte_t *kpte, uns
    16.8 - 	unsigned long flags;
    16.9 - 
   16.10 - 	set_pte_atomic(kpte, pte); 	/* change init_mm */
   16.11 --	if (PTRS_PER_PMD > 1)
   16.12 -+	if (HAVE_SHARED_KERNEL_PMD)
   16.13 - 		return;
   16.14 - 
   16.15 - 	spin_lock_irqsave(&pgd_lock, flags);
   16.16 -diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/mm/pgtable.c ./arch/i386/mm/pgtable.c
   16.17 ---- ../pristine-linux-2.6.16-rc5/arch/i386/mm/pgtable.c	2006-01-03 03:21:10.000000000 +0000
   16.18 -+++ ./arch/i386/mm/pgtable.c	2006-02-27 15:55:31.000000000 +0000
   16.19 -@@ -215,9 +215,10 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
   16.20 - 		spin_lock_irqsave(&pgd_lock, flags);
   16.21 - 	}
   16.22 - 
   16.23 --	clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
   16.24 --			swapper_pg_dir + USER_PTRS_PER_PGD,
   16.25 --			KERNEL_PGD_PTRS);
   16.26 -+	if (PTRS_PER_PMD == 1 || HAVE_SHARED_KERNEL_PMD)
   16.27 -+		clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
   16.28 -+				swapper_pg_dir + USER_PTRS_PER_PGD,
   16.29 -+				KERNEL_PGD_PTRS);
   16.30 - 	if (PTRS_PER_PMD > 1)
   16.31 - 		return;
   16.32 - 
   16.33 -@@ -249,6 +250,30 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
   16.34 - 			goto out_oom;
   16.35 - 		set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));
   16.36 - 	}
   16.37 -+
   16.38 -+	if (!HAVE_SHARED_KERNEL_PMD) {
   16.39 -+		unsigned long flags;
   16.40 -+
   16.41 -+		for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   16.42 -+			pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
   16.43 -+			if (!pmd)
   16.44 -+				goto out_oom;
   16.45 -+			set_pgd(&pgd[USER_PTRS_PER_PGD], __pgd(1 + __pa(pmd)));
   16.46 -+		}
   16.47 -+
   16.48 -+		spin_lock_irqsave(&pgd_lock, flags);
   16.49 -+		for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   16.50 -+			unsigned long v = (unsigned long)i << PGDIR_SHIFT;
   16.51 -+			pgd_t *kpgd = pgd_offset_k(v);
   16.52 -+			pud_t *kpud = pud_offset(kpgd, v);
   16.53 -+			pmd_t *kpmd = pmd_offset(kpud, v);
   16.54 -+			pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   16.55 -+			memcpy(pmd, kpmd, PAGE_SIZE);
   16.56 -+		}
   16.57 -+		pgd_list_add(pgd);
   16.58 -+		spin_unlock_irqrestore(&pgd_lock, flags);
   16.59 -+	}
   16.60 -+
   16.61 - 	return pgd;
   16.62 - 
   16.63 - out_oom:
   16.64 -@@ -263,9 +288,23 @@ void pgd_free(pgd_t *pgd)
   16.65 - 	int i;
   16.66 - 
   16.67 - 	/* in the PAE case user pgd entries are overwritten before usage */
   16.68 --	if (PTRS_PER_PMD > 1)
   16.69 --		for (i = 0; i < USER_PTRS_PER_PGD; ++i)
   16.70 --			kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1));
   16.71 -+	if (PTRS_PER_PMD > 1) {
   16.72 -+		for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
   16.73 -+			pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   16.74 -+			kmem_cache_free(pmd_cache, pmd);
   16.75 -+		}
   16.76 -+		if (!HAVE_SHARED_KERNEL_PMD) {
   16.77 -+			unsigned long flags;
   16.78 -+			spin_lock_irqsave(&pgd_lock, flags);
   16.79 -+			pgd_list_del(pgd);
   16.80 -+			spin_unlock_irqrestore(&pgd_lock, flags);
   16.81 -+			for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   16.82 -+				pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   16.83 -+				memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
   16.84 -+				kmem_cache_free(pmd_cache, pmd);
   16.85 -+			}
   16.86 -+		}
   16.87 -+	}
   16.88 - 	/* in the non-PAE case, free_pgtables() clears user pgd entries */
   16.89 - 	kmem_cache_free(pgd_cache, pgd);
   16.90 - }
   16.91 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/pgtable-2level-defs.h ./include/asm-i386/pgtable-2level-defs.h
   16.92 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/pgtable-2level-defs.h	2006-01-03 03:21:10.000000000 +0000
   16.93 -+++ ./include/asm-i386/pgtable-2level-defs.h	2006-02-27 15:55:31.000000000 +0000
   16.94 -@@ -1,6 +1,8 @@
   16.95 - #ifndef _I386_PGTABLE_2LEVEL_DEFS_H
   16.96 - #define _I386_PGTABLE_2LEVEL_DEFS_H
   16.97 - 
   16.98 -+#define HAVE_SHARED_KERNEL_PMD 0
   16.99 -+
  16.100 - /*
  16.101 -  * traditional i386 two-level paging structure:
  16.102 -  */
  16.103 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/pgtable-3level-defs.h ./include/asm-i386/pgtable-3level-defs.h
  16.104 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/pgtable-3level-defs.h	2006-01-03 03:21:10.000000000 +0000
  16.105 -+++ ./include/asm-i386/pgtable-3level-defs.h	2006-02-27 15:55:31.000000000 +0000
  16.106 -@@ -1,6 +1,8 @@
  16.107 - #ifndef _I386_PGTABLE_3LEVEL_DEFS_H
  16.108 - #define _I386_PGTABLE_3LEVEL_DEFS_H
  16.109 - 
  16.110 -+#define HAVE_SHARED_KERNEL_PMD 1
  16.111 -+
  16.112 - /*
  16.113 -  * PGDIR_SHIFT determines what a top-level page table entry can map
  16.114 -  */
    17.1 --- a/patches/linux-2.6.16-rc5/smp-alts.patch	Fri Mar 17 15:37:28 2006 -0700
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,591 +0,0 @@
    17.4 -diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/Kconfig ./arch/i386/Kconfig
    17.5 ---- ../pristine-linux-2.6.16-rc5/arch/i386/Kconfig	2006-02-27 15:46:58.000000000 +0000
    17.6 -+++ ./arch/i386/Kconfig	2006-02-27 15:55:34.000000000 +0000
    17.7 -@@ -202,6 +202,19 @@ config SMP
    17.8 - 
    17.9 - 	  If you don't know what to do here, say N.
   17.10 - 
   17.11 -+config SMP_ALTERNATIVES
   17.12 -+	bool "SMP alternatives support (EXPERIMENTAL)"
   17.13 -+	depends on SMP && EXPERIMENTAL
   17.14 -+	help
   17.15 -+	  Try to reduce the overhead of running an SMP kernel on a uniprocessor
   17.16 -+	  host slightly by replacing certain key instruction sequences
   17.17 -+	  according to whether we currently have more than one CPU available.
   17.18 -+	  This should provide a noticeable boost to performance when
   17.19 -+	  running SMP kernels on UP machines, and have negligible impact
   17.20 -+	  when running on an true SMP host.
   17.21 -+
   17.22 -+          If unsure, say N.
   17.23 -+	  
   17.24 - config NR_CPUS
   17.25 - 	int "Maximum number of CPUs (2-255)"
   17.26 - 	range 2 255
   17.27 -diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/kernel/Makefile ./arch/i386/kernel/Makefile
   17.28 ---- ../pristine-linux-2.6.16-rc5/arch/i386/kernel/Makefile	2006-02-27 15:46:58.000000000 +0000
   17.29 -+++ ./arch/i386/kernel/Makefile	2006-02-27 15:55:34.000000000 +0000
   17.30 -@@ -37,6 +37,7 @@ obj-$(CONFIG_EFI) 		+= efi.o efi_stub.o
   17.31 - obj-$(CONFIG_DOUBLEFAULT) 	+= doublefault.o
   17.32 - obj-$(CONFIG_VM86)		+= vm86.o
   17.33 - obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
   17.34 -+obj-$(CONFIG_SMP_ALTERNATIVES)  += smpalts.o
   17.35 - 
   17.36 - EXTRA_AFLAGS   := -traditional
   17.37 - 
   17.38 -diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/kernel/smpalts.c ./arch/i386/kernel/smpalts.c
   17.39 ---- ../pristine-linux-2.6.16-rc5/arch/i386/kernel/smpalts.c	1970-01-01 01:00:00.000000000 +0100
   17.40 -+++ ./arch/i386/kernel/smpalts.c	2006-02-27 15:55:34.000000000 +0000
   17.41 -@@ -0,0 +1,85 @@
   17.42 -+#include <linux/kernel.h>
   17.43 -+#include <asm/system.h>
   17.44 -+#include <asm/smp_alt.h>
   17.45 -+#include <asm/processor.h>
   17.46 -+#include <asm/string.h>
   17.47 -+
   17.48 -+struct smp_replacement_record {
   17.49 -+	unsigned char targ_size;
   17.50 -+	unsigned char smp1_size;
   17.51 -+	unsigned char smp2_size;
   17.52 -+	unsigned char up_size;
   17.53 -+	unsigned char feature;
   17.54 -+	unsigned char data[0];
   17.55 -+};
   17.56 -+
   17.57 -+struct smp_alternative_record {
   17.58 -+	void *targ_start;
   17.59 -+	struct smp_replacement_record *repl;
   17.60 -+};
   17.61 -+
   17.62 -+extern struct smp_alternative_record __start_smp_alternatives_table,
   17.63 -+  __stop_smp_alternatives_table;
   17.64 -+extern unsigned long __init_begin, __init_end;
   17.65 -+
   17.66 -+void prepare_for_smp(void)
   17.67 -+{
   17.68 -+	struct smp_alternative_record *r;
   17.69 -+	printk(KERN_INFO "Enabling SMP...\n");
   17.70 -+	for (r = &__start_smp_alternatives_table;
   17.71 -+	     r != &__stop_smp_alternatives_table;
   17.72 -+	     r++) {
   17.73 -+		BUG_ON(r->repl->targ_size < r->repl->smp1_size);
   17.74 -+		BUG_ON(r->repl->targ_size < r->repl->smp2_size);
   17.75 -+		BUG_ON(r->repl->targ_size < r->repl->up_size);
   17.76 -+               if (system_state == SYSTEM_RUNNING &&
   17.77 -+                   r->targ_start >= (void *)&__init_begin &&
   17.78 -+                   r->targ_start < (void *)&__init_end)
   17.79 -+                       continue;
   17.80 -+		if (r->repl->feature != (unsigned char)-1 &&
   17.81 -+		    boot_cpu_has(r->repl->feature)) {
   17.82 -+			memcpy(r->targ_start,
   17.83 -+			       r->repl->data + r->repl->smp1_size,
   17.84 -+			       r->repl->smp2_size);
   17.85 -+			memset(r->targ_start + r->repl->smp2_size,
   17.86 -+			       0x90,
   17.87 -+			       r->repl->targ_size - r->repl->smp2_size);
   17.88 -+		} else {
   17.89 -+			memcpy(r->targ_start,
   17.90 -+			       r->repl->data,
   17.91 -+			       r->repl->smp1_size);
   17.92 -+			memset(r->targ_start + r->repl->smp1_size,
   17.93 -+			       0x90,
   17.94 -+			       r->repl->targ_size - r->repl->smp1_size);
   17.95 -+		}
   17.96 -+	}
   17.97 -+	/* Paranoia */
   17.98 -+	asm volatile ("jmp 1f\n1:");
   17.99 -+	mb();
  17.100 -+}
  17.101 -+
  17.102 -+void unprepare_for_smp(void)
  17.103 -+{
  17.104 -+	struct smp_alternative_record *r;
  17.105 -+	printk(KERN_INFO "Disabling SMP...\n");
  17.106 -+	for (r = &__start_smp_alternatives_table;
  17.107 -+	     r != &__stop_smp_alternatives_table;
  17.108 -+	     r++) {
  17.109 -+		BUG_ON(r->repl->targ_size < r->repl->smp1_size);
  17.110 -+		BUG_ON(r->repl->targ_size < r->repl->smp2_size);
  17.111 -+		BUG_ON(r->repl->targ_size < r->repl->up_size);
  17.112 -+               if (system_state == SYSTEM_RUNNING &&
  17.113 -+                   r->targ_start >= (void *)&__init_begin &&
  17.114 -+                   r->targ_start < (void *)&__init_end)
  17.115 -+                       continue;
  17.116 -+		memcpy(r->targ_start,
  17.117 -+		       r->repl->data + r->repl->smp1_size + r->repl->smp2_size,
  17.118 -+		       r->repl->up_size);
  17.119 -+		memset(r->targ_start + r->repl->up_size,
  17.120 -+		       0x90,
  17.121 -+		       r->repl->targ_size - r->repl->up_size);
  17.122 -+	}
  17.123 -+	/* Paranoia */
  17.124 -+	asm volatile ("jmp 1f\n1:");
  17.125 -+	mb();
  17.126 -+}
  17.127 -diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/kernel/smpboot.c ./arch/i386/kernel/smpboot.c
  17.128 ---- ../pristine-linux-2.6.16-rc5/arch/i386/kernel/smpboot.c	2006-02-27 15:46:58.000000000 +0000
  17.129 -+++ ./arch/i386/kernel/smpboot.c	2006-02-27 15:55:34.000000000 +0000
  17.130 -@@ -1208,6 +1208,11 @@ static void __init smp_boot_cpus(unsigne
  17.131 - 		if (max_cpus <= cpucount+1)
  17.132 - 			continue;
  17.133 - 
  17.134 -+#ifdef CONFIG_SMP_ALTERNATIVES
  17.135 -+		if (kicked == 1)
  17.136 -+			prepare_for_smp();
  17.137 -+#endif
  17.138 -+
  17.139 - 		if (((cpu = alloc_cpu_id()) <= 0) || do_boot_cpu(apicid, cpu))
  17.140 - 			printk("CPU #%d not responding - cannot use it.\n",
  17.141 - 								apicid);
  17.142 -@@ -1386,6 +1391,11 @@ int __devinit __cpu_up(unsigned int cpu)
  17.143 - 		return -EIO;
  17.144 - 	}
  17.145 - 
  17.146 -+#ifdef CONFIG_SMP_ALTERNATIVES
  17.147 -+	if (num_online_cpus() == 1)
  17.148 -+		prepare_for_smp();
  17.149 -+#endif
  17.150 -+
  17.151 - 	local_irq_enable();
  17.152 - 	per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
  17.153 - 	/* Unleash the CPU! */
  17.154 -diff -pruN ../pristine-linux-2.6.16-rc5/arch/i386/kernel/vmlinux.lds.S ./arch/i386/kernel/vmlinux.lds.S
  17.155 ---- ../pristine-linux-2.6.16-rc5/arch/i386/kernel/vmlinux.lds.S	2006-01-03 03:21:10.000000000 +0000
  17.156 -+++ ./arch/i386/kernel/vmlinux.lds.S	2006-02-27 15:55:34.000000000 +0000
  17.157 -@@ -34,6 +34,13 @@ SECTIONS
  17.158 -   __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
  17.159 -   __stop___ex_table = .;
  17.160 - 
  17.161 -+  . = ALIGN(16);
  17.162 -+  __start_smp_alternatives_table = .;
  17.163 -+  __smp_alternatives : { *(__smp_alternatives) }
  17.164 -+  __stop_smp_alternatives_table = .;
  17.165 -+
  17.166 -+  __smp_replacements : { *(__smp_replacements) }
  17.167 -+
  17.168 -   RODATA
  17.169 - 
  17.170 -   /* writeable */
  17.171 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/atomic.h ./include/asm-i386/atomic.h
  17.172 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/atomic.h	2006-02-27 15:47:25.000000000 +0000
  17.173 -+++ ./include/asm-i386/atomic.h	2006-02-27 15:55:34.000000000 +0000
  17.174 -@@ -4,18 +4,13 @@
  17.175 - #include <linux/config.h>
  17.176 - #include <linux/compiler.h>
  17.177 - #include <asm/processor.h>
  17.178 -+#include <asm/smp_alt.h>
  17.179 - 
  17.180 - /*
  17.181 -  * Atomic operations that C can't guarantee us.  Useful for
  17.182 -  * resource counting etc..
  17.183 -  */
  17.184 - 
  17.185 --#ifdef CONFIG_SMP
  17.186 --#define LOCK "lock ; "
  17.187 --#else
  17.188 --#define LOCK ""
  17.189 --#endif
  17.190 --
  17.191 - /*
  17.192 -  * Make sure gcc doesn't try to be clever and move things around
  17.193 -  * on us. We need to use _exactly_ the address the user gave us,
  17.194 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/bitops.h ./include/asm-i386/bitops.h
  17.195 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/bitops.h	2006-02-27 15:47:25.000000000 +0000
  17.196 -+++ ./include/asm-i386/bitops.h	2006-02-27 15:55:34.000000000 +0000
  17.197 -@@ -7,6 +7,7 @@
  17.198 - 
  17.199 - #include <linux/config.h>
  17.200 - #include <linux/compiler.h>
  17.201 -+#include <asm/smp_alt.h>
  17.202 - 
  17.203 - /*
  17.204 -  * These have to be done with inline assembly: that way the bit-setting
  17.205 -@@ -16,12 +17,6 @@
  17.206 -  * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
  17.207 -  */
  17.208 - 
  17.209 --#ifdef CONFIG_SMP
  17.210 --#define LOCK_PREFIX "lock ; "
  17.211 --#else
  17.212 --#define LOCK_PREFIX ""
  17.213 --#endif
  17.214 --
  17.215 - #define ADDR (*(volatile long *) addr)
  17.216 - 
  17.217 - /**
  17.218 -@@ -41,7 +36,7 @@
  17.219 -  */
  17.220 - static inline void set_bit(int nr, volatile unsigned long * addr)
  17.221 - {
  17.222 --	__asm__ __volatile__( LOCK_PREFIX
  17.223 -+	__asm__ __volatile__( LOCK
  17.224 - 		"btsl %1,%0"
  17.225 - 		:"+m" (ADDR)
  17.226 - 		:"Ir" (nr));
  17.227 -@@ -76,7 +71,7 @@ static inline void __set_bit(int nr, vol
  17.228 -  */
  17.229 - static inline void clear_bit(int nr, volatile unsigned long * addr)
  17.230 - {
  17.231 --	__asm__ __volatile__( LOCK_PREFIX
  17.232 -+	__asm__ __volatile__( LOCK
  17.233 - 		"btrl %1,%0"
  17.234 - 		:"+m" (ADDR)
  17.235 - 		:"Ir" (nr));
  17.236 -@@ -121,7 +116,7 @@ static inline void __change_bit(int nr, 
  17.237 -  */
  17.238 - static inline void change_bit(int nr, volatile unsigned long * addr)
  17.239 - {
  17.240 --	__asm__ __volatile__( LOCK_PREFIX
  17.241 -+	__asm__ __volatile__( LOCK
  17.242 - 		"btcl %1,%0"
  17.243 - 		:"+m" (ADDR)
  17.244 - 		:"Ir" (nr));
  17.245 -@@ -140,7 +135,7 @@ static inline int test_and_set_bit(int n
  17.246 - {
  17.247 - 	int oldbit;
  17.248 - 
  17.249 --	__asm__ __volatile__( LOCK_PREFIX
  17.250 -+	__asm__ __volatile__( LOCK
  17.251 - 		"btsl %2,%1\n\tsbbl %0,%0"
  17.252 - 		:"=r" (oldbit),"+m" (ADDR)
  17.253 - 		:"Ir" (nr) : "memory");
  17.254 -@@ -180,7 +175,7 @@ static inline int test_and_clear_bit(int
  17.255 - {
  17.256 - 	int oldbit;
  17.257 - 
  17.258 --	__asm__ __volatile__( LOCK_PREFIX
  17.259 -+	__asm__ __volatile__( LOCK
  17.260 - 		"btrl %2,%1\n\tsbbl %0,%0"
  17.261 - 		:"=r" (oldbit),"+m" (ADDR)
  17.262 - 		:"Ir" (nr) : "memory");
  17.263 -@@ -231,7 +226,7 @@ static inline int test_and_change_bit(in
  17.264 - {
  17.265 - 	int oldbit;
  17.266 - 
  17.267 --	__asm__ __volatile__( LOCK_PREFIX
  17.268 -+	__asm__ __volatile__( LOCK
  17.269 - 		"btcl %2,%1\n\tsbbl %0,%0"
  17.270 - 		:"=r" (oldbit),"+m" (ADDR)
  17.271 - 		:"Ir" (nr) : "memory");
  17.272 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/futex.h ./include/asm-i386/futex.h
  17.273 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/futex.h	2006-02-27 15:47:25.000000000 +0000
  17.274 -+++ ./include/asm-i386/futex.h	2006-02-27 15:55:34.000000000 +0000
  17.275 -@@ -28,7 +28,7 @@
  17.276 - "1:	movl	%2, %0\n\
  17.277 - 	movl	%0, %3\n"					\
  17.278 - 	insn "\n"						\
  17.279 --"2:	" LOCK_PREFIX "cmpxchgl %3, %2\n\
  17.280 -+"2:	" LOCK "cmpxchgl %3, %2\n\
  17.281 - 	jnz	1b\n\
  17.282 - 3:	.section .fixup,\"ax\"\n\
  17.283 - 4:	mov	%5, %1\n\
  17.284 -@@ -68,7 +68,7 @@ futex_atomic_op_inuser (int encoded_op, 
  17.285 - #endif
  17.286 - 		switch (op) {
  17.287 - 		case FUTEX_OP_ADD:
  17.288 --			__futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret,
  17.289 -+			__futex_atomic_op1(LOCK "xaddl %0, %2", ret,
  17.290 - 					   oldval, uaddr, oparg);
  17.291 - 			break;
  17.292 - 		case FUTEX_OP_OR:
  17.293 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/rwsem.h ./include/asm-i386/rwsem.h
  17.294 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/rwsem.h	2006-01-03 03:21:10.000000000 +0000
  17.295 -+++ ./include/asm-i386/rwsem.h	2006-02-27 15:55:34.000000000 +0000
  17.296 -@@ -40,6 +40,7 @@
  17.297 - 
  17.298 - #include <linux/list.h>
  17.299 - #include <linux/spinlock.h>
  17.300 -+#include <asm/smp_alt.h>
  17.301 - 
  17.302 - struct rwsem_waiter;
  17.303 - 
  17.304 -@@ -99,7 +100,7 @@ static inline void __down_read(struct rw
  17.305 - {
  17.306 - 	__asm__ __volatile__(
  17.307 - 		"# beginning down_read\n\t"
  17.308 --LOCK_PREFIX	"  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old value */
  17.309 -+LOCK	        "  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old value */
  17.310 - 		"  js        2f\n\t" /* jump if we weren't granted the lock */
  17.311 - 		"1:\n\t"
  17.312 - 		LOCK_SECTION_START("")
  17.313 -@@ -130,7 +131,7 @@ static inline int __down_read_trylock(st
  17.314 - 		"  movl	     %1,%2\n\t"
  17.315 - 		"  addl      %3,%2\n\t"
  17.316 - 		"  jle	     2f\n\t"
  17.317 --LOCK_PREFIX	"  cmpxchgl  %2,%0\n\t"
  17.318 -+LOCK	        "  cmpxchgl  %2,%0\n\t"
  17.319 - 		"  jnz	     1b\n\t"
  17.320 - 		"2:\n\t"
  17.321 - 		"# ending __down_read_trylock\n\t"
  17.322 -@@ -150,7 +151,7 @@ static inline void __down_write(struct r
  17.323 - 	tmp = RWSEM_ACTIVE_WRITE_BIAS;
  17.324 - 	__asm__ __volatile__(
  17.325 - 		"# beginning down_write\n\t"
  17.326 --LOCK_PREFIX	"  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
  17.327 -+LOCK	        "  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
  17.328 - 		"  testl     %%edx,%%edx\n\t" /* was the count 0 before? */
  17.329 - 		"  jnz       2f\n\t" /* jump if we weren't granted the lock */
  17.330 - 		"1:\n\t"
  17.331 -@@ -188,7 +189,7 @@ static inline void __up_read(struct rw_s
  17.332 - 	__s32 tmp = -RWSEM_ACTIVE_READ_BIAS;
  17.333 - 	__asm__ __volatile__(
  17.334 - 		"# beginning __up_read\n\t"
  17.335 --LOCK_PREFIX	"  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
  17.336 -+LOCK	        "  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
  17.337 - 		"  js        2f\n\t" /* jump if the lock is being waited upon */
  17.338 - 		"1:\n\t"
  17.339 - 		LOCK_SECTION_START("")
  17.340 -@@ -214,7 +215,7 @@ static inline void __up_write(struct rw_
  17.341 - 	__asm__ __volatile__(
  17.342 - 		"# beginning __up_write\n\t"
  17.343 - 		"  movl      %2,%%edx\n\t"
  17.344 --LOCK_PREFIX	"  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
  17.345 -+LOCK	        "  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
  17.346 - 		"  jnz       2f\n\t" /* jump if the lock is being waited upon */
  17.347 - 		"1:\n\t"
  17.348 - 		LOCK_SECTION_START("")
  17.349 -@@ -239,7 +240,7 @@ static inline void __downgrade_write(str
  17.350 - {
  17.351 - 	__asm__ __volatile__(
  17.352 - 		"# beginning __downgrade_write\n\t"
  17.353 --LOCK_PREFIX	"  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
  17.354 -+LOCK	        "  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
  17.355 - 		"  js        2f\n\t" /* jump if the lock is being waited upon */
  17.356 - 		"1:\n\t"
  17.357 - 		LOCK_SECTION_START("")
  17.358 -@@ -263,7 +264,7 @@ LOCK_PREFIX	"  addl      %2,(%%eax)\n\t"
  17.359 - static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem)
  17.360 - {
  17.361 - 	__asm__ __volatile__(
  17.362 --LOCK_PREFIX	"addl %1,%0"
  17.363 -+LOCK	          "addl %1,%0"
  17.364 - 		: "=m"(sem->count)
  17.365 - 		: "ir"(delta), "m"(sem->count));
  17.366 - }
  17.367 -@@ -276,7 +277,7 @@ static inline int rwsem_atomic_update(in
  17.368 - 	int tmp = delta;
  17.369 - 
  17.370 - 	__asm__ __volatile__(
  17.371 --LOCK_PREFIX	"xadd %0,(%2)"
  17.372 -+LOCK  	          "xadd %0,(%2)"
  17.373 - 		: "+r"(tmp), "=m"(sem->count)
  17.374 - 		: "r"(sem), "m"(sem->count)
  17.375 - 		: "memory");
  17.376 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/smp_alt.h ./include/asm-i386/smp_alt.h
  17.377 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/smp_alt.h	1970-01-01 01:00:00.000000000 +0100
  17.378 -+++ ./include/asm-i386/smp_alt.h	2006-02-27 15:55:34.000000000 +0000
  17.379 -@@ -0,0 +1,32 @@
  17.380 -+#ifndef __ASM_SMP_ALT_H__
  17.381 -+#define __ASM_SMP_ALT_H__
  17.382 -+
  17.383 -+#include <linux/config.h>
  17.384 -+
  17.385 -+#ifdef CONFIG_SMP
  17.386 -+#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
  17.387 -+#define LOCK \
  17.388 -+        "6677: nop\n" \
  17.389 -+	".section __smp_alternatives,\"a\"\n" \
  17.390 -+	".long 6677b\n" \
  17.391 -+	".long 6678f\n" \
  17.392 -+	".previous\n" \
  17.393 -+	".section __smp_replacements,\"a\"\n" \
  17.394 -+	"6678: .byte 1\n" \
  17.395 -+	".byte 1\n" \
  17.396 -+	".byte 0\n" \
  17.397 -+        ".byte 1\n" \
  17.398 -+	".byte -1\n" \
  17.399 -+	"lock\n" \
  17.400 -+	"nop\n" \
  17.401 -+	".previous\n"
  17.402 -+void prepare_for_smp(void);
  17.403 -+void unprepare_for_smp(void);
  17.404 -+#else
  17.405 -+#define LOCK "lock ; "
  17.406 -+#endif
  17.407 -+#else
  17.408 -+#define LOCK ""
  17.409 -+#endif
  17.410 -+
  17.411 -+#endif /* __ASM_SMP_ALT_H__ */
  17.412 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/spinlock.h ./include/asm-i386/spinlock.h
  17.413 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/spinlock.h	2006-01-03 03:21:10.000000000 +0000
  17.414 -+++ ./include/asm-i386/spinlock.h	2006-02-27 15:55:34.000000000 +0000
  17.415 -@@ -6,6 +6,7 @@
  17.416 - #include <asm/page.h>
  17.417 - #include <linux/config.h>
  17.418 - #include <linux/compiler.h>
  17.419 -+#include <asm/smp_alt.h>
  17.420 - 
  17.421 - /*
  17.422 -  * Your basic SMP spinlocks, allowing only a single CPU anywhere
  17.423 -@@ -23,7 +24,8 @@
  17.424 - 
  17.425 - #define __raw_spin_lock_string \
  17.426 - 	"\n1:\t" \
  17.427 --	"lock ; decb %0\n\t" \
  17.428 -+	LOCK \
  17.429 -+	"decb %0\n\t" \
  17.430 - 	"jns 3f\n" \
  17.431 - 	"2:\t" \
  17.432 - 	"rep;nop\n\t" \
  17.433 -@@ -34,7 +36,8 @@
  17.434 - 
  17.435 - #define __raw_spin_lock_string_flags \
  17.436 - 	"\n1:\t" \
  17.437 --	"lock ; decb %0\n\t" \
  17.438 -+	LOCK \
  17.439 -+	"decb %0\n\t" \
  17.440 - 	"jns 4f\n\t" \
  17.441 - 	"2:\t" \
  17.442 - 	"testl $0x200, %1\n\t" \
  17.443 -@@ -65,10 +68,34 @@ static inline void __raw_spin_lock_flags
  17.444 - static inline int __raw_spin_trylock(raw_spinlock_t *lock)
  17.445 - {
  17.446 - 	char oldval;
  17.447 -+#ifdef CONFIG_SMP_ALTERNATIVES
  17.448 - 	__asm__ __volatile__(
  17.449 --		"xchgb %b0,%1"
  17.450 -+		"1:movb %1,%b0\n"
  17.451 -+		"movb $0,%1\n"
  17.452 -+		"2:"
  17.453 -+		".section __smp_alternatives,\"a\"\n"
  17.454 -+		".long 1b\n"
  17.455 -+		".long 3f\n"
  17.456 -+		".previous\n"
  17.457 -+		".section __smp_replacements,\"a\"\n"
  17.458 -+		"3: .byte 2b - 1b\n"
  17.459 -+		".byte 5f-4f\n"
  17.460 -+		".byte 0\n"
  17.461 -+		".byte 6f-5f\n"
  17.462 -+		".byte -1\n"
  17.463 -+		"4: xchgb %b0,%1\n"
  17.464 -+		"5: movb %1,%b0\n"
  17.465 -+		"movb $0,%1\n"
  17.466 -+		"6:\n"
  17.467 -+		".previous\n"
  17.468 - 		:"=q" (oldval), "=m" (lock->slock)
  17.469 - 		:"0" (0) : "memory");
  17.470 -+#else
  17.471 -+	__asm__ __volatile__(
  17.472 -+		"xchgb %b0,%1\n"
  17.473 -+		:"=q" (oldval), "=m" (lock->slock)
  17.474 -+		:"0" (0) : "memory");
  17.475 -+#endif
  17.476 - 	return oldval > 0;
  17.477 - }
  17.478 - 
  17.479 -@@ -178,12 +205,12 @@ static inline int __raw_write_trylock(ra
  17.480 - 
  17.481 - static inline void __raw_read_unlock(raw_rwlock_t *rw)
  17.482 - {
  17.483 --	asm volatile("lock ; incl %0" :"=m" (rw->lock) : : "memory");
  17.484 -+	asm volatile(LOCK "incl %0" :"=m" (rw->lock) : : "memory");
  17.485 - }
  17.486 - 
  17.487 - static inline void __raw_write_unlock(raw_rwlock_t *rw)
  17.488 - {
  17.489 --	asm volatile("lock ; addl $" RW_LOCK_BIAS_STR ", %0"
  17.490 -+	asm volatile(LOCK "addl $" RW_LOCK_BIAS_STR ", %0"
  17.491 - 				 : "=m" (rw->lock) : : "memory");
  17.492 - }
  17.493 - 
  17.494 -diff -pruN ../pristine-linux-2.6.16-rc5/include/asm-i386/system.h ./include/asm-i386/system.h
  17.495 ---- ../pristine-linux-2.6.16-rc5/include/asm-i386/system.h	2006-02-27 15:47:25.000000000 +0000
  17.496 -+++ ./include/asm-i386/system.h	2006-02-27 15:55:34.000000000 +0000
  17.497 -@@ -5,7 +5,7 @@
  17.498 - #include <linux/kernel.h>
  17.499 - #include <asm/segment.h>
  17.500 - #include <asm/cpufeature.h>
  17.501 --#include <linux/bitops.h> /* for LOCK_PREFIX */
  17.502 -+#include <asm/smp_alt.h>
  17.503 - 
  17.504 - #ifdef __KERNEL__
  17.505 - 
  17.506 -@@ -271,19 +271,19 @@ static inline unsigned long __cmpxchg(vo
  17.507 - 	unsigned long prev;
  17.508 - 	switch (size) {
  17.509 - 	case 1:
  17.510 --		__asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
  17.511 -+		__asm__ __volatile__(LOCK "cmpxchgb %b1,%2"
  17.512 - 				     : "=a"(prev)
  17.513 - 				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
  17.514 - 				     : "memory");
  17.515 - 		return prev;
  17.516 - 	case 2:
  17.517 --		__asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
  17.518 -+		__asm__ __volatile__(LOCK "cmpxchgw %w1,%2"
  17.519 - 				     : "=a"(prev)
  17.520 - 				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
  17.521 - 				     : "memory");
  17.522 - 		return prev;
  17.523 - 	case 4:
  17.524 --		__asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
  17.525 -+		__asm__ __volatile__(LOCK "cmpxchgl %1,%2"
  17.526 - 				     : "=a"(prev)
  17.527 - 				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
  17.528 - 				     : "memory");
  17.529 -@@ -336,7 +336,7 @@ static inline unsigned long long __cmpxc
  17.530 - 				      unsigned long long new)
  17.531 - {
  17.532 - 	unsigned long long prev;
  17.533 --	__asm__ __volatile__(LOCK_PREFIX "cmpxchg8b %3"
  17.534 -+	__asm__ __volatile__(LOCK "cmpxchg8b %3"
  17.535 - 			     : "=A"(prev)
  17.536 - 			     : "b"((unsigned long)new),
  17.537 - 			       "c"((unsigned long)(new >> 32)),
  17.538 -@@ -503,11 +503,55 @@ struct alt_instr { 
  17.539 - #endif
  17.540 - 
  17.541 - #ifdef CONFIG_SMP
  17.542 -+#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
  17.543 -+#define smp_alt_mb(instr)                                           \
  17.544 -+__asm__ __volatile__("6667:\nnop\nnop\nnop\nnop\nnop\nnop\n6668:\n" \
  17.545 -+		     ".section __smp_alternatives,\"a\"\n"          \
  17.546 -+		     ".long 6667b\n"                                \
  17.547 -+                     ".long 6673f\n"                                \
  17.548 -+		     ".previous\n"                                  \
  17.549 -+		     ".section __smp_replacements,\"a\"\n"          \
  17.550 -+		     "6673:.byte 6668b-6667b\n"                     \
  17.551 -+		     ".byte 6670f-6669f\n"                          \
  17.552 -+		     ".byte 6671f-6670f\n"                          \
  17.553 -+                     ".byte 0\n"                                    \
  17.554 -+		     ".byte %c0\n"                                  \
  17.555 -+		     "6669:lock;addl $0,0(%%esp)\n"                 \
  17.556 -+		     "6670:" instr "\n"                             \
  17.557 -+		     "6671:\n"                                      \
  17.558 -+		     ".previous\n"                                  \
  17.559 -+		     :                                              \
  17.560 -+		     : "i" (X86_FEATURE_XMM2)                       \
  17.561 -+		     : "memory")
  17.562 -+#define smp_rmb() smp_alt_mb("lfence")
  17.563 -+#define smp_mb()  smp_alt_mb("mfence")
  17.564 -+#define set_mb(var, value) do {                                     \
  17.565 -+unsigned long __set_mb_temp;                                        \
  17.566 -+__asm__ __volatile__("6667:movl %1, %0\n6668:\n"                    \
  17.567 -+		     ".section __smp_alternatives,\"a\"\n"          \
  17.568 -+		     ".long 6667b\n"                                \
  17.569 -+		     ".long 6673f\n"                                \
  17.570 -+		     ".previous\n"                                  \
  17.571 -+		     ".section __smp_replacements,\"a\"\n"          \
  17.572 -+		     "6673: .byte 6668b-6667b\n"                    \
  17.573 -+		     ".byte 6670f-6669f\n"                          \
  17.574 -+		     ".byte 0\n"                                    \
  17.575 -+		     ".byte 6671f-6670f\n"                          \
  17.576 -+		     ".byte -1\n"                                   \
  17.577 -+		     "6669: xchg %1, %0\n"                          \
  17.578 -+		     "6670:movl %1, %0\n"                           \
  17.579 -+		     "6671:\n"                                      \
  17.580 -+		     ".previous\n"                                  \
  17.581 -+		     : "=m" (var), "=r" (__set_mb_temp)             \
  17.582 -+		     : "1" (value)                                  \
  17.583 -+		     : "memory"); } while (0)
  17.584 -+#else
  17.585 - #define smp_mb()	mb()
  17.586 - #define smp_rmb()	rmb()
  17.587 -+#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
  17.588 -+#endif
  17.589 - #define smp_wmb()	wmb()
  17.590 - #define smp_read_barrier_depends()	read_barrier_depends()
  17.591 --#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
  17.592 - #else
  17.593 - #define smp_mb()	barrier()
  17.594 - #define smp_rmb()	barrier()
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/patches/linux-2.6.16-rc6/i386-mach-io-check-nmi.patch	Sat Mar 18 10:59:11 2006 +0100
    18.3 @@ -0,0 +1,45 @@
    18.4 +diff -pruN ../pristine-linux-2.6.16-rc6/arch/i386/kernel/traps.c ./arch/i386/kernel/traps.c
    18.5 +--- ../pristine-linux-2.6.16-rc6/arch/i386/kernel/traps.c	2006-03-17 22:59:01.000000000 +0000
    18.6 ++++ ./arch/i386/kernel/traps.c	2006-03-17 23:04:16.000000000 +0000
    18.7 +@@ -567,18 +567,11 @@ static void mem_parity_error(unsigned ch
    18.8 + 
    18.9 + static void io_check_error(unsigned char reason, struct pt_regs * regs)
   18.10 + {
   18.11 +-	unsigned long i;
   18.12 +-
   18.13 + 	printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n");
   18.14 + 	show_registers(regs);
   18.15 + 
   18.16 + 	/* Re-enable the IOCK line, wait for a few seconds */
   18.17 +-	reason = (reason & 0xf) | 8;
   18.18 +-	outb(reason, 0x61);
   18.19 +-	i = 2000;
   18.20 +-	while (--i) udelay(1000);
   18.21 +-	reason &= ~8;
   18.22 +-	outb(reason, 0x61);
   18.23 ++	clear_io_check_error(reason);
   18.24 + }
   18.25 + 
   18.26 + static void unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
   18.27 +diff -pruN ../pristine-linux-2.6.16-rc6/include/asm-i386/mach-default/mach_traps.h ./include/asm-i386/mach-default/mach_traps.h
   18.28 +--- ../pristine-linux-2.6.16-rc6/include/asm-i386/mach-default/mach_traps.h	2006-01-03 03:21:10.000000000 +0000
   18.29 ++++ ./include/asm-i386/mach-default/mach_traps.h	2006-03-17 23:04:16.000000000 +0000
   18.30 +@@ -15,6 +15,18 @@ static inline void clear_mem_error(unsig
   18.31 + 	outb(reason, 0x61);
   18.32 + }
   18.33 + 
   18.34 ++static inline void clear_io_check_error(unsigned char reason)
   18.35 ++{
   18.36 ++	unsigned long i;
   18.37 ++
   18.38 ++	reason = (reason & 0xf) | 8;
   18.39 ++	outb(reason, 0x61);
   18.40 ++	i = 2000;
   18.41 ++	while (--i) udelay(1000);
   18.42 ++	reason &= ~8;
   18.43 ++	outb(reason, 0x61);
   18.44 ++}
   18.45 ++
   18.46 + static inline unsigned char get_nmi_reason(void)
   18.47 + {
   18.48 + 	return inb(0x61);
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/patches/linux-2.6.16-rc6/net-csum.patch	Sat Mar 18 10:59:11 2006 +0100
    19.3 @@ -0,0 +1,41 @@
    19.4 +diff -pruN ../pristine-linux-2.6.16-rc6/net/ipv4/netfilter/ip_nat_proto_tcp.c ./net/ipv4/netfilter/ip_nat_proto_tcp.c
    19.5 +--- ../pristine-linux-2.6.16-rc6/net/ipv4/netfilter/ip_nat_proto_tcp.c	2006-03-17 22:59:16.000000000 +0000
    19.6 ++++ ./net/ipv4/netfilter/ip_nat_proto_tcp.c	2006-03-17 23:04:19.000000000 +0000
    19.7 +@@ -129,10 +129,14 @@ tcp_manip_pkt(struct sk_buff **pskb,
    19.8 + 	if (hdrsize < sizeof(*hdr))
    19.9 + 		return 1;
   19.10 + 
   19.11 +-	hdr->check = ip_nat_cheat_check(~oldip, newip,
   19.12 ++	if ((*pskb)->proto_csum_blank) {
   19.13 ++		hdr->check = ip_nat_cheat_check(oldip, ~newip, hdr->check);
   19.14 ++	} else {
   19.15 ++		hdr->check = ip_nat_cheat_check(~oldip, newip,
   19.16 + 					ip_nat_cheat_check(oldport ^ 0xFFFF,
   19.17 + 							   newport,
   19.18 + 							   hdr->check));
   19.19 ++	}
   19.20 + 	return 1;
   19.21 + }
   19.22 + 
   19.23 +diff -pruN ../pristine-linux-2.6.16-rc6/net/ipv4/netfilter/ip_nat_proto_udp.c ./net/ipv4/netfilter/ip_nat_proto_udp.c
   19.24 +--- ../pristine-linux-2.6.16-rc6/net/ipv4/netfilter/ip_nat_proto_udp.c	2006-03-17 22:59:16.000000000 +0000
   19.25 ++++ ./net/ipv4/netfilter/ip_nat_proto_udp.c	2006-03-17 23:04:19.000000000 +0000
   19.26 +@@ -113,11 +113,16 @@ udp_manip_pkt(struct sk_buff **pskb,
   19.27 + 		newport = tuple->dst.u.udp.port;
   19.28 + 		portptr = &hdr->dest;
   19.29 + 	}
   19.30 +-	if (hdr->check) /* 0 is a special case meaning no checksum */
   19.31 +-		hdr->check = ip_nat_cheat_check(~oldip, newip,
   19.32 ++	if (hdr->check) { /* 0 is a special case meaning no checksum */
   19.33 ++		if ((*pskb)->proto_csum_blank) {
   19.34 ++			hdr->check = ip_nat_cheat_check(oldip, ~newip, hdr->check);
   19.35 ++		} else {
   19.36 ++			hdr->check = ip_nat_cheat_check(~oldip, newip,
   19.37 + 					ip_nat_cheat_check(*portptr ^ 0xFFFF,
   19.38 + 							   newport,
   19.39 + 							   hdr->check));
   19.40 ++		}
   19.41 ++	}
   19.42 + 	*portptr = newport;
   19.43 + 	return 1;
   19.44 + }
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/patches/linux-2.6.16-rc6/pmd-shared.patch	Sat Mar 18 10:59:11 2006 +0100
    20.3 @@ -0,0 +1,111 @@
    20.4 +diff -pruN ../pristine-linux-2.6.16-rc6/arch/i386/mm/pageattr.c ./arch/i386/mm/pageattr.c
    20.5 +--- ../pristine-linux-2.6.16-rc6/arch/i386/mm/pageattr.c	2006-03-17 22:59:01.000000000 +0000
    20.6 ++++ ./arch/i386/mm/pageattr.c	2006-03-17 23:04:21.000000000 +0000
    20.7 +@@ -78,7 +78,7 @@ static void set_pmd_pte(pte_t *kpte, uns
    20.8 + 	unsigned long flags;
    20.9 + 
   20.10 + 	set_pte_atomic(kpte, pte); 	/* change init_mm */
   20.11 +-	if (PTRS_PER_PMD > 1)
   20.12 ++	if (HAVE_SHARED_KERNEL_PMD)
   20.13 + 		return;
   20.14 + 
   20.15 + 	spin_lock_irqsave(&pgd_lock, flags);
   20.16 +diff -pruN ../pristine-linux-2.6.16-rc6/arch/i386/mm/pgtable.c ./arch/i386/mm/pgtable.c
   20.17 +--- ../pristine-linux-2.6.16-rc6/arch/i386/mm/pgtable.c	2006-01-03 03:21:10.000000000 +0000
   20.18 ++++ ./arch/i386/mm/pgtable.c	2006-03-17 23:04:21.000000000 +0000
   20.19 +@@ -215,9 +215,10 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
   20.20 + 		spin_lock_irqsave(&pgd_lock, flags);
   20.21 + 	}
   20.22 + 
   20.23 +-	clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
   20.24 +-			swapper_pg_dir + USER_PTRS_PER_PGD,
   20.25 +-			KERNEL_PGD_PTRS);
   20.26 ++	if (PTRS_PER_PMD == 1 || HAVE_SHARED_KERNEL_PMD)
   20.27 ++		clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
   20.28 ++				swapper_pg_dir + USER_PTRS_PER_PGD,
   20.29 ++				KERNEL_PGD_PTRS);
   20.30 + 	if (PTRS_PER_PMD > 1)
   20.31 + 		return;
   20.32 + 
   20.33 +@@ -249,6 +250,30 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
   20.34 + 			goto out_oom;
   20.35 + 		set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));
   20.36 + 	}
   20.37 ++
   20.38 ++	if (!HAVE_SHARED_KERNEL_PMD) {
   20.39 ++		unsigned long flags;
   20.40 ++
   20.41 ++		for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   20.42 ++			pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
   20.43 ++			if (!pmd)
   20.44 ++				goto out_oom;
   20.45 ++			set_pgd(&pgd[USER_PTRS_PER_PGD], __pgd(1 + __pa(pmd)));
   20.46 ++		}
   20.47 ++
   20.48 ++		spin_lock_irqsave(&pgd_lock, flags);
   20.49 ++		for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   20.50 ++			unsigned long v = (unsigned long)i << PGDIR_SHIFT;
   20.51 ++			pgd_t *kpgd = pgd_offset_k(v);
   20.52 ++			pud_t *kpud = pud_offset(kpgd, v);
   20.53 ++			pmd_t *kpmd = pmd_offset(kpud, v);
   20.54 ++			pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   20.55 ++			memcpy(pmd, kpmd, PAGE_SIZE);
   20.56 ++		}
   20.57 ++		pgd_list_add(pgd);
   20.58 ++		spin_unlock_irqrestore(&pgd_lock, flags);
   20.59 ++	}
   20.60 ++
   20.61 + 	return pgd;
   20.62 + 
   20.63 + out_oom:
   20.64 +@@ -263,9 +288,23 @@ void pgd_free(pgd_t *pgd)
   20.65 + 	int i;
   20.66 + 
   20.67 + 	/* in the PAE case user pgd entries are overwritten before usage */
   20.68 +-	if (PTRS_PER_PMD > 1)
   20.69 +-		for (i = 0; i < USER_PTRS_PER_PGD; ++i)
   20.70 +-			kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1));
   20.71 ++	if (PTRS_PER_PMD > 1) {
   20.72 ++		for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
   20.73 ++			pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   20.74 ++			kmem_cache_free(pmd_cache, pmd);
   20.75 ++		}
   20.76 ++		if (!HAVE_SHARED_KERNEL_PMD) {
   20.77 ++			unsigned long flags;
   20.78 ++			spin_lock_irqsave(&pgd_lock, flags);
   20.79 ++			pgd_list_del(pgd);
   20.80 ++			spin_unlock_irqrestore(&pgd_lock, flags);
   20.81 ++			for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   20.82 ++				pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   20.83 ++				memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
   20.84 ++				kmem_cache_free(pmd_cache, pmd);
   20.85 ++			}
   20.86 ++		}
   20.87 ++	}
   20.88 + 	/* in the non-PAE case, free_pgtables() clears user pgd entries */
   20.89 + 	kmem_cache_free(pgd_cache, pgd);
   20.90 + }
   20.91 +diff -pruN ../pristine-linux-2.6.16-rc6/include/asm-i386/pgtable-2level-defs.h ./include/asm-i386/pgtable-2level-defs.h
   20.92 +--- ../pristine-linux-2.6.16-rc6/include/asm-i386/pgtable-2level-defs.h	2006-01-03 03:21:10.000000000 +0000
   20.93 ++++ ./include/asm-i386/pgtable-2level-defs.h	2006-03-17 23:04:21.000000000 +0000
   20.94 +@@ -1,6 +1,8 @@
   20.95 + #ifndef _I386_PGTABLE_2LEVEL_DEFS_H
   20.96 + #define _I386_PGTABLE_2LEVEL_DEFS_H
   20.97 + 
   20.98 ++#define HAVE_SHARED_KERNEL_PMD 0
   20.99 ++
  20.100 + /*
  20.101 +  * traditional i386 two-level paging structure:
  20.102 +  */
  20.103 +diff -pruN ../pristine-linux-2.6.16-rc6/include/asm-i386/pgtable-3level-defs.h ./include/asm-i386/pgtable-3level-defs.h
  20.104 +--- ../pristine-linux-2.6.16-rc6/include/asm-i386/pgtable-3level-defs.h	2006-01-03 03:21:10.000000000 +0000
  20.105 ++++ ./include/asm-i386/pgtable-3level-defs.h	2006-03-17 23:04:21.000000000 +0000
  20.106 +@@ -1,6 +1,8 @@
  20.107 + #ifndef _I386_PGTABLE_3LEVEL_DEFS_H
  20.108 + #define _I386_PGTABLE_3LEVEL_DEFS_H
  20.109 + 
  20.110 ++#define HAVE_SHARED_KERNEL_PMD 1
  20.111 ++
  20.112 + /*
  20.113 +  * PGDIR_SHIFT determines what a top-level page table entry can map
  20.114 +  */
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/patches/linux-2.6.16-rc6/smp-alts.patch	Sat Mar 18 10:59:11 2006 +0100
    21.3 @@ -0,0 +1,591 @@
    21.4 +diff -pruN ../pristine-linux-2.6.16-rc6/arch/i386/Kconfig ./arch/i386/Kconfig
    21.5 +--- ../pristine-linux-2.6.16-rc6/arch/i386/Kconfig	2006-03-17 22:59:01.000000000 +0000
    21.6 ++++ ./arch/i386/Kconfig	2006-03-17 23:04:23.000000000 +0000
    21.7 +@@ -202,6 +202,19 @@ config SMP
    21.8 + 
    21.9 + 	  If you don't know what to do here, say N.
   21.10 + 
   21.11 ++config SMP_ALTERNATIVES
   21.12 ++	bool "SMP alternatives support (EXPERIMENTAL)"
   21.13 ++	depends on SMP && EXPERIMENTAL
   21.14 ++	help
   21.15 ++	  Try to reduce the overhead of running an SMP kernel on a uniprocessor
   21.16 ++	  host slightly by replacing certain key instruction sequences
   21.17 ++	  according to whether we currently have more than one CPU available.
   21.18 ++	  This should provide a noticeable boost to performance when
   21.19 ++	  running SMP kernels on UP machines, and have negligible impact
   21.20 ++	  when running on an true SMP host.
   21.21 ++
   21.22 ++          If unsure, say N.
   21.23 ++	  
   21.24 + config NR_CPUS
   21.25 + 	int "Maximum number of CPUs (2-255)"
   21.26 + 	range 2 255
   21.27 +diff -pruN ../pristine-linux-2.6.16-rc6/arch/i386/kernel/Makefile ./arch/i386/kernel/Makefile
   21.28 +--- ../pristine-linux-2.6.16-rc6/arch/i386/kernel/Makefile	2006-03-17 22:59:01.000000000 +0000
   21.29 ++++ ./arch/i386/kernel/Makefile	2006-03-17 23:04:23.000000000 +0000
   21.30 +@@ -37,6 +37,7 @@ obj-$(CONFIG_EFI) 		+= efi.o efi_stub.o
   21.31 + obj-$(CONFIG_DOUBLEFAULT) 	+= doublefault.o
   21.32 + obj-$(CONFIG_VM86)		+= vm86.o
   21.33 + obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
   21.34 ++obj-$(CONFIG_SMP_ALTERNATIVES)  += smpalts.o
   21.35 + 
   21.36 + EXTRA_AFLAGS   := -traditional
   21.37 + 
   21.38 +diff -pruN ../pristine-linux-2.6.16-rc6/arch/i386/kernel/smpalts.c ./arch/i386/kernel/smpalts.c
   21.39 +--- ../pristine-linux-2.6.16-rc6/arch/i386/kernel/smpalts.c	1970-01-01 01:00:00.000000000 +0100
   21.40 ++++ ./arch/i386/kernel/smpalts.c	2006-03-17 23:04:23.000000000 +0000
   21.41 +@@ -0,0 +1,85 @@
   21.42 ++#include <linux/kernel.h>
   21.43 ++#include <asm/system.h>
   21.44 ++#include <asm/smp_alt.h>
   21.45 ++#include <asm/processor.h>
   21.46 ++#include <asm/string.h>
   21.47 ++
   21.48 ++struct smp_replacement_record {
   21.49 ++	unsigned char targ_size;
   21.50 ++	unsigned char smp1_size;
   21.51 ++	unsigned char smp2_size;
   21.52 ++	unsigned char up_size;
   21.53 ++	unsigned char feature;
   21.54 ++	unsigned char data[0];
   21.55 ++};
   21.56 ++
   21.57 ++struct smp_alternative_record {
   21.58 ++	void *targ_start;
   21.59 ++	struct smp_replacement_record *repl;
   21.60 ++};
   21.61 ++
   21.62 ++extern struct smp_alternative_record __start_smp_alternatives_table,
   21.63 ++  __stop_smp_alternatives_table;
   21.64 ++extern unsigned long __init_begin, __init_end;
   21.65 ++
   21.66 ++void prepare_for_smp(void)
   21.67 ++{
   21.68 ++	struct smp_alternative_record *r;
   21.69 ++	printk(KERN_INFO "Enabling SMP...\n");
   21.70 ++	for (r = &__start_smp_alternatives_table;
   21.71 ++	     r != &__stop_smp_alternatives_table;
   21.72 ++	     r++) {
   21.73 ++		BUG_ON(r->repl->targ_size < r->repl->smp1_size);
   21.74 ++		BUG_ON(r->repl->targ_size < r->repl->smp2_size);
   21.75 ++		BUG_ON(r->repl->targ_size < r->repl->up_size);
   21.76 ++               if (system_state == SYSTEM_RUNNING &&
   21.77 ++                   r->targ_start >= (void *)&__init_begin &&
   21.78 ++                   r->targ_start < (void *)&__init_end)
   21.79 ++                       continue;
   21.80 ++		if (r->repl->feature != (unsigned char)-1 &&
   21.81 ++		    boot_cpu_has(r->repl->feature)) {
   21.82 ++			memcpy(r->targ_start,
   21.83 ++			       r->repl->data + r->repl->smp1_size,
   21.84 ++			       r->repl->smp2_size);
   21.85 ++			memset(r->targ_start + r->repl->smp2_size,
   21.86 ++			       0x90,
   21.87 ++			       r->repl->targ_size - r->repl->smp2_size);
   21.88 ++		} else {
   21.89 ++			memcpy(r->targ_start,
   21.90 ++			       r->repl->data,
   21.91 ++			       r->repl->smp1_size);
   21.92 ++			memset(r->targ_start + r->repl->smp1_size,
   21.93 ++			       0x90,
   21.94 ++			       r->repl->targ_size - r->repl->smp1_size);
   21.95 ++		}
   21.96 ++	}
   21.97 ++	/* Paranoia */
   21.98 ++	asm volatile ("jmp 1f\n1:");
   21.99 ++	mb();
  21.100 ++}
  21.101 ++
  21.102 ++void unprepare_for_smp(void)
  21.103 ++{
  21.104 ++	struct smp_alternative_record *r;
  21.105 ++	printk(KERN_INFO "Disabling SMP...\n");
  21.106 ++	for (r = &__start_smp_alternatives_table;
  21.107 ++	     r != &__stop_smp_alternatives_table;
  21.108 ++	     r++) {
  21.109 ++		BUG_ON(r->repl->targ_size < r->repl->smp1_size);
  21.110 ++		BUG_ON(r->repl->targ_size < r->repl->smp2_size);
  21.111 ++		BUG_ON(r->repl->targ_size < r->repl->up_size);
  21.112 ++               if (system_state == SYSTEM_RUNNING &&
  21.113 ++                   r->targ_start >= (void *)&__init_begin &&
  21.114 ++                   r->targ_start < (void *)&__init_end)
  21.115 ++                       continue;
  21.116 ++		memcpy(r->targ_start,
  21.117 ++		       r->repl->data + r->repl->smp1_size + r->repl->smp2_size,
  21.118 ++		       r->repl->up_size);
  21.119 ++		memset(r->targ_start + r->repl->up_size,
  21.120 ++		       0x90,
  21.121 ++		       r->repl->targ_size - r->repl->up_size);
  21.122 ++	}
  21.123 ++	/* Paranoia */
  21.124 ++	asm volatile ("jmp 1f\n1:");
  21.125 ++	mb();
  21.126 ++}
  21.127 +diff -pruN ../pristine-linux-2.6.16-rc6/arch/i386/kernel/smpboot.c ./arch/i386/kernel/smpboot.c
  21.128 +--- ../pristine-linux-2.6.16-rc6/arch/i386/kernel/smpboot.c	2006-03-17 22:59:01.000000000 +0000
  21.129 ++++ ./arch/i386/kernel/smpboot.c	2006-03-17 23:04:23.000000000 +0000
  21.130 +@@ -1208,6 +1208,11 @@ static void __init smp_boot_cpus(unsigne
  21.131 + 		if (max_cpus <= cpucount+1)
  21.132 + 			continue;
  21.133 + 
  21.134 ++#ifdef CONFIG_SMP_ALTERNATIVES
  21.135 ++		if (kicked == 1)
  21.136 ++			prepare_for_smp();
  21.137 ++#endif
  21.138 ++
  21.139 + 		if (((cpu = alloc_cpu_id()) <= 0) || do_boot_cpu(apicid, cpu))
  21.140 + 			printk("CPU #%d not responding - cannot use it.\n",
  21.141 + 								apicid);
  21.142 +@@ -1386,6 +1391,11 @@ int __devinit __cpu_up(unsigned int cpu)
  21.143 + 		return -EIO;
  21.144 + 	}
  21.145 + 
  21.146 ++#ifdef CONFIG_SMP_ALTERNATIVES
  21.147 ++	if (num_online_cpus() == 1)
  21.148 ++		prepare_for_smp();
  21.149 ++#endif
  21.150 ++
  21.151 + 	local_irq_enable();
  21.152 + 	per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
  21.153 + 	/* Unleash the CPU! */
  21.154 +diff -pruN ../pristine-linux-2.6.16-rc6/arch/i386/kernel/vmlinux.lds.S ./arch/i386/kernel/vmlinux.lds.S
  21.155 +--- ../pristine-linux-2.6.16-rc6/arch/i386/kernel/vmlinux.lds.S	2006-01-03 03:21:10.000000000 +0000
  21.156 ++++ ./arch/i386/kernel/vmlinux.lds.S	2006-03-17 23:04:23.000000000 +0000
  21.157 +@@ -34,6 +34,13 @@ SECTIONS
  21.158 +   __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
  21.159 +   __stop___ex_table = .;
  21.160 + 
  21.161 ++  . = ALIGN(16);
  21.162 ++  __start_smp_alternatives_table = .;
  21.163 ++  __smp_alternatives : { *(__smp_alternatives) }
  21.164 ++  __stop_smp_alternatives_table = .;
  21.165 ++
  21.166 ++  __smp_replacements : { *(__smp_replacements) }
  21.167 ++
  21.168 +   RODATA
  21.169 + 
  21.170 +   /* writeable */
  21.171 +diff -pruN ../pristine-linux-2.6.16-rc6/include/asm-i386/atomic.h ./include/asm-i386/atomic.h
  21.172 +--- ../pristine-linux-2.6.16-rc6/include/asm-i386/atomic.h	2006-03-17 22:59:05.000000000 +0000
  21.173 ++++ ./include/asm-i386/atomic.h	2006-03-17 23:04:23.000000000 +0000
  21.174 +@@ -4,18 +4,13 @@
  21.175 + #include <linux/config.h>
  21.176 + #include <linux/compiler.h>
  21.177 + #include <asm/processor.h>
  21.178 ++#include <asm/smp_alt.h>
  21.179 + 
  21.180 + /*
  21.181 +  * Atomic operations that C can't guarantee us.  Useful for
  21.182 +  * resource counting etc..
  21.183 +  */
  21.184 + 
  21.185 +-#ifdef CONFIG_SMP
  21.186 +-#define LOCK "lock ; "
  21.187 +-#else
  21.188 +-#define LOCK ""
  21.189 +-#endif
  21.190 +-
  21.191 + /*
  21.192 +  * Make sure gcc doesn't try to be clever and move things around
  21.193 +  * on us. We need to use _exactly_ the address the user gave us,
  21.194 +diff -pruN ../pristine-linux-2.6.16-rc6/include/asm-i386/bitops.h ./include/asm-i386/bitops.h
  21.195 +--- ../pristine-linux-2.6.16-rc6/include/asm-i386/bitops.h	2006-03-17 22:59:05.000000000 +0000
  21.196 ++++ ./include/asm-i386/bitops.h	2006-03-17 23:04:23.000000000 +0000
  21.197 +@@ -7,6 +7,7 @@
  21.198 + 
  21.199 + #include <linux/config.h>
  21.200 + #include <linux/compiler.h>
  21.201 ++#include <asm/smp_alt.h>
  21.202 + 
  21.203 + /*
  21.204 +  * These have to be done with inline assembly: that way the bit-setting
  21.205 +@@ -16,12 +17,6 @@
  21.206 +  * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
  21.207 +  */
  21.208 + 
  21.209 +-#ifdef CONFIG_SMP
  21.210 +-#define LOCK_PREFIX "lock ; "
  21.211 +-#else
  21.212 +-#define LOCK_PREFIX ""
  21.213 +-#endif
  21.214 +-
  21.215 + #define ADDR (*(volatile long *) addr)
  21.216 + 
  21.217 + /**
  21.218 +@@ -41,7 +36,7 @@
  21.219 +  */
  21.220 + static inline void set_bit(int nr, volatile unsigned long * addr)
  21.221 + {
  21.222 +-	__asm__ __volatile__( LOCK_PREFIX
  21.223 ++	__asm__ __volatile__( LOCK
  21.224 + 		"btsl %1,%0"
  21.225 + 		:"+m" (ADDR)
  21.226 + 		:"Ir" (nr));
  21.227 +@@ -76,7 +71,7 @@ static inline void __set_bit(int nr, vol
  21.228 +  */
  21.229 + static inline void clear_bit(int nr, volatile unsigned long * addr)
  21.230 + {
  21.231 +-	__asm__ __volatile__( LOCK_PREFIX
  21.232 ++	__asm__ __volatile__( LOCK
  21.233 + 		"btrl %1,%0"
  21.234 + 		:"+m" (ADDR)
  21.235 + 		:"Ir" (nr));
  21.236 +@@ -121,7 +116,7 @@ static inline void __change_bit(int nr, 
  21.237 +  */
  21.238 + static inline void change_bit(int nr, volatile unsigned long * addr)
  21.239 + {
  21.240 +-	__asm__ __volatile__( LOCK_PREFIX
  21.241 ++	__asm__ __volatile__( LOCK
  21.242 + 		"btcl %1,%0"
  21.243 + 		:"+m" (ADDR)
  21.244 + 		:"Ir" (nr));
  21.245 +@@ -140,7 +135,7 @@ static inline int test_and_set_bit(int n
  21.246 + {
  21.247 + 	int oldbit;
  21.248 + 
  21.249 +-	__asm__ __volatile__( LOCK_PREFIX
  21.250 ++	__asm__ __volatile__( LOCK
  21.251 + 		"btsl %2,%1\n\tsbbl %0,%0"
  21.252 + 		:"=r" (oldbit),"+m" (ADDR)
  21.253 + 		:"Ir" (nr) : "memory");
  21.254 +@@ -180,7 +175,7 @@ static inline int test_and_clear_bit(int
  21.255 + {
  21.256 + 	int oldbit;
  21.257 + 
  21.258 +-	__asm__ __volatile__( LOCK_PREFIX
  21.259 ++	__asm__ __volatile__( LOCK
  21.260 + 		"btrl %2,%1\n\tsbbl %0,%0"
  21.261 + 		:"=r" (oldbit),"+m" (ADDR)
  21.262 + 		:"Ir" (nr) : "memory");
  21.263 +@@ -231,7 +226,7 @@ static inline int test_and_change_bit(in
  21.264 + {
  21.265 + 	int oldbit;
  21.266 + 
  21.267 +-	__asm__ __volatile__( LOCK_PREFIX
  21.268 ++	__asm__ __volatile__( LOCK
  21.269 + 		"btcl %2,%1\n\tsbbl %0,%0"
  21.270 + 		:"=r" (oldbit),"+m" (ADDR)
  21.271 + 		:"Ir" (nr) : "memory");
  21.272 +diff -pruN ../pristine-linux-2.6.16-rc6/include/asm-i386/futex.h ./include/asm-i386/futex.h
  21.273 +--- ../pristine-linux-2.6.16-rc6/include/asm-i386/futex.h	2006-03-17 22:59:05.000000000 +0000
  21.274 ++++ ./include/asm-i386/futex.h	2006-03-17 23:04:23.000000000 +0000
  21.275 +@@ -28,7 +28,7 @@
  21.276 + "1:	movl	%2, %0\n\
  21.277 + 	movl	%0, %3\n"					\
  21.278 + 	insn "\n"						\
  21.279 +-"2:	" LOCK_PREFIX "cmpxchgl %3, %2\n\
  21.280 ++"2:	" LOCK "cmpxchgl %3, %2\n\
  21.281 + 	jnz	1b\n\
  21.282 + 3:	.section .fixup,\"ax\"\n\
  21.283 + 4:	mov	%5, %1\n\
  21.284 +@@ -68,7 +68,7 @@ futex_atomic_op_inuser (int encoded_op, 
  21.285 + #endif
  21.286 + 		switch (op) {
  21.287 + 		case FUTEX_OP_ADD:
  21.288 +-			__futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret,
  21.289 ++			__futex_atomic_op1(LOCK "xaddl %0, %2", ret,
  21.290 + 					   oldval, uaddr, oparg);
  21.291 + 			break;
  21.292 + 		case FUTEX_OP_OR:
  21.293 +diff -pruN ../pristine-linux-2.6.16-rc6/include/asm-i386/rwsem.h ./include/asm-i386/rwsem.h
  21.294 +--- ../pristine-linux-2.6.16-rc6/include/asm-i386/rwsem.h	2006-01-03 03:21:10.000000000 +0000
  21.295 ++++ ./include/asm-i386/rwsem.h	2006-03-17 23:04:23.000000000 +0000
  21.296 +@@ -40,6 +40,7 @@
  21.297 + 
  21.298 + #include <linux/list.h>
  21.299 + #include <linux/spinlock.h>
  21.300 ++#include <asm/smp_alt.h>
  21.301 + 
  21.302 + struct rwsem_waiter;
  21.303 + 
  21.304 +@@ -99,7 +100,7 @@ static inline void __down_read(struct rw
  21.305 + {
  21.306 + 	__asm__ __volatile__(
  21.307 + 		"# beginning down_read\n\t"
  21.308 +-LOCK_PREFIX	"  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old value */
  21.309 ++LOCK	        "  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old value */
  21.310 + 		"  js        2f\n\t" /* jump if we weren't granted the lock */
  21.311 + 		"1:\n\t"
  21.312 + 		LOCK_SECTION_START("")
  21.313 +@@ -130,7 +131,7 @@ static inline int __down_read_trylock(st
  21.314 + 		"  movl	     %1,%2\n\t"
  21.315 + 		"  addl      %3,%2\n\t"
  21.316 + 		"  jle	     2f\n\t"
  21.317 +-LOCK_PREFIX	"  cmpxchgl  %2,%0\n\t"
  21.318 ++LOCK	        "  cmpxchgl  %2,%0\n\t"
  21.319 + 		"  jnz	     1b\n\t"
  21.320 + 		"2:\n\t"
  21.321 + 		"# ending __down_read_trylock\n\t"
  21.322 +@@ -150,7 +151,7 @@ static inline void __down_write(struct r
  21.323 + 	tmp = RWSEM_ACTIVE_WRITE_BIAS;
  21.324 + 	__asm__ __volatile__(
  21.325 + 		"# beginning down_write\n\t"
  21.326 +-LOCK_PREFIX	"  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
  21.327 ++LOCK	        "  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
  21.328 + 		"  testl     %%edx,%%edx\n\t" /* was the count 0 before? */
  21.329 + 		"  jnz       2f\n\t" /* jump if we weren't granted the lock */
  21.330 + 		"1:\n\t"
  21.331 +@@ -188,7 +189,7 @@ static inline void __up_read(struct rw_s
  21.332 + 	__s32 tmp = -RWSEM_ACTIVE_READ_BIAS;
  21.333 + 	__asm__ __volatile__(
  21.334 + 		"# beginning __up_read\n\t"
  21.335 +-LOCK_PREFIX	"  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
  21.336 ++LOCK	        "  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
  21.337 + 		"  js        2f\n\t" /* jump if the lock is being waited upon */
  21.338 + 		"1:\n\t"
  21.339 + 		LOCK_SECTION_START("")
  21.340 +@@ -214,7 +215,7 @@ static inline void __up_write(struct rw_
  21.341 + 	__asm__ __volatile__(
  21.342 + 		"# beginning __up_write\n\t"
  21.343 + 		"  movl      %2,%%edx\n\t"
  21.344 +-LOCK_PREFIX	"  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
  21.345 ++LOCK	        "  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
  21.346 + 		"  jnz       2f\n\t" /* jump if the lock is being waited upon */
  21.347 + 		"1:\n\t"
  21.348 + 		LOCK_SECTION_START("")
  21.349 +@@ -239,7 +240,7 @@ static inline void __downgrade_write(str
  21.350 + {
  21.351 + 	__asm__ __volatile__(
  21.352 + 		"# beginning __downgrade_write\n\t"
  21.353 +-LOCK_PREFIX	"  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
  21.354 ++LOCK	        "  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
  21.355 + 		"  js        2f\n\t" /* jump if the lock is being waited upon */
  21.356 + 		"1:\n\t"
  21.357 + 		LOCK_SECTION_START("")
  21.358 +@@ -263,7 +264,7 @@ LOCK_PREFIX	"  addl      %2,(%%eax)\n\t"
  21.359 + static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem)
  21.360 + {
  21.361 + 	__asm__ __volatile__(
  21.362 +-LOCK_PREFIX	"addl %1,%0"
  21.363 ++LOCK	          "addl %1,%0"
  21.364 + 		: "=m"(sem->count)
  21.365 + 		: "ir"(delta), "m"(sem->count));
  21.366 + }
  21.367 +@@ -276,7 +277,7 @@ static inline int rwsem_atomic_update(in
  21.368 + 	int tmp = delta;
  21.369 + 
  21.370 + 	__asm__ __volatile__(
  21.371 +-LOCK_PREFIX	"xadd %0,(%2)"
  21.372 ++LOCK  	          "xadd %0,(%2)"
  21.373 + 		: "+r"(tmp), "=m"(sem->count)
  21.374 + 		: "r"(sem), "m"(sem->count)
  21.375 + 		: "memory");
  21.376 +diff -pruN ../pristine-linux-2.6.16-rc6/include/asm-i386/smp_alt.h ./include/asm-i386/smp_alt.h
  21.377 +--- ../pristine-linux-2.6.16-rc6/include/asm-i386/smp_alt.h	1970-01-01 01:00:00.000000000 +0100
  21.378 ++++ ./include/asm-i386/smp_alt.h	2006-03-17 23:04:23.000000000 +0000
  21.379 +@@ -0,0 +1,32 @@
  21.380 ++#ifndef __ASM_SMP_ALT_H__
  21.381 ++#define __ASM_SMP_ALT_H__
  21.382 ++
  21.383 ++#include <linux/config.h>
  21.384 ++
  21.385 ++#ifdef CONFIG_SMP
  21.386 ++#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
  21.387 ++#define LOCK \
  21.388 ++        "6677: nop\n" \
  21.389 ++	".section __smp_alternatives,\"a\"\n" \
  21.390 ++	".long 6677b\n" \
  21.391 ++	".long 6678f\n" \
  21.392 ++	".previous\n" \
  21.393 ++	".section __smp_replacements,\"a\"\n" \
  21.394 ++	"6678: .byte 1\n" \
  21.395 ++	".byte 1\n" \
  21.396 ++	".byte 0\n" \
  21.397 ++        ".byte 1\n" \
  21.398 ++	".byte -1\n" \
  21.399 ++	"lock\n" \
  21.400 ++	"nop\n" \
  21.401 ++	".previous\n"
  21.402 ++void prepare_for_smp(void);
  21.403 ++void unprepare_for_smp(void);
  21.404 ++#else
  21.405 ++#define LOCK "lock ; "
  21.406 ++#endif
  21.407 ++#else
  21.408 ++#define LOCK ""
  21.409 ++#endif
  21.410 ++
  21.411 ++#endif /* __ASM_SMP_ALT_H__ */
  21.412 +diff -pruN ../pristine-linux-2.6.16-rc6/include/asm-i386/spinlock.h ./include/asm-i386/spinlock.h
  21.413 +--- ../pristine-linux-2.6.16-rc6/include/asm-i386/spinlock.h	2006-01-03 03:21:10.000000000 +0000
  21.414 ++++ ./include/asm-i386/spinlock.h	2006-03-17 23:04:23.000000000 +0000
  21.415 +@@ -6,6 +6,7 @@
  21.416 + #include <asm/page.h>
  21.417 + #include <linux/config.h>
  21.418 + #include <linux/compiler.h>
  21.419 ++#include <asm/smp_alt.h>
  21.420 + 
  21.421 + /*
  21.422 +  * Your basic SMP spinlocks, allowing only a single CPU anywhere
  21.423 +@@ -23,7 +24,8 @@
  21.424 + 
  21.425 + #define __raw_spin_lock_string \
  21.426 + 	"\n1:\t" \
  21.427 +-	"lock ; decb %0\n\t" \
  21.428 ++	LOCK \
  21.429 ++	"decb %0\n\t" \
  21.430 + 	"jns 3f\n" \
  21.431 + 	"2:\t" \
  21.432 + 	"rep;nop\n\t" \
  21.433 +@@ -34,7 +36,8 @@
  21.434 + 
  21.435 + #define __raw_spin_lock_string_flags \
  21.436 + 	"\n1:\t" \
  21.437 +-	"lock ; decb %0\n\t" \
  21.438 ++	LOCK \
  21.439 ++	"decb %0\n\t" \
  21.440 + 	"jns 4f\n\t" \
  21.441 + 	"2:\t" \
  21.442 + 	"testl $0x200, %1\n\t" \
  21.443 +@@ -65,10 +68,34 @@ static inline void __raw_spin_lock_flags
  21.444 + static inline int __raw_spin_trylock(raw_spinlock_t *lock)
  21.445 + {
  21.446 + 	char oldval;
  21.447 ++#ifdef CONFIG_SMP_ALTERNATIVES
  21.448 + 	__asm__ __volatile__(
  21.449 +-		"xchgb %b0,%1"
  21.450 ++		"1:movb %1,%b0\n"
  21.451 ++		"movb $0,%1\n"
  21.452 ++		"2:"
  21.453 ++		".section __smp_alternatives,\"a\"\n"
  21.454 ++		".long 1b\n"
  21.455 ++		".long 3f\n"
  21.456 ++		".previous\n"
  21.457 ++		".section __smp_replacements,\"a\"\n"
  21.458 ++		"3: .byte 2b - 1b\n"
  21.459 ++		".byte 5f-4f\n"
  21.460 ++		".byte 0\n"
  21.461 ++		".byte 6f-5f\n"
  21.462 ++		".byte -1\n"
  21.463 ++		"4: xchgb %b0,%1\n"
  21.464 ++		"5: movb %1,%b0\n"
  21.465 ++		"movb $0,%1\n"
  21.466 ++		"6:\n"
  21.467 ++		".previous\n"
  21.468 + 		:"=q" (oldval), "=m" (lock->slock)
  21.469 + 		:"0" (0) : "memory");
  21.470 ++#else
  21.471 ++	__asm__ __volatile__(
  21.472 ++		"xchgb %b0,%1\n"
  21.473 ++		:"=q" (oldval), "=m" (lock->slock)
  21.474 ++		:"0" (0) : "memory");
  21.475 ++#endif
  21.476 + 	return oldval > 0;
  21.477 + }
  21.478 + 
  21.479 +@@ -178,12 +205,12 @@ static inline int __raw_write_trylock(ra
  21.480 + 
  21.481 + static inline void __raw_read_unlock(raw_rwlock_t *rw)
  21.482 + {
  21.483 +-	asm volatile("lock ; incl %0" :"=m" (rw->lock) : : "memory");
  21.484 ++	asm volatile(LOCK "incl %0" :"=m" (rw->lock) : : "memory");
  21.485 + }
  21.486 + 
  21.487 + static inline void __raw_write_unlock(raw_rwlock_t *rw)
  21.488 + {
  21.489 +-	asm volatile("lock ; addl $" RW_LOCK_BIAS_STR ", %0"
  21.490 ++	asm volatile(LOCK "addl $" RW_LOCK_BIAS_STR ", %0"
  21.491 + 				 : "=m" (rw->lock) : : "memory");
  21.492 + }
  21.493 + 
  21.494 +diff -pruN ../pristine-linux-2.6.16-rc6/include/asm-i386/system.h ./include/asm-i386/system.h
  21.495 +--- ../pristine-linux-2.6.16-rc6/include/asm-i386/system.h	2006-03-17 22:59:05.000000000 +0000
  21.496 ++++ ./include/asm-i386/system.h	2006-03-17 23:04:23.000000000 +0000
  21.497 +@@ -5,7 +5,7 @@
  21.498 + #include <linux/kernel.h>
  21.499 + #include <asm/segment.h>
  21.500 + #include <asm/cpufeature.h>
  21.501 +-#include <linux/bitops.h> /* for LOCK_PREFIX */
  21.502 ++#include <asm/smp_alt.h>
  21.503 + 
  21.504 + #ifdef __KERNEL__
  21.505 + 
  21.506 +@@ -271,19 +271,19 @@ static inline unsigned long __cmpxchg(vo
  21.507 + 	unsigned long prev;
  21.508 + 	switch (size) {
  21.509 + 	case 1:
  21.510 +-		__asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
  21.511 ++		__asm__ __volatile__(LOCK "cmpxchgb %b1,%2"
  21.512 + 				     : "=a"(prev)
  21.513 + 				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
  21.514 + 				     : "memory");
  21.515 + 		return prev;
  21.516 + 	case 2:
  21.517 +-		__asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
  21.518 ++		__asm__ __volatile__(LOCK "cmpxchgw %w1,%2"
  21.519 + 				     : "=a"(prev)
  21.520 + 				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
  21.521 + 				     : "memory");
  21.522 + 		return prev;
  21.523 + 	case 4:
  21.524 +-		__asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
  21.525 ++		__asm__ __volatile__(LOCK "cmpxchgl %1,%2"
  21.526 + 				     : "=a"(prev)
  21.527 + 				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
  21.528 + 				     : "memory");
  21.529 +@@ -336,7 +336,7 @@ static inline unsigned long long __cmpxc
  21.530 + 				      unsigned long long new)
  21.531 + {
  21.532 + 	unsigned long long prev;
  21.533 +-	__asm__ __volatile__(LOCK_PREFIX "cmpxchg8b %3"
  21.534 ++	__asm__ __volatile__(LOCK "cmpxchg8b %3"
  21.535 + 			     : "=A"(prev)
  21.536 + 			     : "b"((unsigned long)new),
  21.537 + 			       "c"((unsigned long)(new >> 32)),
  21.538 +@@ -503,11 +503,55 @@ struct alt_instr { 
  21.539 + #endif
  21.540 + 
  21.541 + #ifdef CONFIG_SMP
  21.542 ++#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
  21.543 ++#define smp_alt_mb(instr)                                           \
  21.544 ++__asm__ __volatile__("6667:\nnop\nnop\nnop\nnop\nnop\nnop\n6668:\n" \
  21.545 ++		     ".section __smp_alternatives,\"a\"\n"          \
  21.546 ++		     ".long 6667b\n"                                \
  21.547 ++                     ".long 6673f\n"                                \
  21.548 ++		     ".previous\n"                                  \
  21.549 ++		     ".section __smp_replacements,\"a\"\n"          \
  21.550 ++		     "6673:.byte 6668b-6667b\n"                     \
  21.551 ++		     ".byte 6670f-6669f\n"                          \
  21.552 ++		     ".byte 6671f-6670f\n"                          \
  21.553 ++                     ".byte 0\n"                                    \
  21.554 ++		     ".byte %c0\n"                                  \
  21.555 ++		     "6669:lock;addl $0,0(%%esp)\n"                 \
  21.556 ++		     "6670:" instr "\n"                             \
  21.557 ++		     "6671:\n"                                      \
  21.558 ++		     ".previous\n"                                  \
  21.559 ++		     :                                              \
  21.560 ++		     : "i" (X86_FEATURE_XMM2)                       \
  21.561 ++		     : "memory")
  21.562 ++#define smp_rmb() smp_alt_mb("lfence")
  21.563 ++#define smp_mb()  smp_alt_mb("mfence")
  21.564 ++#define set_mb(var, value) do {                                     \
  21.565 ++unsigned long __set_mb_temp;                                        \
  21.566 ++__asm__ __volatile__("6667:movl %1, %0\n6668:\n"                    \
  21.567 ++		     ".section __smp_alternatives,\"a\"\n"          \
  21.568 ++		     ".long 6667b\n"                                \
  21.569 ++		     ".long 6673f\n"                                \
  21.570 ++		     ".previous\n"                                  \
  21.571 ++		     ".section __smp_replacements,\"a\"\n"          \
  21.572 ++		     "6673: .byte 6668b-6667b\n"                    \
  21.573 ++		     ".byte 6670f-6669f\n"                          \
  21.574 ++		     ".byte 0\n"                                    \
  21.575 ++		     ".byte 6671f-6670f\n"                          \
  21.576 ++		     ".byte -1\n"                                   \
  21.577 ++		     "6669: xchg %1, %0\n"                          \
  21.578 ++		     "6670:movl %1, %0\n"                           \
  21.579 ++		     "6671:\n"                                      \
  21.580 ++		     ".previous\n"                                  \
  21.581 ++		     : "=m" (var), "=r" (__set_mb_temp)             \
  21.582 ++		     : "1" (value)                                  \
  21.583 ++		     : "memory"); } while (0)
  21.584 ++#else
  21.585 + #define smp_mb()	mb()
  21.586 + #define smp_rmb()	rmb()
  21.587 ++#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
  21.588 ++#endif
  21.589 + #define smp_wmb()	wmb()
  21.590 + #define smp_read_barrier_depends()	read_barrier_depends()
  21.591 +-#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
  21.592 + #else
  21.593 + #define smp_mb()	barrier()
  21.594 + #define smp_rmb()	barrier()