ia64/xen-unstable

changeset 8945:1c7145a5bb43

Update to Linux 2.6.16-rc4.

Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Tue Feb 21 11:19:13 2006 +0000 (2006-02-21)
parents a05e56904e7e
children 8005fbd31d8b
files buildconfigs/mk.linux-2.6-xen linux-2.6-xen-sparse/arch/x86_64/kernel/io_apic-xen.c linux-2.6-xen-sparse/arch/x86_64/kernel/mpparse-xen.c linux-2.6-xen-sparse/drivers/char/tty_io.c linux-2.6-xen-sparse/drivers/serial/Kconfig linux-2.6-xen-sparse/include/linux/mm.h linux-2.6-xen-sparse/mm/memory.c linux-2.6-xen-sparse/mm/page_alloc.c patches/linux-2.6.16-rc3/i386-mach-io-check-nmi.patch patches/linux-2.6.16-rc3/net-csum.patch patches/linux-2.6.16-rc3/pmd-shared.patch patches/linux-2.6.16-rc3/smp-alts.patch patches/linux-2.6.16-rc4/i386-mach-io-check-nmi.patch patches/linux-2.6.16-rc4/net-csum.patch patches/linux-2.6.16-rc4/pmd-shared.patch patches/linux-2.6.16-rc4/smp-alts.patch
line diff
     1.1 --- a/buildconfigs/mk.linux-2.6-xen	Mon Feb 20 23:01:50 2006 +0000
     1.2 +++ b/buildconfigs/mk.linux-2.6-xen	Tue Feb 21 11:19:13 2006 +0000
     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-rc3
     1.8 -LINUX_SRCS = linux-2.6.15.tar.bz2 patch-2.6.16-rc3.bz2
     1.9 +LINUX_VER    = 2.6.16-rc4
    1.10 +LINUX_SRCS = linux-2.6.15.tar.bz2 patch-2.6.16-rc4.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-rc3/.valid-pristine: pristine-$(LINUX_PDIR)/.valid-srcs
    1.19 +pristine-linux-%.16-rc4/.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/x86_64/kernel/io_apic-xen.c	Mon Feb 20 23:01:50 2006 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/io_apic-xen.c	Tue Feb 21 11:19:13 2006 +0000
     2.3 @@ -30,6 +30,9 @@
     2.4  #include <linux/mc146818rtc.h>
     2.5  #include <linux/acpi.h>
     2.6  #include <linux/sysdev.h>
     2.7 +#ifdef CONFIG_ACPI
     2.8 +#include <acpi/acpi_bus.h>
     2.9 +#endif
    2.10  
    2.11  #include <asm/io.h>
    2.12  #include <asm/smp.h>
    2.13 @@ -310,6 +313,8 @@ static int __init enable_ioapic_setup(ch
    2.14  
    2.15     And another hack to disable the IOMMU on VIA chipsets.
    2.16  
    2.17 +   ... and others. Really should move this somewhere else.
    2.18 +
    2.19     Kludge-O-Rama. */
    2.20  void __init check_ioapic(void) 
    2.21  { 
    2.22 @@ -358,6 +363,17 @@ void __init check_ioapic(void)
    2.23  #ifndef CONFIG_XEN
    2.24  					if (apic_runs_main_timer != 0)
    2.25  						break;
    2.26 +#ifdef CONFIG_ACPI
    2.27 +					/* Don't do this for laptops right
    2.28 +					   right now because their timer
    2.29 +					   doesn't necessarily tick in C2/3 */
    2.30 +					if (acpi_fadt.revision >= 3 &&
    2.31 +			(acpi_fadt.plvl2_lat + acpi_fadt.plvl3_lat) < 1100) {
    2.32 +						printk(KERN_INFO
    2.33 +"ATI board detected, but seems to be a laptop. Timer might be shakey, sorry\n");
    2.34 +						break;
    2.35 +					}
    2.36 +#endif					
    2.37  					printk(KERN_INFO
    2.38  	     "ATI board detected. Using APIC/PM timer.\n");
    2.39  					apic_runs_main_timer = 1;
     3.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/mpparse-xen.c	Mon Feb 20 23:01:50 2006 +0000
     3.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/mpparse-xen.c	Tue Feb 21 11:19:13 2006 +0000
     3.3 @@ -295,9 +295,9 @@ static int __init smp_read_mpc(struct mp
     3.4  
     3.5  	memcpy(str,mpc->mpc_productid,12);
     3.6  	str[12]=0;
     3.7 -	printk(KERN_INFO "Product ID: %s ",str);
     3.8 +	printk("Product ID: %s ",str);
     3.9  
    3.10 -	printk(KERN_INFO "APIC at: 0x%X\n",mpc->mpc_lapic);
    3.11 +	printk("APIC at: 0x%X\n",mpc->mpc_lapic);
    3.12  
    3.13  	/* save the local APIC address, it might be non-default */
    3.14  	if (!acpi_lapic)
     4.1 --- a/linux-2.6-xen-sparse/drivers/char/tty_io.c	Mon Feb 20 23:01:50 2006 +0000
     4.2 +++ b/linux-2.6-xen-sparse/drivers/char/tty_io.c	Tue Feb 21 11:19:13 2006 +0000
     4.3 @@ -1843,7 +1843,6 @@ static void release_dev(struct file * fi
     4.4  		tty_closing = tty->count <= 1;
     4.5  		o_tty_closing = o_tty &&
     4.6  			(o_tty->count <= (pty_master ? 1 : 0));
     4.7 -		up(&tty_sem);
     4.8  		do_sleep = 0;
     4.9  
    4.10  		if (tty_closing) {
    4.11 @@ -1871,6 +1870,7 @@ static void release_dev(struct file * fi
    4.12  
    4.13  		printk(KERN_WARNING "release_dev: %s: read/write wait queue "
    4.14  				    "active!\n", tty_name(tty, buf));
    4.15 +		up(&tty_sem);
    4.16  		schedule();
    4.17  	}	
    4.18  
    4.19 @@ -1879,8 +1879,6 @@ static void release_dev(struct file * fi
    4.20  	 * both sides, and we've completed the last operation that could 
    4.21  	 * block, so it's safe to proceed with closing.
    4.22  	 */
    4.23 -	 
    4.24 -	down(&tty_sem);
    4.25  	if (pty_master) {
    4.26  		if (--o_tty->count < 0) {
    4.27  			printk(KERN_WARNING "release_dev: bad pty slave count "
    4.28 @@ -1894,7 +1892,6 @@ static void release_dev(struct file * fi
    4.29  		       tty->count, tty_name(tty, buf));
    4.30  		tty->count = 0;
    4.31  	}
    4.32 -	up(&tty_sem);
    4.33  	
    4.34  	/*
    4.35  	 * We've decremented tty->count, so we need to remove this file
    4.36 @@ -1939,6 +1936,8 @@ static void release_dev(struct file * fi
    4.37  		read_unlock(&tasklist_lock);
    4.38  	}
    4.39  
    4.40 +	up(&tty_sem);
    4.41 +
    4.42  	/* check whether both sides are closing ... */
    4.43  	if (!tty_closing || (o_tty && !o_tty_closing))
    4.44  		return;
     5.1 --- a/linux-2.6-xen-sparse/drivers/serial/Kconfig	Mon Feb 20 23:01:50 2006 +0000
     5.2 +++ b/linux-2.6-xen-sparse/drivers/serial/Kconfig	Tue Feb 21 11:19:13 2006 +0000
     5.3 @@ -903,8 +903,8 @@ config SERIAL_JSM
     5.4  	  something like this to connect more than two modems to your Linux
     5.5  	  box, for instance in order to become a dial-in server. This driver
     5.6  	  supports PCI boards only.
     5.7 -	  If you have a card like this, say Y here and read the file
     5.8 -	  <file:Documentation/jsm.txt>.
     5.9 +
    5.10 +	  If you have a card like this, say Y here, otherwise say N.
    5.11  
    5.12  	  To compile this driver as a module, choose M here: the
    5.13  	  module will be called jsm.
     6.1 --- a/linux-2.6-xen-sparse/include/linux/mm.h	Mon Feb 20 23:01:50 2006 +0000
     6.2 +++ b/linux-2.6-xen-sparse/include/linux/mm.h	Tue Feb 21 11:19:13 2006 +0000
     6.3 @@ -1064,5 +1064,7 @@ int shrink_slab(unsigned long scanned, g
     6.4  void drop_pagecache(void);
     6.5  void drop_slab(void);
     6.6  
     6.7 +extern int randomize_va_space;
     6.8 +
     6.9  #endif /* __KERNEL__ */
    6.10  #endif /* _LINUX_MM_H */
     7.1 --- a/linux-2.6-xen-sparse/mm/memory.c	Mon Feb 20 23:01:50 2006 +0000
     7.2 +++ b/linux-2.6-xen-sparse/mm/memory.c	Tue Feb 21 11:19:13 2006 +0000
     7.3 @@ -82,6 +82,16 @@ EXPORT_SYMBOL(num_physpages);
     7.4  EXPORT_SYMBOL(high_memory);
     7.5  EXPORT_SYMBOL(vmalloc_earlyreserve);
     7.6  
     7.7 +int randomize_va_space __read_mostly = 1;
     7.8 +
     7.9 +static int __init disable_randmaps(char *s)
    7.10 +{
    7.11 +	randomize_va_space = 0;
    7.12 +	return 0;
    7.13 +}
    7.14 +__setup("norandmaps", disable_randmaps);
    7.15 +
    7.16 +
    7.17  /*
    7.18   * If a p?d_bad entry is found while walking page tables, report
    7.19   * the error, before resetting entry to p?d_none.  Usually (but
     8.1 --- a/linux-2.6-xen-sparse/mm/page_alloc.c	Mon Feb 20 23:01:50 2006 +0000
     8.2 +++ b/linux-2.6-xen-sparse/mm/page_alloc.c	Tue Feb 21 11:19:13 2006 +0000
     8.3 @@ -56,6 +56,7 @@ long nr_swap_pages;
     8.4  int percpu_pagelist_fraction;
     8.5  
     8.6  static void fastcall free_hot_cold_page(struct page *page, int cold);
     8.7 +static void __free_pages_ok(struct page *page, unsigned int order);
     8.8  
     8.9  /*
    8.10   * results with 256, 32 in the lowmem_reserve sysctl:
    8.11 @@ -169,20 +170,23 @@ static void bad_page(struct page *page)
    8.12   * All pages have PG_compound set.  All pages have their ->private pointing at
    8.13   * the head page (even the head page has this).
    8.14   *
    8.15 - * The first tail page's ->mapping, if non-zero, holds the address of the
    8.16 - * compound page's put_page() function.
    8.17 - *
    8.18 - * The order of the allocation is stored in the first tail page's ->index
    8.19 - * This is only for debug at present.  This usage means that zero-order pages
    8.20 - * may not be compound.
    8.21 + * The first tail page's ->lru.next holds the address of the compound page's
    8.22 + * put_page() function.  Its ->lru.prev holds the order of allocation.
    8.23 + * This usage means that zero-order pages may not be compound.
    8.24   */
    8.25 +
    8.26 +static void free_compound_page(struct page *page)
    8.27 +{
    8.28 +	__free_pages_ok(page, (unsigned long)page[1].lru.prev);
    8.29 +}
    8.30 +
    8.31  static void prep_compound_page(struct page *page, unsigned long order)
    8.32  {
    8.33  	int i;
    8.34  	int nr_pages = 1 << order;
    8.35  
    8.36 -	page[1].mapping = NULL;
    8.37 -	page[1].index = order;
    8.38 +	page[1].lru.next = (void *)free_compound_page;	/* set dtor */
    8.39 +	page[1].lru.prev = (void *)order;
    8.40  	for (i = 0; i < nr_pages; i++) {
    8.41  		struct page *p = page + i;
    8.42  
    8.43 @@ -196,7 +200,7 @@ static void destroy_compound_page(struct
    8.44  	int i;
    8.45  	int nr_pages = 1 << order;
    8.46  
    8.47 -	if (unlikely(page[1].index != order))
    8.48 +	if (unlikely((unsigned long)page[1].lru.prev != order))
    8.49  		bad_page(page);
    8.50  
    8.51  	for (i = 0; i < nr_pages; i++) {
    8.52 @@ -1539,29 +1543,29 @@ static int __initdata node_load[MAX_NUMN
    8.53   */
    8.54  static int __init find_next_best_node(int node, nodemask_t *used_node_mask)
    8.55  {
    8.56 -	int i, n, val;
    8.57 +	int n, val;
    8.58  	int min_val = INT_MAX;
    8.59  	int best_node = -1;
    8.60  
    8.61 -	for_each_online_node(i) {
    8.62 +	/* Use the local node if we haven't already */
    8.63 +	if (!node_isset(node, *used_node_mask)) {
    8.64 +		node_set(node, *used_node_mask);
    8.65 +		return node;
    8.66 +	}
    8.67 +
    8.68 +	for_each_online_node(n) {
    8.69  		cpumask_t tmp;
    8.70  
    8.71 -		/* Start from local node */
    8.72 -		n = (node+i) % num_online_nodes();
    8.73 -
    8.74  		/* Don't want a node to appear more than once */
    8.75  		if (node_isset(n, *used_node_mask))
    8.76  			continue;
    8.77  
    8.78 -		/* Use the local node if we haven't already */
    8.79 -		if (!node_isset(node, *used_node_mask)) {
    8.80 -			best_node = node;
    8.81 -			break;
    8.82 -		}
    8.83 -
    8.84  		/* Use the distance array to find the distance */
    8.85  		val = node_distance(node, n);
    8.86  
    8.87 +		/* Penalize nodes under us ("prefer the next node") */
    8.88 +		val += (n < node);
    8.89 +
    8.90  		/* Give preference to headless and unused nodes */
    8.91  		tmp = node_to_cpumask(n);
    8.92  		if (!cpus_empty(tmp))
     9.1 --- a/patches/linux-2.6.16-rc3/i386-mach-io-check-nmi.patch	Mon Feb 20 23:01:50 2006 +0000
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,45 +0,0 @@
     9.4 -diff -pruN ../pristine-linux-2.6.16-rc3/arch/i386/kernel/traps.c ./arch/i386/kernel/traps.c
     9.5 ---- ../pristine-linux-2.6.16-rc3/arch/i386/kernel/traps.c	2006-02-15 20:38:51.000000000 +0000
     9.6 -+++ ./arch/i386/kernel/traps.c	2006-02-15 20:40:43.000000000 +0000
     9.7 -@@ -567,18 +567,11 @@ static void mem_parity_error(unsigned ch
     9.8 - 
     9.9 - static void io_check_error(unsigned char reason, struct pt_regs * regs)
    9.10 - {
    9.11 --	unsigned long i;
    9.12 --
    9.13 - 	printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n");
    9.14 - 	show_registers(regs);
    9.15 - 
    9.16 - 	/* Re-enable the IOCK line, wait for a few seconds */
    9.17 --	reason = (reason & 0xf) | 8;
    9.18 --	outb(reason, 0x61);
    9.19 --	i = 2000;
    9.20 --	while (--i) udelay(1000);
    9.21 --	reason &= ~8;
    9.22 --	outb(reason, 0x61);
    9.23 -+	clear_io_check_error(reason);
    9.24 - }
    9.25 - 
    9.26 - static void unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
    9.27 -diff -pruN ../pristine-linux-2.6.16-rc3/include/asm-i386/mach-default/mach_traps.h ./include/asm-i386/mach-default/mach_traps.h
    9.28 ---- ../pristine-linux-2.6.16-rc3/include/asm-i386/mach-default/mach_traps.h	2006-01-03 03:21:10.000000000 +0000
    9.29 -+++ ./include/asm-i386/mach-default/mach_traps.h	2006-02-15 20:40:43.000000000 +0000
    9.30 -@@ -15,6 +15,18 @@ static inline void clear_mem_error(unsig
    9.31 - 	outb(reason, 0x61);
    9.32 - }
    9.33 - 
    9.34 -+static inline void clear_io_check_error(unsigned char reason)
    9.35 -+{
    9.36 -+	unsigned long i;
    9.37 -+
    9.38 -+	reason = (reason & 0xf) | 8;
    9.39 -+	outb(reason, 0x61);
    9.40 -+	i = 2000;
    9.41 -+	while (--i) udelay(1000);
    9.42 -+	reason &= ~8;
    9.43 -+	outb(reason, 0x61);
    9.44 -+}
    9.45 -+
    9.46 - static inline unsigned char get_nmi_reason(void)
    9.47 - {
    9.48 - 	return inb(0x61);
    10.1 --- a/patches/linux-2.6.16-rc3/net-csum.patch	Mon Feb 20 23:01:50 2006 +0000
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,41 +0,0 @@
    10.4 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/net/ipv4/netfilter/ip_nat_proto_tcp.c ./net/ipv4/netfilter/ip_nat_proto_tcp.c
    10.5 ---- ../pristine-linux-2.6.16-rc1-git4/net/ipv4/netfilter/ip_nat_proto_tcp.c	2006-02-02 17:39:51.000000000 +0000
    10.6 -+++ ./net/ipv4/netfilter/ip_nat_proto_tcp.c	2006-02-02 17:44:18.000000000 +0000
    10.7 -@@ -129,10 +129,14 @@ tcp_manip_pkt(struct sk_buff **pskb,
    10.8 - 	if (hdrsize < sizeof(*hdr))
    10.9 - 		return 1;
   10.10 - 
   10.11 --	hdr->check = ip_nat_cheat_check(~oldip, newip,
   10.12 -+	if ((*pskb)->proto_csum_blank) {
   10.13 -+		hdr->check = ip_nat_cheat_check(oldip, ~newip, hdr->check);
   10.14 -+	} else {
   10.15 -+		hdr->check = ip_nat_cheat_check(~oldip, newip,
   10.16 - 					ip_nat_cheat_check(oldport ^ 0xFFFF,
   10.17 - 							   newport,
   10.18 - 							   hdr->check));
   10.19 -+	}
   10.20 - 	return 1;
   10.21 - }
   10.22 -
   10.23 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/net/ipv4/netfilter/ip_nat_proto_udp.c ./net/ipv4/netfilter/ip_nat_proto_udp.c
   10.24 ---- ../pristine-linux-2.6.16-rc1-git4/net/ipv4/netfilter/ip_nat_proto_udp.c	2006-02-02 17:39:51.000000000 +0000
   10.25 -+++ ./net/ipv4/netfilter/ip_nat_proto_udp.c	2006-02-02 17:44:18.000000000 +0000
   10.26 -@@ -113,11 +113,16 @@ udp_manip_pkt(struct sk_buff **pskb,
   10.27 - 		newport = tuple->dst.u.udp.port;
   10.28 - 		portptr = &hdr->dest;
   10.29 - 	}
   10.30 --	if (hdr->check) /* 0 is a special case meaning no checksum */
   10.31 --		hdr->check = ip_nat_cheat_check(~oldip, newip,
   10.32 -+	if (hdr->check) { /* 0 is a special case meaning no checksum */
   10.33 -+		if ((*pskb)->proto_csum_blank) {
   10.34 -+			hdr->check = ip_nat_cheat_check(oldip, ~newip, hdr->check);
   10.35 -+		} else {
   10.36 -+			hdr->check = ip_nat_cheat_check(~oldip, newip,
   10.37 - 					ip_nat_cheat_check(*portptr ^ 0xFFFF,
   10.38 - 							   newport,
   10.39 - 							   hdr->check));
   10.40 -+		}
   10.41 -+	}
   10.42 - 	*portptr = newport;
   10.43 - 	return 1;
   10.44 - }
    11.1 --- a/patches/linux-2.6.16-rc3/pmd-shared.patch	Mon Feb 20 23:01:50 2006 +0000
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,111 +0,0 @@
    11.4 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/arch/i386/mm/pageattr.c ./arch/i386/mm/pageattr.c
    11.5 ---- ../pristine-linux-2.6.16-rc1-git4/arch/i386/mm/pageattr.c	2006-02-02 17:39:29.000000000 +0000
    11.6 -+++ ./arch/i386/mm/pageattr.c	2006-02-02 17:45:14.000000000 +0000
    11.7 -@@ -78,7 +78,7 @@ static void set_pmd_pte(pte_t *kpte, uns
    11.8 - 	unsigned long flags;
    11.9 - 
   11.10 - 	set_pte_atomic(kpte, pte); 	/* change init_mm */
   11.11 --	if (PTRS_PER_PMD > 1)
   11.12 -+	if (HAVE_SHARED_KERNEL_PMD)
   11.13 - 		return;
   11.14 - 
   11.15 - 	spin_lock_irqsave(&pgd_lock, flags);
   11.16 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/arch/i386/mm/pgtable.c ./arch/i386/mm/pgtable.c
   11.17 ---- ../pristine-linux-2.6.16-rc1-git4/arch/i386/mm/pgtable.c	2006-01-03 03:21:10.000000000 +0000
   11.18 -+++ ./arch/i386/mm/pgtable.c	2006-02-02 17:45:14.000000000 +0000
   11.19 -@@ -215,9 +215,10 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
   11.20 - 		spin_lock_irqsave(&pgd_lock, flags);
   11.21 - 	}
   11.22 - 
   11.23 --	clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
   11.24 --			swapper_pg_dir + USER_PTRS_PER_PGD,
   11.25 --			KERNEL_PGD_PTRS);
   11.26 -+	if (PTRS_PER_PMD == 1 || HAVE_SHARED_KERNEL_PMD)
   11.27 -+		clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
   11.28 -+				swapper_pg_dir + USER_PTRS_PER_PGD,
   11.29 -+				KERNEL_PGD_PTRS);
   11.30 - 	if (PTRS_PER_PMD > 1)
   11.31 - 		return;
   11.32 - 
   11.33 -@@ -249,6 +250,30 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
   11.34 - 			goto out_oom;
   11.35 - 		set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));
   11.36 - 	}
   11.37 -+
   11.38 -+	if (!HAVE_SHARED_KERNEL_PMD) {
   11.39 -+		unsigned long flags;
   11.40 -+
   11.41 -+		for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   11.42 -+			pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
   11.43 -+			if (!pmd)
   11.44 -+				goto out_oom;
   11.45 -+			set_pgd(&pgd[USER_PTRS_PER_PGD], __pgd(1 + __pa(pmd)));
   11.46 -+		}
   11.47 -+
   11.48 -+		spin_lock_irqsave(&pgd_lock, flags);
   11.49 -+		for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   11.50 -+			unsigned long v = (unsigned long)i << PGDIR_SHIFT;
   11.51 -+			pgd_t *kpgd = pgd_offset_k(v);
   11.52 -+			pud_t *kpud = pud_offset(kpgd, v);
   11.53 -+			pmd_t *kpmd = pmd_offset(kpud, v);
   11.54 -+			pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   11.55 -+			memcpy(pmd, kpmd, PAGE_SIZE);
   11.56 -+		}
   11.57 -+		pgd_list_add(pgd);
   11.58 -+		spin_unlock_irqrestore(&pgd_lock, flags);
   11.59 -+	}
   11.60 -+
   11.61 - 	return pgd;
   11.62 - 
   11.63 - out_oom:
   11.64 -@@ -263,9 +288,23 @@ void pgd_free(pgd_t *pgd)
   11.65 - 	int i;
   11.66 - 
   11.67 - 	/* in the PAE case user pgd entries are overwritten before usage */
   11.68 --	if (PTRS_PER_PMD > 1)
   11.69 --		for (i = 0; i < USER_PTRS_PER_PGD; ++i)
   11.70 --			kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1));
   11.71 -+	if (PTRS_PER_PMD > 1) {
   11.72 -+		for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
   11.73 -+			pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   11.74 -+			kmem_cache_free(pmd_cache, pmd);
   11.75 -+		}
   11.76 -+		if (!HAVE_SHARED_KERNEL_PMD) {
   11.77 -+			unsigned long flags;
   11.78 -+			spin_lock_irqsave(&pgd_lock, flags);
   11.79 -+			pgd_list_del(pgd);
   11.80 -+			spin_unlock_irqrestore(&pgd_lock, flags);
   11.81 -+			for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   11.82 -+				pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   11.83 -+				memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
   11.84 -+				kmem_cache_free(pmd_cache, pmd);
   11.85 -+			}
   11.86 -+		}
   11.87 -+	}
   11.88 - 	/* in the non-PAE case, free_pgtables() clears user pgd entries */
   11.89 - 	kmem_cache_free(pgd_cache, pgd);
   11.90 - }
   11.91 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/pgtable-2level-defs.h ./include/asm-i386/pgtable-2level-defs.h
   11.92 ---- ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/pgtable-2level-defs.h	2006-01-03 03:21:10.000000000 +0000
   11.93 -+++ ./include/asm-i386/pgtable-2level-defs.h	2006-02-02 17:45:14.000000000 +0000
   11.94 -@@ -1,6 +1,8 @@
   11.95 - #ifndef _I386_PGTABLE_2LEVEL_DEFS_H
   11.96 - #define _I386_PGTABLE_2LEVEL_DEFS_H
   11.97 - 
   11.98 -+#define HAVE_SHARED_KERNEL_PMD 0
   11.99 -+
  11.100 - /*
  11.101 -  * traditional i386 two-level paging structure:
  11.102 -  */
  11.103 -diff -pruN ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/pgtable-3level-defs.h ./include/asm-i386/pgtable-3level-defs.h
  11.104 ---- ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/pgtable-3level-defs.h	2006-01-03 03:21:10.000000000 +0000
  11.105 -+++ ./include/asm-i386/pgtable-3level-defs.h	2006-02-02 17:45:14.000000000 +0000
  11.106 -@@ -1,6 +1,8 @@
  11.107 - #ifndef _I386_PGTABLE_3LEVEL_DEFS_H
  11.108 - #define _I386_PGTABLE_3LEVEL_DEFS_H
  11.109 - 
  11.110 -+#define HAVE_SHARED_KERNEL_PMD 1
  11.111 -+
  11.112 - /*
  11.113 -  * PGDIR_SHIFT determines what a top-level page table entry can map
  11.114 -  */
    12.1 --- a/patches/linux-2.6.16-rc3/smp-alts.patch	Mon Feb 20 23:01:50 2006 +0000
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,591 +0,0 @@
    12.4 -diff -pruN ../pristine-linux-2.6.16-rc3/arch/i386/Kconfig ./arch/i386/Kconfig
    12.5 ---- ../pristine-linux-2.6.16-rc3/arch/i386/Kconfig	2006-02-15 20:38:51.000000000 +0000
    12.6 -+++ ./arch/i386/Kconfig	2006-02-15 20:45:57.000000000 +0000
    12.7 -@@ -202,6 +202,19 @@ config SMP
    12.8 - 
    12.9 - 	  If you don't know what to do here, say N.
   12.10 - 
   12.11 -+config SMP_ALTERNATIVES
   12.12 -+	bool "SMP alternatives support (EXPERIMENTAL)"
   12.13 -+	depends on SMP && EXPERIMENTAL
   12.14 -+	help
   12.15 -+	  Try to reduce the overhead of running an SMP kernel on a uniprocessor
   12.16 -+	  host slightly by replacing certain key instruction sequences
   12.17 -+	  according to whether we currently have more than one CPU available.
   12.18 -+	  This should provide a noticeable boost to performance when
   12.19 -+	  running SMP kernels on UP machines, and have negligible impact
   12.20 -+	  when running on an true SMP host.
   12.21 -+
   12.22 -+          If unsure, say N.
   12.23 -+	  
   12.24 - config NR_CPUS
   12.25 - 	int "Maximum number of CPUs (2-255)"
   12.26 - 	range 2 255
   12.27 -diff -pruN ../pristine-linux-2.6.16-rc3/arch/i386/kernel/Makefile ./arch/i386/kernel/Makefile
   12.28 ---- ../pristine-linux-2.6.16-rc3/arch/i386/kernel/Makefile	2006-02-15 20:38:51.000000000 +0000
   12.29 -+++ ./arch/i386/kernel/Makefile	2006-02-15 20:45:57.000000000 +0000
   12.30 -@@ -37,6 +37,7 @@ obj-$(CONFIG_EFI) 		+= efi.o efi_stub.o
   12.31 - obj-$(CONFIG_DOUBLEFAULT) 	+= doublefault.o
   12.32 - obj-$(CONFIG_VM86)		+= vm86.o
   12.33 - obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
   12.34 -+obj-$(CONFIG_SMP_ALTERNATIVES)  += smpalts.o
   12.35 - 
   12.36 - EXTRA_AFLAGS   := -traditional
   12.37 - 
   12.38 -diff -pruN ../pristine-linux-2.6.16-rc3/arch/i386/kernel/smpalts.c ./arch/i386/kernel/smpalts.c
   12.39 ---- ../pristine-linux-2.6.16-rc3/arch/i386/kernel/smpalts.c	1970-01-01 01:00:00.000000000 +0100
   12.40 -+++ ./arch/i386/kernel/smpalts.c	2006-02-15 20:45:57.000000000 +0000
   12.41 -@@ -0,0 +1,85 @@
   12.42 -+#include <linux/kernel.h>
   12.43 -+#include <asm/system.h>
   12.44 -+#include <asm/smp_alt.h>
   12.45 -+#include <asm/processor.h>
   12.46 -+#include <asm/string.h>
   12.47 -+
   12.48 -+struct smp_replacement_record {
   12.49 -+	unsigned char targ_size;
   12.50 -+	unsigned char smp1_size;
   12.51 -+	unsigned char smp2_size;
   12.52 -+	unsigned char up_size;
   12.53 -+	unsigned char feature;
   12.54 -+	unsigned char data[0];
   12.55 -+};
   12.56 -+
   12.57 -+struct smp_alternative_record {
   12.58 -+	void *targ_start;
   12.59 -+	struct smp_replacement_record *repl;
   12.60 -+};
   12.61 -+
   12.62 -+extern struct smp_alternative_record __start_smp_alternatives_table,
   12.63 -+  __stop_smp_alternatives_table;
   12.64 -+extern unsigned long __init_begin, __init_end;
   12.65 -+
   12.66 -+void prepare_for_smp(void)
   12.67 -+{
   12.68 -+	struct smp_alternative_record *r;
   12.69 -+	printk(KERN_INFO "Enabling SMP...\n");
   12.70 -+	for (r = &__start_smp_alternatives_table;
   12.71 -+	     r != &__stop_smp_alternatives_table;
   12.72 -+	     r++) {
   12.73 -+		BUG_ON(r->repl->targ_size < r->repl->smp1_size);
   12.74 -+		BUG_ON(r->repl->targ_size < r->repl->smp2_size);
   12.75 -+		BUG_ON(r->repl->targ_size < r->repl->up_size);
   12.76 -+               if (system_state == SYSTEM_RUNNING &&
   12.77 -+                   r->targ_start >= (void *)&__init_begin &&
   12.78 -+                   r->targ_start < (void *)&__init_end)
   12.79 -+                       continue;
   12.80 -+		if (r->repl->feature != (unsigned char)-1 &&
   12.81 -+		    boot_cpu_has(r->repl->feature)) {
   12.82 -+			memcpy(r->targ_start,
   12.83 -+			       r->repl->data + r->repl->smp1_size,
   12.84 -+			       r->repl->smp2_size);
   12.85 -+			memset(r->targ_start + r->repl->smp2_size,
   12.86 -+			       0x90,
   12.87 -+			       r->repl->targ_size - r->repl->smp2_size);
   12.88 -+		} else {
   12.89 -+			memcpy(r->targ_start,
   12.90 -+			       r->repl->data,
   12.91 -+			       r->repl->smp1_size);
   12.92 -+			memset(r->targ_start + r->repl->smp1_size,
   12.93 -+			       0x90,
   12.94 -+			       r->repl->targ_size - r->repl->smp1_size);
   12.95 -+		}
   12.96 -+	}
   12.97 -+	/* Paranoia */
   12.98 -+	asm volatile ("jmp 1f\n1:");
   12.99 -+	mb();
  12.100 -+}
  12.101 -+
  12.102 -+void unprepare_for_smp(void)
  12.103 -+{
  12.104 -+	struct smp_alternative_record *r;
  12.105 -+	printk(KERN_INFO "Disabling SMP...\n");
  12.106 -+	for (r = &__start_smp_alternatives_table;
  12.107 -+	     r != &__stop_smp_alternatives_table;
  12.108 -+	     r++) {
  12.109 -+		BUG_ON(r->repl->targ_size < r->repl->smp1_size);
  12.110 -+		BUG_ON(r->repl->targ_size < r->repl->smp2_size);
  12.111 -+		BUG_ON(r->repl->targ_size < r->repl->up_size);
  12.112 -+               if (system_state == SYSTEM_RUNNING &&
  12.113 -+                   r->targ_start >= (void *)&__init_begin &&
  12.114 -+                   r->targ_start < (void *)&__init_end)
  12.115 -+                       continue;
  12.116 -+		memcpy(r->targ_start,
  12.117 -+		       r->repl->data + r->repl->smp1_size + r->repl->smp2_size,
  12.118 -+		       r->repl->up_size);
  12.119 -+		memset(r->targ_start + r->repl->up_size,
  12.120 -+		       0x90,
  12.121 -+		       r->repl->targ_size - r->repl->up_size);
  12.122 -+	}
  12.123 -+	/* Paranoia */
  12.124 -+	asm volatile ("jmp 1f\n1:");
  12.125 -+	mb();
  12.126 -+}
  12.127 -diff -pruN ../pristine-linux-2.6.16-rc3/arch/i386/kernel/smpboot.c ./arch/i386/kernel/smpboot.c
  12.128 ---- ../pristine-linux-2.6.16-rc3/arch/i386/kernel/smpboot.c	2006-02-15 20:38:51.000000000 +0000
  12.129 -+++ ./arch/i386/kernel/smpboot.c	2006-02-15 20:45:57.000000000 +0000
  12.130 -@@ -1214,6 +1214,11 @@ static void __init smp_boot_cpus(unsigne
  12.131 - 		if (max_cpus <= cpucount+1)
  12.132 - 			continue;
  12.133 - 
  12.134 -+#ifdef CONFIG_SMP_ALTERNATIVES
  12.135 -+		if (kicked == 1)
  12.136 -+			prepare_for_smp();
  12.137 -+#endif
  12.138 -+
  12.139 - 		if (((cpu = alloc_cpu_id()) <= 0) || do_boot_cpu(apicid, cpu))
  12.140 - 			printk("CPU #%d not responding - cannot use it.\n",
  12.141 - 								apicid);
  12.142 -@@ -1392,6 +1397,11 @@ int __devinit __cpu_up(unsigned int cpu)
  12.143 - 		return -EIO;
  12.144 - 	}
  12.145 - 
  12.146 -+#ifdef CONFIG_SMP_ALTERNATIVES
  12.147 -+	if (num_online_cpus() == 1)
  12.148 -+		prepare_for_smp();
  12.149 -+#endif
  12.150 -+
  12.151 - 	local_irq_enable();
  12.152 - 	per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
  12.153 - 	/* Unleash the CPU! */
  12.154 -diff -pruN ../pristine-linux-2.6.16-rc3/arch/i386/kernel/vmlinux.lds.S ./arch/i386/kernel/vmlinux.lds.S
  12.155 ---- ../pristine-linux-2.6.16-rc3/arch/i386/kernel/vmlinux.lds.S	2006-01-03 03:21:10.000000000 +0000
  12.156 -+++ ./arch/i386/kernel/vmlinux.lds.S	2006-02-15 20:45:57.000000000 +0000
  12.157 -@@ -34,6 +34,13 @@ SECTIONS
  12.158 -   __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
  12.159 -   __stop___ex_table = .;
  12.160 - 
  12.161 -+  . = ALIGN(16);
  12.162 -+  __start_smp_alternatives_table = .;
  12.163 -+  __smp_alternatives : { *(__smp_alternatives) }
  12.164 -+  __stop_smp_alternatives_table = .;
  12.165 -+
  12.166 -+  __smp_replacements : { *(__smp_replacements) }
  12.167 -+
  12.168 -   RODATA
  12.169 - 
  12.170 -   /* writeable */
  12.171 -diff -pruN ../pristine-linux-2.6.16-rc3/include/asm-i386/atomic.h ./include/asm-i386/atomic.h
  12.172 ---- ../pristine-linux-2.6.16-rc3/include/asm-i386/atomic.h	2006-02-15 20:38:57.000000000 +0000
  12.173 -+++ ./include/asm-i386/atomic.h	2006-02-15 20:45:57.000000000 +0000
  12.174 -@@ -4,18 +4,13 @@
  12.175 - #include <linux/config.h>
  12.176 - #include <linux/compiler.h>
  12.177 - #include <asm/processor.h>
  12.178 -+#include <asm/smp_alt.h>
  12.179 - 
  12.180 - /*
  12.181 -  * Atomic operations that C can't guarantee us.  Useful for
  12.182 -  * resource counting etc..
  12.183 -  */
  12.184 - 
  12.185 --#ifdef CONFIG_SMP
  12.186 --#define LOCK "lock ; "
  12.187 --#else
  12.188 --#define LOCK ""
  12.189 --#endif
  12.190 --
  12.191 - /*
  12.192 -  * Make sure gcc doesn't try to be clever and move things around
  12.193 -  * on us. We need to use _exactly_ the address the user gave us,
  12.194 -diff -pruN ../pristine-linux-2.6.16-rc3/include/asm-i386/bitops.h ./include/asm-i386/bitops.h
  12.195 ---- ../pristine-linux-2.6.16-rc3/include/asm-i386/bitops.h	2006-02-15 20:38:57.000000000 +0000
  12.196 -+++ ./include/asm-i386/bitops.h	2006-02-15 20:45:57.000000000 +0000
  12.197 -@@ -7,6 +7,7 @@
  12.198 - 
  12.199 - #include <linux/config.h>
  12.200 - #include <linux/compiler.h>
  12.201 -+#include <asm/smp_alt.h>
  12.202 - 
  12.203 - /*
  12.204 -  * These have to be done with inline assembly: that way the bit-setting
  12.205 -@@ -16,12 +17,6 @@
  12.206 -  * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
  12.207 -  */
  12.208 - 
  12.209 --#ifdef CONFIG_SMP
  12.210 --#define LOCK_PREFIX "lock ; "
  12.211 --#else
  12.212 --#define LOCK_PREFIX ""
  12.213 --#endif
  12.214 --
  12.215 - #define ADDR (*(volatile long *) addr)
  12.216 - 
  12.217 - /**
  12.218 -@@ -41,7 +36,7 @@
  12.219 -  */
  12.220 - static inline void set_bit(int nr, volatile unsigned long * addr)
  12.221 - {
  12.222 --	__asm__ __volatile__( LOCK_PREFIX
  12.223 -+	__asm__ __volatile__( LOCK
  12.224 - 		"btsl %1,%0"
  12.225 - 		:"+m" (ADDR)
  12.226 - 		:"Ir" (nr));
  12.227 -@@ -76,7 +71,7 @@ static inline void __set_bit(int nr, vol
  12.228 -  */
  12.229 - static inline void clear_bit(int nr, volatile unsigned long * addr)
  12.230 - {
  12.231 --	__asm__ __volatile__( LOCK_PREFIX
  12.232 -+	__asm__ __volatile__( LOCK
  12.233 - 		"btrl %1,%0"
  12.234 - 		:"+m" (ADDR)
  12.235 - 		:"Ir" (nr));
  12.236 -@@ -121,7 +116,7 @@ static inline void __change_bit(int nr, 
  12.237 -  */
  12.238 - static inline void change_bit(int nr, volatile unsigned long * addr)
  12.239 - {
  12.240 --	__asm__ __volatile__( LOCK_PREFIX
  12.241 -+	__asm__ __volatile__( LOCK
  12.242 - 		"btcl %1,%0"
  12.243 - 		:"+m" (ADDR)
  12.244 - 		:"Ir" (nr));
  12.245 -@@ -140,7 +135,7 @@ static inline int test_and_set_bit(int n
  12.246 - {
  12.247 - 	int oldbit;
  12.248 - 
  12.249 --	__asm__ __volatile__( LOCK_PREFIX
  12.250 -+	__asm__ __volatile__( LOCK
  12.251 - 		"btsl %2,%1\n\tsbbl %0,%0"
  12.252 - 		:"=r" (oldbit),"+m" (ADDR)
  12.253 - 		:"Ir" (nr) : "memory");
  12.254 -@@ -180,7 +175,7 @@ static inline int test_and_clear_bit(int
  12.255 - {
  12.256 - 	int oldbit;
  12.257 - 
  12.258 --	__asm__ __volatile__( LOCK_PREFIX
  12.259 -+	__asm__ __volatile__( LOCK
  12.260 - 		"btrl %2,%1\n\tsbbl %0,%0"
  12.261 - 		:"=r" (oldbit),"+m" (ADDR)
  12.262 - 		:"Ir" (nr) : "memory");
  12.263 -@@ -231,7 +226,7 @@ static inline int test_and_change_bit(in
  12.264 - {
  12.265 - 	int oldbit;
  12.266 - 
  12.267 --	__asm__ __volatile__( LOCK_PREFIX
  12.268 -+	__asm__ __volatile__( LOCK
  12.269 - 		"btcl %2,%1\n\tsbbl %0,%0"
  12.270 - 		:"=r" (oldbit),"+m" (ADDR)
  12.271 - 		:"Ir" (nr) : "memory");
  12.272 -diff -pruN ../pristine-linux-2.6.16-rc3/include/asm-i386/futex.h ./include/asm-i386/futex.h
  12.273 ---- ../pristine-linux-2.6.16-rc3/include/asm-i386/futex.h	2006-02-15 20:38:57.000000000 +0000
  12.274 -+++ ./include/asm-i386/futex.h	2006-02-15 20:45:57.000000000 +0000
  12.275 -@@ -28,7 +28,7 @@
  12.276 - "1:	movl	%2, %0\n\
  12.277 - 	movl	%0, %3\n"					\
  12.278 - 	insn "\n"						\
  12.279 --"2:	" LOCK_PREFIX "cmpxchgl %3, %2\n\
  12.280 -+"2:	" LOCK "cmpxchgl %3, %2\n\
  12.281 - 	jnz	1b\n\
  12.282 - 3:	.section .fixup,\"ax\"\n\
  12.283 - 4:	mov	%5, %1\n\
  12.284 -@@ -68,7 +68,7 @@ futex_atomic_op_inuser (int encoded_op, 
  12.285 - #endif
  12.286 - 		switch (op) {
  12.287 - 		case FUTEX_OP_ADD:
  12.288 --			__futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret,
  12.289 -+			__futex_atomic_op1(LOCK "xaddl %0, %2", ret,
  12.290 - 					   oldval, uaddr, oparg);
  12.291 - 			break;
  12.292 - 		case FUTEX_OP_OR:
  12.293 -diff -pruN ../pristine-linux-2.6.16-rc3/include/asm-i386/rwsem.h ./include/asm-i386/rwsem.h
  12.294 ---- ../pristine-linux-2.6.16-rc3/include/asm-i386/rwsem.h	2006-01-03 03:21:10.000000000 +0000
  12.295 -+++ ./include/asm-i386/rwsem.h	2006-02-15 20:45:57.000000000 +0000
  12.296 -@@ -40,6 +40,7 @@
  12.297 - 
  12.298 - #include <linux/list.h>
  12.299 - #include <linux/spinlock.h>
  12.300 -+#include <asm/smp_alt.h>
  12.301 - 
  12.302 - struct rwsem_waiter;
  12.303 - 
  12.304 -@@ -99,7 +100,7 @@ static inline void __down_read(struct rw
  12.305 - {
  12.306 - 	__asm__ __volatile__(
  12.307 - 		"# beginning down_read\n\t"
  12.308 --LOCK_PREFIX	"  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old value */
  12.309 -+LOCK	        "  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old value */
  12.310 - 		"  js        2f\n\t" /* jump if we weren't granted the lock */
  12.311 - 		"1:\n\t"
  12.312 - 		LOCK_SECTION_START("")
  12.313 -@@ -130,7 +131,7 @@ static inline int __down_read_trylock(st
  12.314 - 		"  movl	     %1,%2\n\t"
  12.315 - 		"  addl      %3,%2\n\t"
  12.316 - 		"  jle	     2f\n\t"
  12.317 --LOCK_PREFIX	"  cmpxchgl  %2,%0\n\t"
  12.318 -+LOCK	        "  cmpxchgl  %2,%0\n\t"
  12.319 - 		"  jnz	     1b\n\t"
  12.320 - 		"2:\n\t"
  12.321 - 		"# ending __down_read_trylock\n\t"
  12.322 -@@ -150,7 +151,7 @@ static inline void __down_write(struct r
  12.323 - 	tmp = RWSEM_ACTIVE_WRITE_BIAS;
  12.324 - 	__asm__ __volatile__(
  12.325 - 		"# beginning down_write\n\t"
  12.326 --LOCK_PREFIX	"  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
  12.327 -+LOCK	        "  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
  12.328 - 		"  testl     %%edx,%%edx\n\t" /* was the count 0 before? */
  12.329 - 		"  jnz       2f\n\t" /* jump if we weren't granted the lock */
  12.330 - 		"1:\n\t"
  12.331 -@@ -188,7 +189,7 @@ static inline void __up_read(struct rw_s
  12.332 - 	__s32 tmp = -RWSEM_ACTIVE_READ_BIAS;
  12.333 - 	__asm__ __volatile__(
  12.334 - 		"# beginning __up_read\n\t"
  12.335 --LOCK_PREFIX	"  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
  12.336 -+LOCK	        "  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
  12.337 - 		"  js        2f\n\t" /* jump if the lock is being waited upon */
  12.338 - 		"1:\n\t"
  12.339 - 		LOCK_SECTION_START("")
  12.340 -@@ -214,7 +215,7 @@ static inline void __up_write(struct rw_
  12.341 - 	__asm__ __volatile__(
  12.342 - 		"# beginning __up_write\n\t"
  12.343 - 		"  movl      %2,%%edx\n\t"
  12.344 --LOCK_PREFIX	"  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
  12.345 -+LOCK	        "  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
  12.346 - 		"  jnz       2f\n\t" /* jump if the lock is being waited upon */
  12.347 - 		"1:\n\t"
  12.348 - 		LOCK_SECTION_START("")
  12.349 -@@ -239,7 +240,7 @@ static inline void __downgrade_write(str
  12.350 - {
  12.351 - 	__asm__ __volatile__(
  12.352 - 		"# beginning __downgrade_write\n\t"
  12.353 --LOCK_PREFIX	"  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
  12.354 -+LOCK	        "  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
  12.355 - 		"  js        2f\n\t" /* jump if the lock is being waited upon */
  12.356 - 		"1:\n\t"
  12.357 - 		LOCK_SECTION_START("")
  12.358 -@@ -263,7 +264,7 @@ LOCK_PREFIX	"  addl      %2,(%%eax)\n\t"
  12.359 - static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem)
  12.360 - {
  12.361 - 	__asm__ __volatile__(
  12.362 --LOCK_PREFIX	"addl %1,%0"
  12.363 -+LOCK	          "addl %1,%0"
  12.364 - 		: "=m"(sem->count)
  12.365 - 		: "ir"(delta), "m"(sem->count));
  12.366 - }
  12.367 -@@ -276,7 +277,7 @@ static inline int rwsem_atomic_update(in
  12.368 - 	int tmp = delta;
  12.369 - 
  12.370 - 	__asm__ __volatile__(
  12.371 --LOCK_PREFIX	"xadd %0,(%2)"
  12.372 -+LOCK  	          "xadd %0,(%2)"
  12.373 - 		: "+r"(tmp), "=m"(sem->count)
  12.374 - 		: "r"(sem), "m"(sem->count)
  12.375 - 		: "memory");
  12.376 -diff -pruN ../pristine-linux-2.6.16-rc3/include/asm-i386/smp_alt.h ./include/asm-i386/smp_alt.h
  12.377 ---- ../pristine-linux-2.6.16-rc3/include/asm-i386/smp_alt.h	1970-01-01 01:00:00.000000000 +0100
  12.378 -+++ ./include/asm-i386/smp_alt.h	2006-02-15 20:45:57.000000000 +0000
  12.379 -@@ -0,0 +1,32 @@
  12.380 -+#ifndef __ASM_SMP_ALT_H__
  12.381 -+#define __ASM_SMP_ALT_H__
  12.382 -+
  12.383 -+#include <linux/config.h>
  12.384 -+
  12.385 -+#ifdef CONFIG_SMP
  12.386 -+#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
  12.387 -+#define LOCK \
  12.388 -+        "6677: nop\n" \
  12.389 -+	".section __smp_alternatives,\"a\"\n" \
  12.390 -+	".long 6677b\n" \
  12.391 -+	".long 6678f\n" \
  12.392 -+	".previous\n" \
  12.393 -+	".section __smp_replacements,\"a\"\n" \
  12.394 -+	"6678: .byte 1\n" \
  12.395 -+	".byte 1\n" \
  12.396 -+	".byte 0\n" \
  12.397 -+        ".byte 1\n" \
  12.398 -+	".byte -1\n" \
  12.399 -+	"lock\n" \
  12.400 -+	"nop\n" \
  12.401 -+	".previous\n"
  12.402 -+void prepare_for_smp(void);
  12.403 -+void unprepare_for_smp(void);
  12.404 -+#else
  12.405 -+#define LOCK "lock ; "
  12.406 -+#endif
  12.407 -+#else
  12.408 -+#define LOCK ""
  12.409 -+#endif
  12.410 -+
  12.411 -+#endif /* __ASM_SMP_ALT_H__ */
  12.412 -diff -pruN ../pristine-linux-2.6.16-rc3/include/asm-i386/spinlock.h ./include/asm-i386/spinlock.h
  12.413 ---- ../pristine-linux-2.6.16-rc3/include/asm-i386/spinlock.h	2006-01-03 03:21:10.000000000 +0000
  12.414 -+++ ./include/asm-i386/spinlock.h	2006-02-15 20:45:57.000000000 +0000
  12.415 -@@ -6,6 +6,7 @@
  12.416 - #include <asm/page.h>
  12.417 - #include <linux/config.h>
  12.418 - #include <linux/compiler.h>
  12.419 -+#include <asm/smp_alt.h>
  12.420 - 
  12.421 - /*
  12.422 -  * Your basic SMP spinlocks, allowing only a single CPU anywhere
  12.423 -@@ -23,7 +24,8 @@
  12.424 - 
  12.425 - #define __raw_spin_lock_string \
  12.426 - 	"\n1:\t" \
  12.427 --	"lock ; decb %0\n\t" \
  12.428 -+	LOCK \
  12.429 -+	"decb %0\n\t" \
  12.430 - 	"jns 3f\n" \
  12.431 - 	"2:\t" \
  12.432 - 	"rep;nop\n\t" \
  12.433 -@@ -34,7 +36,8 @@
  12.434 - 
  12.435 - #define __raw_spin_lock_string_flags \
  12.436 - 	"\n1:\t" \
  12.437 --	"lock ; decb %0\n\t" \
  12.438 -+	LOCK \
  12.439 -+	"decb %0\n\t" \
  12.440 - 	"jns 4f\n\t" \
  12.441 - 	"2:\t" \
  12.442 - 	"testl $0x200, %1\n\t" \
  12.443 -@@ -65,10 +68,34 @@ static inline void __raw_spin_lock_flags
  12.444 - static inline int __raw_spin_trylock(raw_spinlock_t *lock)
  12.445 - {
  12.446 - 	char oldval;
  12.447 -+#ifdef CONFIG_SMP_ALTERNATIVES
  12.448 - 	__asm__ __volatile__(
  12.449 --		"xchgb %b0,%1"
  12.450 -+		"1:movb %1,%b0\n"
  12.451 -+		"movb $0,%1\n"
  12.452 -+		"2:"
  12.453 -+		".section __smp_alternatives,\"a\"\n"
  12.454 -+		".long 1b\n"
  12.455 -+		".long 3f\n"
  12.456 -+		".previous\n"
  12.457 -+		".section __smp_replacements,\"a\"\n"
  12.458 -+		"3: .byte 2b - 1b\n"
  12.459 -+		".byte 5f-4f\n"
  12.460 -+		".byte 0\n"
  12.461 -+		".byte 6f-5f\n"
  12.462 -+		".byte -1\n"
  12.463 -+		"4: xchgb %b0,%1\n"
  12.464 -+		"5: movb %1,%b0\n"
  12.465 -+		"movb $0,%1\n"
  12.466 -+		"6:\n"
  12.467 -+		".previous\n"
  12.468 - 		:"=q" (oldval), "=m" (lock->slock)
  12.469 - 		:"0" (0) : "memory");
  12.470 -+#else
  12.471 -+	__asm__ __volatile__(
  12.472 -+		"xchgb %b0,%1\n"
  12.473 -+		:"=q" (oldval), "=m" (lock->slock)
  12.474 -+		:"0" (0) : "memory");
  12.475 -+#endif
  12.476 - 	return oldval > 0;
  12.477 - }
  12.478 - 
  12.479 -@@ -178,12 +205,12 @@ static inline int __raw_write_trylock(ra
  12.480 - 
  12.481 - static inline void __raw_read_unlock(raw_rwlock_t *rw)
  12.482 - {
  12.483 --	asm volatile("lock ; incl %0" :"=m" (rw->lock) : : "memory");
  12.484 -+	asm volatile(LOCK "incl %0" :"=m" (rw->lock) : : "memory");
  12.485 - }
  12.486 - 
  12.487 - static inline void __raw_write_unlock(raw_rwlock_t *rw)
  12.488 - {
  12.489 --	asm volatile("lock ; addl $" RW_LOCK_BIAS_STR ", %0"
  12.490 -+	asm volatile(LOCK "addl $" RW_LOCK_BIAS_STR ", %0"
  12.491 - 				 : "=m" (rw->lock) : : "memory");
  12.492 - }
  12.493 - 
  12.494 -diff -pruN ../pristine-linux-2.6.16-rc3/include/asm-i386/system.h ./include/asm-i386/system.h
  12.495 ---- ../pristine-linux-2.6.16-rc3/include/asm-i386/system.h	2006-02-15 20:38:57.000000000 +0000
  12.496 -+++ ./include/asm-i386/system.h	2006-02-15 20:45:57.000000000 +0000
  12.497 -@@ -5,7 +5,7 @@
  12.498 - #include <linux/kernel.h>
  12.499 - #include <asm/segment.h>
  12.500 - #include <asm/cpufeature.h>
  12.501 --#include <linux/bitops.h> /* for LOCK_PREFIX */
  12.502 -+#include <asm/smp_alt.h>
  12.503 - 
  12.504 - #ifdef __KERNEL__
  12.505 - 
  12.506 -@@ -271,19 +271,19 @@ static inline unsigned long __cmpxchg(vo
  12.507 - 	unsigned long prev;
  12.508 - 	switch (size) {
  12.509 - 	case 1:
  12.510 --		__asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
  12.511 -+		__asm__ __volatile__(LOCK "cmpxchgb %b1,%2"
  12.512 - 				     : "=a"(prev)
  12.513 - 				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
  12.514 - 				     : "memory");
  12.515 - 		return prev;
  12.516 - 	case 2:
  12.517 --		__asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
  12.518 -+		__asm__ __volatile__(LOCK "cmpxchgw %w1,%2"
  12.519 - 				     : "=a"(prev)
  12.520 - 				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
  12.521 - 				     : "memory");
  12.522 - 		return prev;
  12.523 - 	case 4:
  12.524 --		__asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
  12.525 -+		__asm__ __volatile__(LOCK "cmpxchgl %1,%2"
  12.526 - 				     : "=a"(prev)
  12.527 - 				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
  12.528 - 				     : "memory");
  12.529 -@@ -336,7 +336,7 @@ static inline unsigned long long __cmpxc
  12.530 - 				      unsigned long long new)
  12.531 - {
  12.532 - 	unsigned long long prev;
  12.533 --	__asm__ __volatile__(LOCK_PREFIX "cmpxchg8b %3"
  12.534 -+	__asm__ __volatile__(LOCK "cmpxchg8b %3"
  12.535 - 			     : "=A"(prev)
  12.536 - 			     : "b"((unsigned long)new),
  12.537 - 			       "c"((unsigned long)(new >> 32)),
  12.538 -@@ -503,11 +503,55 @@ struct alt_instr { 
  12.539 - #endif
  12.540 - 
  12.541 - #ifdef CONFIG_SMP
  12.542 -+#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
  12.543 -+#define smp_alt_mb(instr)                                           \
  12.544 -+__asm__ __volatile__("6667:\nnop\nnop\nnop\nnop\nnop\nnop\n6668:\n" \
  12.545 -+		     ".section __smp_alternatives,\"a\"\n"          \
  12.546 -+		     ".long 6667b\n"                                \
  12.547 -+                     ".long 6673f\n"                                \
  12.548 -+		     ".previous\n"                                  \
  12.549 -+		     ".section __smp_replacements,\"a\"\n"          \
  12.550 -+		     "6673:.byte 6668b-6667b\n"                     \
  12.551 -+		     ".byte 6670f-6669f\n"                          \
  12.552 -+		     ".byte 6671f-6670f\n"                          \
  12.553 -+                     ".byte 0\n"                                    \
  12.554 -+		     ".byte %c0\n"                                  \
  12.555 -+		     "6669:lock;addl $0,0(%%esp)\n"                 \
  12.556 -+		     "6670:" instr "\n"                             \
  12.557 -+		     "6671:\n"                                      \
  12.558 -+		     ".previous\n"                                  \
  12.559 -+		     :                                              \
  12.560 -+		     : "i" (X86_FEATURE_XMM2)                       \
  12.561 -+		     : "memory")
  12.562 -+#define smp_rmb() smp_alt_mb("lfence")
  12.563 -+#define smp_mb()  smp_alt_mb("mfence")
  12.564 -+#define set_mb(var, value) do {                                     \
  12.565 -+unsigned long __set_mb_temp;                                        \
  12.566 -+__asm__ __volatile__("6667:movl %1, %0\n6668:\n"                    \
  12.567 -+		     ".section __smp_alternatives,\"a\"\n"          \
  12.568 -+		     ".long 6667b\n"                                \
  12.569 -+		     ".long 6673f\n"                                \
  12.570 -+		     ".previous\n"                                  \
  12.571 -+		     ".section __smp_replacements,\"a\"\n"          \
  12.572 -+		     "6673: .byte 6668b-6667b\n"                    \
  12.573 -+		     ".byte 6670f-6669f\n"                          \
  12.574 -+		     ".byte 0\n"                                    \
  12.575 -+		     ".byte 6671f-6670f\n"                          \
  12.576 -+		     ".byte -1\n"                                   \
  12.577 -+		     "6669: xchg %1, %0\n"                          \
  12.578 -+		     "6670:movl %1, %0\n"                           \
  12.579 -+		     "6671:\n"                                      \
  12.580 -+		     ".previous\n"                                  \
  12.581 -+		     : "=m" (var), "=r" (__set_mb_temp)             \
  12.582 -+		     : "1" (value)                                  \
  12.583 -+		     : "memory"); } while (0)
  12.584 -+#else
  12.585 - #define smp_mb()	mb()
  12.586 - #define smp_rmb()	rmb()
  12.587 -+#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
  12.588 -+#endif
  12.589 - #define smp_wmb()	wmb()
  12.590 - #define smp_read_barrier_depends()	read_barrier_depends()
  12.591 --#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
  12.592 - #else
  12.593 - #define smp_mb()	barrier()
  12.594 - #define smp_rmb()	barrier()
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/patches/linux-2.6.16-rc4/i386-mach-io-check-nmi.patch	Tue Feb 21 11:19:13 2006 +0000
    13.3 @@ -0,0 +1,45 @@
    13.4 +diff -pruN ../pristine-linux-2.6.16-rc3/arch/i386/kernel/traps.c ./arch/i386/kernel/traps.c
    13.5 +--- ../pristine-linux-2.6.16-rc3/arch/i386/kernel/traps.c	2006-02-15 20:38:51.000000000 +0000
    13.6 ++++ ./arch/i386/kernel/traps.c	2006-02-15 20:40:43.000000000 +0000
    13.7 +@@ -567,18 +567,11 @@ static void mem_parity_error(unsigned ch
    13.8 + 
    13.9 + static void io_check_error(unsigned char reason, struct pt_regs * regs)
   13.10 + {
   13.11 +-	unsigned long i;
   13.12 +-
   13.13 + 	printk(KERN_EMERG "NMI: IOCK error (debug interrupt?)\n");
   13.14 + 	show_registers(regs);
   13.15 + 
   13.16 + 	/* Re-enable the IOCK line, wait for a few seconds */
   13.17 +-	reason = (reason & 0xf) | 8;
   13.18 +-	outb(reason, 0x61);
   13.19 +-	i = 2000;
   13.20 +-	while (--i) udelay(1000);
   13.21 +-	reason &= ~8;
   13.22 +-	outb(reason, 0x61);
   13.23 ++	clear_io_check_error(reason);
   13.24 + }
   13.25 + 
   13.26 + static void unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
   13.27 +diff -pruN ../pristine-linux-2.6.16-rc3/include/asm-i386/mach-default/mach_traps.h ./include/asm-i386/mach-default/mach_traps.h
   13.28 +--- ../pristine-linux-2.6.16-rc3/include/asm-i386/mach-default/mach_traps.h	2006-01-03 03:21:10.000000000 +0000
   13.29 ++++ ./include/asm-i386/mach-default/mach_traps.h	2006-02-15 20:40:43.000000000 +0000
   13.30 +@@ -15,6 +15,18 @@ static inline void clear_mem_error(unsig
   13.31 + 	outb(reason, 0x61);
   13.32 + }
   13.33 + 
   13.34 ++static inline void clear_io_check_error(unsigned char reason)
   13.35 ++{
   13.36 ++	unsigned long i;
   13.37 ++
   13.38 ++	reason = (reason & 0xf) | 8;
   13.39 ++	outb(reason, 0x61);
   13.40 ++	i = 2000;
   13.41 ++	while (--i) udelay(1000);
   13.42 ++	reason &= ~8;
   13.43 ++	outb(reason, 0x61);
   13.44 ++}
   13.45 ++
   13.46 + static inline unsigned char get_nmi_reason(void)
   13.47 + {
   13.48 + 	return inb(0x61);
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/patches/linux-2.6.16-rc4/net-csum.patch	Tue Feb 21 11:19:13 2006 +0000
    14.3 @@ -0,0 +1,41 @@
    14.4 +diff -pruN ../pristine-linux-2.6.16-rc1-git4/net/ipv4/netfilter/ip_nat_proto_tcp.c ./net/ipv4/netfilter/ip_nat_proto_tcp.c
    14.5 +--- ../pristine-linux-2.6.16-rc1-git4/net/ipv4/netfilter/ip_nat_proto_tcp.c	2006-02-02 17:39:51.000000000 +0000
    14.6 ++++ ./net/ipv4/netfilter/ip_nat_proto_tcp.c	2006-02-02 17:44:18.000000000 +0000
    14.7 +@@ -129,10 +129,14 @@ tcp_manip_pkt(struct sk_buff **pskb,
    14.8 + 	if (hdrsize < sizeof(*hdr))
    14.9 + 		return 1;
   14.10 + 
   14.11 +-	hdr->check = ip_nat_cheat_check(~oldip, newip,
   14.12 ++	if ((*pskb)->proto_csum_blank) {
   14.13 ++		hdr->check = ip_nat_cheat_check(oldip, ~newip, hdr->check);
   14.14 ++	} else {
   14.15 ++		hdr->check = ip_nat_cheat_check(~oldip, newip,
   14.16 + 					ip_nat_cheat_check(oldport ^ 0xFFFF,
   14.17 + 							   newport,
   14.18 + 							   hdr->check));
   14.19 ++	}
   14.20 + 	return 1;
   14.21 + }
   14.22 +
   14.23 +diff -pruN ../pristine-linux-2.6.16-rc1-git4/net/ipv4/netfilter/ip_nat_proto_udp.c ./net/ipv4/netfilter/ip_nat_proto_udp.c
   14.24 +--- ../pristine-linux-2.6.16-rc1-git4/net/ipv4/netfilter/ip_nat_proto_udp.c	2006-02-02 17:39:51.000000000 +0000
   14.25 ++++ ./net/ipv4/netfilter/ip_nat_proto_udp.c	2006-02-02 17:44:18.000000000 +0000
   14.26 +@@ -113,11 +113,16 @@ udp_manip_pkt(struct sk_buff **pskb,
   14.27 + 		newport = tuple->dst.u.udp.port;
   14.28 + 		portptr = &hdr->dest;
   14.29 + 	}
   14.30 +-	if (hdr->check) /* 0 is a special case meaning no checksum */
   14.31 +-		hdr->check = ip_nat_cheat_check(~oldip, newip,
   14.32 ++	if (hdr->check) { /* 0 is a special case meaning no checksum */
   14.33 ++		if ((*pskb)->proto_csum_blank) {
   14.34 ++			hdr->check = ip_nat_cheat_check(oldip, ~newip, hdr->check);
   14.35 ++		} else {
   14.36 ++			hdr->check = ip_nat_cheat_check(~oldip, newip,
   14.37 + 					ip_nat_cheat_check(*portptr ^ 0xFFFF,
   14.38 + 							   newport,
   14.39 + 							   hdr->check));
   14.40 ++		}
   14.41 ++	}
   14.42 + 	*portptr = newport;
   14.43 + 	return 1;
   14.44 + }
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/patches/linux-2.6.16-rc4/pmd-shared.patch	Tue Feb 21 11:19:13 2006 +0000
    15.3 @@ -0,0 +1,111 @@
    15.4 +diff -pruN ../pristine-linux-2.6.16-rc1-git4/arch/i386/mm/pageattr.c ./arch/i386/mm/pageattr.c
    15.5 +--- ../pristine-linux-2.6.16-rc1-git4/arch/i386/mm/pageattr.c	2006-02-02 17:39:29.000000000 +0000
    15.6 ++++ ./arch/i386/mm/pageattr.c	2006-02-02 17:45:14.000000000 +0000
    15.7 +@@ -78,7 +78,7 @@ static void set_pmd_pte(pte_t *kpte, uns
    15.8 + 	unsigned long flags;
    15.9 + 
   15.10 + 	set_pte_atomic(kpte, pte); 	/* change init_mm */
   15.11 +-	if (PTRS_PER_PMD > 1)
   15.12 ++	if (HAVE_SHARED_KERNEL_PMD)
   15.13 + 		return;
   15.14 + 
   15.15 + 	spin_lock_irqsave(&pgd_lock, flags);
   15.16 +diff -pruN ../pristine-linux-2.6.16-rc1-git4/arch/i386/mm/pgtable.c ./arch/i386/mm/pgtable.c
   15.17 +--- ../pristine-linux-2.6.16-rc1-git4/arch/i386/mm/pgtable.c	2006-01-03 03:21:10.000000000 +0000
   15.18 ++++ ./arch/i386/mm/pgtable.c	2006-02-02 17:45:14.000000000 +0000
   15.19 +@@ -215,9 +215,10 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
   15.20 + 		spin_lock_irqsave(&pgd_lock, flags);
   15.21 + 	}
   15.22 + 
   15.23 +-	clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
   15.24 +-			swapper_pg_dir + USER_PTRS_PER_PGD,
   15.25 +-			KERNEL_PGD_PTRS);
   15.26 ++	if (PTRS_PER_PMD == 1 || HAVE_SHARED_KERNEL_PMD)
   15.27 ++		clone_pgd_range((pgd_t *)pgd + USER_PTRS_PER_PGD,
   15.28 ++				swapper_pg_dir + USER_PTRS_PER_PGD,
   15.29 ++				KERNEL_PGD_PTRS);
   15.30 + 	if (PTRS_PER_PMD > 1)
   15.31 + 		return;
   15.32 + 
   15.33 +@@ -249,6 +250,30 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
   15.34 + 			goto out_oom;
   15.35 + 		set_pgd(&pgd[i], __pgd(1 + __pa(pmd)));
   15.36 + 	}
   15.37 ++
   15.38 ++	if (!HAVE_SHARED_KERNEL_PMD) {
   15.39 ++		unsigned long flags;
   15.40 ++
   15.41 ++		for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   15.42 ++			pmd_t *pmd = kmem_cache_alloc(pmd_cache, GFP_KERNEL);
   15.43 ++			if (!pmd)
   15.44 ++				goto out_oom;
   15.45 ++			set_pgd(&pgd[USER_PTRS_PER_PGD], __pgd(1 + __pa(pmd)));
   15.46 ++		}
   15.47 ++
   15.48 ++		spin_lock_irqsave(&pgd_lock, flags);
   15.49 ++		for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   15.50 ++			unsigned long v = (unsigned long)i << PGDIR_SHIFT;
   15.51 ++			pgd_t *kpgd = pgd_offset_k(v);
   15.52 ++			pud_t *kpud = pud_offset(kpgd, v);
   15.53 ++			pmd_t *kpmd = pmd_offset(kpud, v);
   15.54 ++			pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   15.55 ++			memcpy(pmd, kpmd, PAGE_SIZE);
   15.56 ++		}
   15.57 ++		pgd_list_add(pgd);
   15.58 ++		spin_unlock_irqrestore(&pgd_lock, flags);
   15.59 ++	}
   15.60 ++
   15.61 + 	return pgd;
   15.62 + 
   15.63 + out_oom:
   15.64 +@@ -263,9 +288,23 @@ void pgd_free(pgd_t *pgd)
   15.65 + 	int i;
   15.66 + 
   15.67 + 	/* in the PAE case user pgd entries are overwritten before usage */
   15.68 +-	if (PTRS_PER_PMD > 1)
   15.69 +-		for (i = 0; i < USER_PTRS_PER_PGD; ++i)
   15.70 +-			kmem_cache_free(pmd_cache, (void *)__va(pgd_val(pgd[i])-1));
   15.71 ++	if (PTRS_PER_PMD > 1) {
   15.72 ++		for (i = 0; i < USER_PTRS_PER_PGD; ++i) {
   15.73 ++			pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   15.74 ++			kmem_cache_free(pmd_cache, pmd);
   15.75 ++		}
   15.76 ++		if (!HAVE_SHARED_KERNEL_PMD) {
   15.77 ++			unsigned long flags;
   15.78 ++			spin_lock_irqsave(&pgd_lock, flags);
   15.79 ++			pgd_list_del(pgd);
   15.80 ++			spin_unlock_irqrestore(&pgd_lock, flags);
   15.81 ++			for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
   15.82 ++				pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
   15.83 ++				memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
   15.84 ++				kmem_cache_free(pmd_cache, pmd);
   15.85 ++			}
   15.86 ++		}
   15.87 ++	}
   15.88 + 	/* in the non-PAE case, free_pgtables() clears user pgd entries */
   15.89 + 	kmem_cache_free(pgd_cache, pgd);
   15.90 + }
   15.91 +diff -pruN ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/pgtable-2level-defs.h ./include/asm-i386/pgtable-2level-defs.h
   15.92 +--- ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/pgtable-2level-defs.h	2006-01-03 03:21:10.000000000 +0000
   15.93 ++++ ./include/asm-i386/pgtable-2level-defs.h	2006-02-02 17:45:14.000000000 +0000
   15.94 +@@ -1,6 +1,8 @@
   15.95 + #ifndef _I386_PGTABLE_2LEVEL_DEFS_H
   15.96 + #define _I386_PGTABLE_2LEVEL_DEFS_H
   15.97 + 
   15.98 ++#define HAVE_SHARED_KERNEL_PMD 0
   15.99 ++
  15.100 + /*
  15.101 +  * traditional i386 two-level paging structure:
  15.102 +  */
  15.103 +diff -pruN ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/pgtable-3level-defs.h ./include/asm-i386/pgtable-3level-defs.h
  15.104 +--- ../pristine-linux-2.6.16-rc1-git4/include/asm-i386/pgtable-3level-defs.h	2006-01-03 03:21:10.000000000 +0000
  15.105 ++++ ./include/asm-i386/pgtable-3level-defs.h	2006-02-02 17:45:14.000000000 +0000
  15.106 +@@ -1,6 +1,8 @@
  15.107 + #ifndef _I386_PGTABLE_3LEVEL_DEFS_H
  15.108 + #define _I386_PGTABLE_3LEVEL_DEFS_H
  15.109 + 
  15.110 ++#define HAVE_SHARED_KERNEL_PMD 1
  15.111 ++
  15.112 + /*
  15.113 +  * PGDIR_SHIFT determines what a top-level page table entry can map
  15.114 +  */
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/patches/linux-2.6.16-rc4/smp-alts.patch	Tue Feb 21 11:19:13 2006 +0000
    16.3 @@ -0,0 +1,591 @@
    16.4 +diff -pruN ../pristine-linux-2.6.16-rc3/arch/i386/Kconfig ./arch/i386/Kconfig
    16.5 +--- ../pristine-linux-2.6.16-rc3/arch/i386/Kconfig	2006-02-15 20:38:51.000000000 +0000
    16.6 ++++ ./arch/i386/Kconfig	2006-02-15 20:45:57.000000000 +0000
    16.7 +@@ -202,6 +202,19 @@ config SMP
    16.8 + 
    16.9 + 	  If you don't know what to do here, say N.
   16.10 + 
   16.11 ++config SMP_ALTERNATIVES
   16.12 ++	bool "SMP alternatives support (EXPERIMENTAL)"
   16.13 ++	depends on SMP && EXPERIMENTAL
   16.14 ++	help
   16.15 ++	  Try to reduce the overhead of running an SMP kernel on a uniprocessor
   16.16 ++	  host slightly by replacing certain key instruction sequences
   16.17 ++	  according to whether we currently have more than one CPU available.
   16.18 ++	  This should provide a noticeable boost to performance when
   16.19 ++	  running SMP kernels on UP machines, and have negligible impact
   16.20 ++	  when running on an true SMP host.
   16.21 ++
   16.22 ++          If unsure, say N.
   16.23 ++	  
   16.24 + config NR_CPUS
   16.25 + 	int "Maximum number of CPUs (2-255)"
   16.26 + 	range 2 255
   16.27 +diff -pruN ../pristine-linux-2.6.16-rc3/arch/i386/kernel/Makefile ./arch/i386/kernel/Makefile
   16.28 +--- ../pristine-linux-2.6.16-rc3/arch/i386/kernel/Makefile	2006-02-15 20:38:51.000000000 +0000
   16.29 ++++ ./arch/i386/kernel/Makefile	2006-02-15 20:45:57.000000000 +0000
   16.30 +@@ -37,6 +37,7 @@ obj-$(CONFIG_EFI) 		+= efi.o efi_stub.o
   16.31 + obj-$(CONFIG_DOUBLEFAULT) 	+= doublefault.o
   16.32 + obj-$(CONFIG_VM86)		+= vm86.o
   16.33 + obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
   16.34 ++obj-$(CONFIG_SMP_ALTERNATIVES)  += smpalts.o
   16.35 + 
   16.36 + EXTRA_AFLAGS   := -traditional
   16.37 + 
   16.38 +diff -pruN ../pristine-linux-2.6.16-rc3/arch/i386/kernel/smpalts.c ./arch/i386/kernel/smpalts.c
   16.39 +--- ../pristine-linux-2.6.16-rc3/arch/i386/kernel/smpalts.c	1970-01-01 01:00:00.000000000 +0100
   16.40 ++++ ./arch/i386/kernel/smpalts.c	2006-02-15 20:45:57.000000000 +0000
   16.41 +@@ -0,0 +1,85 @@
   16.42 ++#include <linux/kernel.h>
   16.43 ++#include <asm/system.h>
   16.44 ++#include <asm/smp_alt.h>
   16.45 ++#include <asm/processor.h>
   16.46 ++#include <asm/string.h>
   16.47 ++
   16.48 ++struct smp_replacement_record {
   16.49 ++	unsigned char targ_size;
   16.50 ++	unsigned char smp1_size;
   16.51 ++	unsigned char smp2_size;
   16.52 ++	unsigned char up_size;
   16.53 ++	unsigned char feature;
   16.54 ++	unsigned char data[0];
   16.55 ++};
   16.56 ++
   16.57 ++struct smp_alternative_record {
   16.58 ++	void *targ_start;
   16.59 ++	struct smp_replacement_record *repl;
   16.60 ++};
   16.61 ++
   16.62 ++extern struct smp_alternative_record __start_smp_alternatives_table,
   16.63 ++  __stop_smp_alternatives_table;
   16.64 ++extern unsigned long __init_begin, __init_end;
   16.65 ++
   16.66 ++void prepare_for_smp(void)
   16.67 ++{
   16.68 ++	struct smp_alternative_record *r;
   16.69 ++	printk(KERN_INFO "Enabling SMP...\n");
   16.70 ++	for (r = &__start_smp_alternatives_table;
   16.71 ++	     r != &__stop_smp_alternatives_table;
   16.72 ++	     r++) {
   16.73 ++		BUG_ON(r->repl->targ_size < r->repl->smp1_size);
   16.74 ++		BUG_ON(r->repl->targ_size < r->repl->smp2_size);
   16.75 ++		BUG_ON(r->repl->targ_size < r->repl->up_size);
   16.76 ++               if (system_state == SYSTEM_RUNNING &&
   16.77 ++                   r->targ_start >= (void *)&__init_begin &&
   16.78 ++                   r->targ_start < (void *)&__init_end)
   16.79 ++                       continue;
   16.80 ++		if (r->repl->feature != (unsigned char)-1 &&
   16.81 ++		    boot_cpu_has(r->repl->feature)) {
   16.82 ++			memcpy(r->targ_start,
   16.83 ++			       r->repl->data + r->repl->smp1_size,
   16.84 ++			       r->repl->smp2_size);
   16.85 ++			memset(r->targ_start + r->repl->smp2_size,
   16.86 ++			       0x90,
   16.87 ++			       r->repl->targ_size - r->repl->smp2_size);
   16.88 ++		} else {
   16.89 ++			memcpy(r->targ_start,
   16.90 ++			       r->repl->data,
   16.91 ++			       r->repl->smp1_size);
   16.92 ++			memset(r->targ_start + r->repl->smp1_size,
   16.93 ++			       0x90,
   16.94 ++			       r->repl->targ_size - r->repl->smp1_size);
   16.95 ++		}
   16.96 ++	}
   16.97 ++	/* Paranoia */
   16.98 ++	asm volatile ("jmp 1f\n1:");
   16.99 ++	mb();
  16.100 ++}
  16.101 ++
  16.102 ++void unprepare_for_smp(void)
  16.103 ++{
  16.104 ++	struct smp_alternative_record *r;
  16.105 ++	printk(KERN_INFO "Disabling SMP...\n");
  16.106 ++	for (r = &__start_smp_alternatives_table;
  16.107 ++	     r != &__stop_smp_alternatives_table;
  16.108 ++	     r++) {
  16.109 ++		BUG_ON(r->repl->targ_size < r->repl->smp1_size);
  16.110 ++		BUG_ON(r->repl->targ_size < r->repl->smp2_size);
  16.111 ++		BUG_ON(r->repl->targ_size < r->repl->up_size);
  16.112 ++               if (system_state == SYSTEM_RUNNING &&
  16.113 ++                   r->targ_start >= (void *)&__init_begin &&
  16.114 ++                   r->targ_start < (void *)&__init_end)
  16.115 ++                       continue;
  16.116 ++		memcpy(r->targ_start,
  16.117 ++		       r->repl->data + r->repl->smp1_size + r->repl->smp2_size,
  16.118 ++		       r->repl->up_size);
  16.119 ++		memset(r->targ_start + r->repl->up_size,
  16.120 ++		       0x90,
  16.121 ++		       r->repl->targ_size - r->repl->up_size);
  16.122 ++	}
  16.123 ++	/* Paranoia */
  16.124 ++	asm volatile ("jmp 1f\n1:");
  16.125 ++	mb();
  16.126 ++}
  16.127 +diff -pruN ../pristine-linux-2.6.16-rc3/arch/i386/kernel/smpboot.c ./arch/i386/kernel/smpboot.c
  16.128 +--- ../pristine-linux-2.6.16-rc3/arch/i386/kernel/smpboot.c	2006-02-15 20:38:51.000000000 +0000
  16.129 ++++ ./arch/i386/kernel/smpboot.c	2006-02-15 20:45:57.000000000 +0000
  16.130 +@@ -1214,6 +1214,11 @@ static void __init smp_boot_cpus(unsigne
  16.131 + 		if (max_cpus <= cpucount+1)
  16.132 + 			continue;
  16.133 + 
  16.134 ++#ifdef CONFIG_SMP_ALTERNATIVES
  16.135 ++		if (kicked == 1)
  16.136 ++			prepare_for_smp();
  16.137 ++#endif
  16.138 ++
  16.139 + 		if (((cpu = alloc_cpu_id()) <= 0) || do_boot_cpu(apicid, cpu))
  16.140 + 			printk("CPU #%d not responding - cannot use it.\n",
  16.141 + 								apicid);
  16.142 +@@ -1392,6 +1397,11 @@ int __devinit __cpu_up(unsigned int cpu)
  16.143 + 		return -EIO;
  16.144 + 	}
  16.145 + 
  16.146 ++#ifdef CONFIG_SMP_ALTERNATIVES
  16.147 ++	if (num_online_cpus() == 1)
  16.148 ++		prepare_for_smp();
  16.149 ++#endif
  16.150 ++
  16.151 + 	local_irq_enable();
  16.152 + 	per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
  16.153 + 	/* Unleash the CPU! */
  16.154 +diff -pruN ../pristine-linux-2.6.16-rc3/arch/i386/kernel/vmlinux.lds.S ./arch/i386/kernel/vmlinux.lds.S
  16.155 +--- ../pristine-linux-2.6.16-rc3/arch/i386/kernel/vmlinux.lds.S	2006-01-03 03:21:10.000000000 +0000
  16.156 ++++ ./arch/i386/kernel/vmlinux.lds.S	2006-02-15 20:45:57.000000000 +0000
  16.157 +@@ -34,6 +34,13 @@ SECTIONS
  16.158 +   __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) }
  16.159 +   __stop___ex_table = .;
  16.160 + 
  16.161 ++  . = ALIGN(16);
  16.162 ++  __start_smp_alternatives_table = .;
  16.163 ++  __smp_alternatives : { *(__smp_alternatives) }
  16.164 ++  __stop_smp_alternatives_table = .;
  16.165 ++
  16.166 ++  __smp_replacements : { *(__smp_replacements) }
  16.167 ++
  16.168 +   RODATA
  16.169 + 
  16.170 +   /* writeable */
  16.171 +diff -pruN ../pristine-linux-2.6.16-rc3/include/asm-i386/atomic.h ./include/asm-i386/atomic.h
  16.172 +--- ../pristine-linux-2.6.16-rc3/include/asm-i386/atomic.h	2006-02-15 20:38:57.000000000 +0000
  16.173 ++++ ./include/asm-i386/atomic.h	2006-02-15 20:45:57.000000000 +0000
  16.174 +@@ -4,18 +4,13 @@
  16.175 + #include <linux/config.h>
  16.176 + #include <linux/compiler.h>
  16.177 + #include <asm/processor.h>
  16.178 ++#include <asm/smp_alt.h>
  16.179 + 
  16.180 + /*
  16.181 +  * Atomic operations that C can't guarantee us.  Useful for
  16.182 +  * resource counting etc..
  16.183 +  */
  16.184 + 
  16.185 +-#ifdef CONFIG_SMP
  16.186 +-#define LOCK "lock ; "
  16.187 +-#else
  16.188 +-#define LOCK ""
  16.189 +-#endif
  16.190 +-
  16.191 + /*
  16.192 +  * Make sure gcc doesn't try to be clever and move things around
  16.193 +  * on us. We need to use _exactly_ the address the user gave us,
  16.194 +diff -pruN ../pristine-linux-2.6.16-rc3/include/asm-i386/bitops.h ./include/asm-i386/bitops.h
  16.195 +--- ../pristine-linux-2.6.16-rc3/include/asm-i386/bitops.h	2006-02-15 20:38:57.000000000 +0000
  16.196 ++++ ./include/asm-i386/bitops.h	2006-02-15 20:45:57.000000000 +0000
  16.197 +@@ -7,6 +7,7 @@
  16.198 + 
  16.199 + #include <linux/config.h>
  16.200 + #include <linux/compiler.h>
  16.201 ++#include <asm/smp_alt.h>
  16.202 + 
  16.203 + /*
  16.204 +  * These have to be done with inline assembly: that way the bit-setting
  16.205 +@@ -16,12 +17,6 @@
  16.206 +  * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
  16.207 +  */
  16.208 + 
  16.209 +-#ifdef CONFIG_SMP
  16.210 +-#define LOCK_PREFIX "lock ; "
  16.211 +-#else
  16.212 +-#define LOCK_PREFIX ""
  16.213 +-#endif
  16.214 +-
  16.215 + #define ADDR (*(volatile long *) addr)
  16.216 + 
  16.217 + /**
  16.218 +@@ -41,7 +36,7 @@
  16.219 +  */
  16.220 + static inline void set_bit(int nr, volatile unsigned long * addr)
  16.221 + {
  16.222 +-	__asm__ __volatile__( LOCK_PREFIX
  16.223 ++	__asm__ __volatile__( LOCK
  16.224 + 		"btsl %1,%0"
  16.225 + 		:"+m" (ADDR)
  16.226 + 		:"Ir" (nr));
  16.227 +@@ -76,7 +71,7 @@ static inline void __set_bit(int nr, vol
  16.228 +  */
  16.229 + static inline void clear_bit(int nr, volatile unsigned long * addr)
  16.230 + {
  16.231 +-	__asm__ __volatile__( LOCK_PREFIX
  16.232 ++	__asm__ __volatile__( LOCK
  16.233 + 		"btrl %1,%0"
  16.234 + 		:"+m" (ADDR)
  16.235 + 		:"Ir" (nr));
  16.236 +@@ -121,7 +116,7 @@ static inline void __change_bit(int nr, 
  16.237 +  */
  16.238 + static inline void change_bit(int nr, volatile unsigned long * addr)
  16.239 + {
  16.240 +-	__asm__ __volatile__( LOCK_PREFIX
  16.241 ++	__asm__ __volatile__( LOCK
  16.242 + 		"btcl %1,%0"
  16.243 + 		:"+m" (ADDR)
  16.244 + 		:"Ir" (nr));
  16.245 +@@ -140,7 +135,7 @@ static inline int test_and_set_bit(int n
  16.246 + {
  16.247 + 	int oldbit;
  16.248 + 
  16.249 +-	__asm__ __volatile__( LOCK_PREFIX
  16.250 ++	__asm__ __volatile__( LOCK
  16.251 + 		"btsl %2,%1\n\tsbbl %0,%0"
  16.252 + 		:"=r" (oldbit),"+m" (ADDR)
  16.253 + 		:"Ir" (nr) : "memory");
  16.254 +@@ -180,7 +175,7 @@ static inline int test_and_clear_bit(int
  16.255 + {
  16.256 + 	int oldbit;
  16.257 + 
  16.258 +-	__asm__ __volatile__( LOCK_PREFIX
  16.259 ++	__asm__ __volatile__( LOCK
  16.260 + 		"btrl %2,%1\n\tsbbl %0,%0"
  16.261 + 		:"=r" (oldbit),"+m" (ADDR)
  16.262 + 		:"Ir" (nr) : "memory");
  16.263 +@@ -231,7 +226,7 @@ static inline int test_and_change_bit(in
  16.264 + {
  16.265 + 	int oldbit;
  16.266 + 
  16.267 +-	__asm__ __volatile__( LOCK_PREFIX
  16.268 ++	__asm__ __volatile__( LOCK
  16.269 + 		"btcl %2,%1\n\tsbbl %0,%0"
  16.270 + 		:"=r" (oldbit),"+m" (ADDR)
  16.271 + 		:"Ir" (nr) : "memory");
  16.272 +diff -pruN ../pristine-linux-2.6.16-rc3/include/asm-i386/futex.h ./include/asm-i386/futex.h
  16.273 +--- ../pristine-linux-2.6.16-rc3/include/asm-i386/futex.h	2006-02-15 20:38:57.000000000 +0000
  16.274 ++++ ./include/asm-i386/futex.h	2006-02-15 20:45:57.000000000 +0000
  16.275 +@@ -28,7 +28,7 @@
  16.276 + "1:	movl	%2, %0\n\
  16.277 + 	movl	%0, %3\n"					\
  16.278 + 	insn "\n"						\
  16.279 +-"2:	" LOCK_PREFIX "cmpxchgl %3, %2\n\
  16.280 ++"2:	" LOCK "cmpxchgl %3, %2\n\
  16.281 + 	jnz	1b\n\
  16.282 + 3:	.section .fixup,\"ax\"\n\
  16.283 + 4:	mov	%5, %1\n\
  16.284 +@@ -68,7 +68,7 @@ futex_atomic_op_inuser (int encoded_op, 
  16.285 + #endif
  16.286 + 		switch (op) {
  16.287 + 		case FUTEX_OP_ADD:
  16.288 +-			__futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret,
  16.289 ++			__futex_atomic_op1(LOCK "xaddl %0, %2", ret,
  16.290 + 					   oldval, uaddr, oparg);
  16.291 + 			break;
  16.292 + 		case FUTEX_OP_OR:
  16.293 +diff -pruN ../pristine-linux-2.6.16-rc3/include/asm-i386/rwsem.h ./include/asm-i386/rwsem.h
  16.294 +--- ../pristine-linux-2.6.16-rc3/include/asm-i386/rwsem.h	2006-01-03 03:21:10.000000000 +0000
  16.295 ++++ ./include/asm-i386/rwsem.h	2006-02-15 20:45:57.000000000 +0000
  16.296 +@@ -40,6 +40,7 @@
  16.297 + 
  16.298 + #include <linux/list.h>
  16.299 + #include <linux/spinlock.h>
  16.300 ++#include <asm/smp_alt.h>
  16.301 + 
  16.302 + struct rwsem_waiter;
  16.303 + 
  16.304 +@@ -99,7 +100,7 @@ static inline void __down_read(struct rw
  16.305 + {
  16.306 + 	__asm__ __volatile__(
  16.307 + 		"# beginning down_read\n\t"
  16.308 +-LOCK_PREFIX	"  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old value */
  16.309 ++LOCK	        "  incl      (%%eax)\n\t" /* adds 0x00000001, returns the old value */
  16.310 + 		"  js        2f\n\t" /* jump if we weren't granted the lock */
  16.311 + 		"1:\n\t"
  16.312 + 		LOCK_SECTION_START("")
  16.313 +@@ -130,7 +131,7 @@ static inline int __down_read_trylock(st
  16.314 + 		"  movl	     %1,%2\n\t"
  16.315 + 		"  addl      %3,%2\n\t"
  16.316 + 		"  jle	     2f\n\t"
  16.317 +-LOCK_PREFIX	"  cmpxchgl  %2,%0\n\t"
  16.318 ++LOCK	        "  cmpxchgl  %2,%0\n\t"
  16.319 + 		"  jnz	     1b\n\t"
  16.320 + 		"2:\n\t"
  16.321 + 		"# ending __down_read_trylock\n\t"
  16.322 +@@ -150,7 +151,7 @@ static inline void __down_write(struct r
  16.323 + 	tmp = RWSEM_ACTIVE_WRITE_BIAS;
  16.324 + 	__asm__ __volatile__(
  16.325 + 		"# beginning down_write\n\t"
  16.326 +-LOCK_PREFIX	"  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
  16.327 ++LOCK	        "  xadd      %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
  16.328 + 		"  testl     %%edx,%%edx\n\t" /* was the count 0 before? */
  16.329 + 		"  jnz       2f\n\t" /* jump if we weren't granted the lock */
  16.330 + 		"1:\n\t"
  16.331 +@@ -188,7 +189,7 @@ static inline void __up_read(struct rw_s
  16.332 + 	__s32 tmp = -RWSEM_ACTIVE_READ_BIAS;
  16.333 + 	__asm__ __volatile__(
  16.334 + 		"# beginning __up_read\n\t"
  16.335 +-LOCK_PREFIX	"  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
  16.336 ++LOCK	        "  xadd      %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
  16.337 + 		"  js        2f\n\t" /* jump if the lock is being waited upon */
  16.338 + 		"1:\n\t"
  16.339 + 		LOCK_SECTION_START("")
  16.340 +@@ -214,7 +215,7 @@ static inline void __up_write(struct rw_
  16.341 + 	__asm__ __volatile__(
  16.342 + 		"# beginning __up_write\n\t"
  16.343 + 		"  movl      %2,%%edx\n\t"
  16.344 +-LOCK_PREFIX	"  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
  16.345 ++LOCK	        "  xaddl     %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
  16.346 + 		"  jnz       2f\n\t" /* jump if the lock is being waited upon */
  16.347 + 		"1:\n\t"
  16.348 + 		LOCK_SECTION_START("")
  16.349 +@@ -239,7 +240,7 @@ static inline void __downgrade_write(str
  16.350 + {
  16.351 + 	__asm__ __volatile__(
  16.352 + 		"# beginning __downgrade_write\n\t"
  16.353 +-LOCK_PREFIX	"  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
  16.354 ++LOCK	        "  addl      %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
  16.355 + 		"  js        2f\n\t" /* jump if the lock is being waited upon */
  16.356 + 		"1:\n\t"
  16.357 + 		LOCK_SECTION_START("")
  16.358 +@@ -263,7 +264,7 @@ LOCK_PREFIX	"  addl      %2,(%%eax)\n\t"
  16.359 + static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem)
  16.360 + {
  16.361 + 	__asm__ __volatile__(
  16.362 +-LOCK_PREFIX	"addl %1,%0"
  16.363 ++LOCK	          "addl %1,%0"
  16.364 + 		: "=m"(sem->count)
  16.365 + 		: "ir"(delta), "m"(sem->count));
  16.366 + }
  16.367 +@@ -276,7 +277,7 @@ static inline int rwsem_atomic_update(in
  16.368 + 	int tmp = delta;
  16.369 + 
  16.370 + 	__asm__ __volatile__(
  16.371 +-LOCK_PREFIX	"xadd %0,(%2)"
  16.372 ++LOCK  	          "xadd %0,(%2)"
  16.373 + 		: "+r"(tmp), "=m"(sem->count)
  16.374 + 		: "r"(sem), "m"(sem->count)
  16.375 + 		: "memory");
  16.376 +diff -pruN ../pristine-linux-2.6.16-rc3/include/asm-i386/smp_alt.h ./include/asm-i386/smp_alt.h
  16.377 +--- ../pristine-linux-2.6.16-rc3/include/asm-i386/smp_alt.h	1970-01-01 01:00:00.000000000 +0100
  16.378 ++++ ./include/asm-i386/smp_alt.h	2006-02-15 20:45:57.000000000 +0000
  16.379 +@@ -0,0 +1,32 @@
  16.380 ++#ifndef __ASM_SMP_ALT_H__
  16.381 ++#define __ASM_SMP_ALT_H__
  16.382 ++
  16.383 ++#include <linux/config.h>
  16.384 ++
  16.385 ++#ifdef CONFIG_SMP
  16.386 ++#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
  16.387 ++#define LOCK \
  16.388 ++        "6677: nop\n" \
  16.389 ++	".section __smp_alternatives,\"a\"\n" \
  16.390 ++	".long 6677b\n" \
  16.391 ++	".long 6678f\n" \
  16.392 ++	".previous\n" \
  16.393 ++	".section __smp_replacements,\"a\"\n" \
  16.394 ++	"6678: .byte 1\n" \
  16.395 ++	".byte 1\n" \
  16.396 ++	".byte 0\n" \
  16.397 ++        ".byte 1\n" \
  16.398 ++	".byte -1\n" \
  16.399 ++	"lock\n" \
  16.400 ++	"nop\n" \
  16.401 ++	".previous\n"
  16.402 ++void prepare_for_smp(void);
  16.403 ++void unprepare_for_smp(void);
  16.404 ++#else
  16.405 ++#define LOCK "lock ; "
  16.406 ++#endif
  16.407 ++#else
  16.408 ++#define LOCK ""
  16.409 ++#endif
  16.410 ++
  16.411 ++#endif /* __ASM_SMP_ALT_H__ */
  16.412 +diff -pruN ../pristine-linux-2.6.16-rc3/include/asm-i386/spinlock.h ./include/asm-i386/spinlock.h
  16.413 +--- ../pristine-linux-2.6.16-rc3/include/asm-i386/spinlock.h	2006-01-03 03:21:10.000000000 +0000
  16.414 ++++ ./include/asm-i386/spinlock.h	2006-02-15 20:45:57.000000000 +0000
  16.415 +@@ -6,6 +6,7 @@
  16.416 + #include <asm/page.h>
  16.417 + #include <linux/config.h>
  16.418 + #include <linux/compiler.h>
  16.419 ++#include <asm/smp_alt.h>
  16.420 + 
  16.421 + /*
  16.422 +  * Your basic SMP spinlocks, allowing only a single CPU anywhere
  16.423 +@@ -23,7 +24,8 @@
  16.424 + 
  16.425 + #define __raw_spin_lock_string \
  16.426 + 	"\n1:\t" \
  16.427 +-	"lock ; decb %0\n\t" \
  16.428 ++	LOCK \
  16.429 ++	"decb %0\n\t" \
  16.430 + 	"jns 3f\n" \
  16.431 + 	"2:\t" \
  16.432 + 	"rep;nop\n\t" \
  16.433 +@@ -34,7 +36,8 @@
  16.434 + 
  16.435 + #define __raw_spin_lock_string_flags \
  16.436 + 	"\n1:\t" \
  16.437 +-	"lock ; decb %0\n\t" \
  16.438 ++	LOCK \
  16.439 ++	"decb %0\n\t" \
  16.440 + 	"jns 4f\n\t" \
  16.441 + 	"2:\t" \
  16.442 + 	"testl $0x200, %1\n\t" \
  16.443 +@@ -65,10 +68,34 @@ static inline void __raw_spin_lock_flags
  16.444 + static inline int __raw_spin_trylock(raw_spinlock_t *lock)
  16.445 + {
  16.446 + 	char oldval;
  16.447 ++#ifdef CONFIG_SMP_ALTERNATIVES
  16.448 + 	__asm__ __volatile__(
  16.449 +-		"xchgb %b0,%1"
  16.450 ++		"1:movb %1,%b0\n"
  16.451 ++		"movb $0,%1\n"
  16.452 ++		"2:"
  16.453 ++		".section __smp_alternatives,\"a\"\n"
  16.454 ++		".long 1b\n"
  16.455 ++		".long 3f\n"
  16.456 ++		".previous\n"
  16.457 ++		".section __smp_replacements,\"a\"\n"
  16.458 ++		"3: .byte 2b - 1b\n"
  16.459 ++		".byte 5f-4f\n"
  16.460 ++		".byte 0\n"
  16.461 ++		".byte 6f-5f\n"
  16.462 ++		".byte -1\n"
  16.463 ++		"4: xchgb %b0,%1\n"
  16.464 ++		"5: movb %1,%b0\n"
  16.465 ++		"movb $0,%1\n"
  16.466 ++		"6:\n"
  16.467 ++		".previous\n"
  16.468 + 		:"=q" (oldval), "=m" (lock->slock)
  16.469 + 		:"0" (0) : "memory");
  16.470 ++#else
  16.471 ++	__asm__ __volatile__(
  16.472 ++		"xchgb %b0,%1\n"
  16.473 ++		:"=q" (oldval), "=m" (lock->slock)
  16.474 ++		:"0" (0) : "memory");
  16.475 ++#endif
  16.476 + 	return oldval > 0;
  16.477 + }
  16.478 + 
  16.479 +@@ -178,12 +205,12 @@ static inline int __raw_write_trylock(ra
  16.480 + 
  16.481 + static inline void __raw_read_unlock(raw_rwlock_t *rw)
  16.482 + {
  16.483 +-	asm volatile("lock ; incl %0" :"=m" (rw->lock) : : "memory");
  16.484 ++	asm volatile(LOCK "incl %0" :"=m" (rw->lock) : : "memory");
  16.485 + }
  16.486 + 
  16.487 + static inline void __raw_write_unlock(raw_rwlock_t *rw)
  16.488 + {
  16.489 +-	asm volatile("lock ; addl $" RW_LOCK_BIAS_STR ", %0"
  16.490 ++	asm volatile(LOCK "addl $" RW_LOCK_BIAS_STR ", %0"
  16.491 + 				 : "=m" (rw->lock) : : "memory");
  16.492 + }
  16.493 + 
  16.494 +diff -pruN ../pristine-linux-2.6.16-rc3/include/asm-i386/system.h ./include/asm-i386/system.h
  16.495 +--- ../pristine-linux-2.6.16-rc3/include/asm-i386/system.h	2006-02-15 20:38:57.000000000 +0000
  16.496 ++++ ./include/asm-i386/system.h	2006-02-15 20:45:57.000000000 +0000
  16.497 +@@ -5,7 +5,7 @@
  16.498 + #include <linux/kernel.h>
  16.499 + #include <asm/segment.h>
  16.500 + #include <asm/cpufeature.h>
  16.501 +-#include <linux/bitops.h> /* for LOCK_PREFIX */
  16.502 ++#include <asm/smp_alt.h>
  16.503 + 
  16.504 + #ifdef __KERNEL__
  16.505 + 
  16.506 +@@ -271,19 +271,19 @@ static inline unsigned long __cmpxchg(vo
  16.507 + 	unsigned long prev;
  16.508 + 	switch (size) {
  16.509 + 	case 1:
  16.510 +-		__asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
  16.511 ++		__asm__ __volatile__(LOCK "cmpxchgb %b1,%2"
  16.512 + 				     : "=a"(prev)
  16.513 + 				     : "q"(new), "m"(*__xg(ptr)), "0"(old)
  16.514 + 				     : "memory");
  16.515 + 		return prev;
  16.516 + 	case 2:
  16.517 +-		__asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
  16.518 ++		__asm__ __volatile__(LOCK "cmpxchgw %w1,%2"
  16.519 + 				     : "=a"(prev)
  16.520 + 				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
  16.521 + 				     : "memory");
  16.522 + 		return prev;
  16.523 + 	case 4:
  16.524 +-		__asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
  16.525 ++		__asm__ __volatile__(LOCK "cmpxchgl %1,%2"
  16.526 + 				     : "=a"(prev)
  16.527 + 				     : "r"(new), "m"(*__xg(ptr)), "0"(old)
  16.528 + 				     : "memory");
  16.529 +@@ -336,7 +336,7 @@ static inline unsigned long long __cmpxc
  16.530 + 				      unsigned long long new)
  16.531 + {
  16.532 + 	unsigned long long prev;
  16.533 +-	__asm__ __volatile__(LOCK_PREFIX "cmpxchg8b %3"
  16.534 ++	__asm__ __volatile__(LOCK "cmpxchg8b %3"
  16.535 + 			     : "=A"(prev)
  16.536 + 			     : "b"((unsigned long)new),
  16.537 + 			       "c"((unsigned long)(new >> 32)),
  16.538 +@@ -503,11 +503,55 @@ struct alt_instr { 
  16.539 + #endif
  16.540 + 
  16.541 + #ifdef CONFIG_SMP
  16.542 ++#if defined(CONFIG_SMP_ALTERNATIVES) && !defined(MODULE)
  16.543 ++#define smp_alt_mb(instr)                                           \
  16.544 ++__asm__ __volatile__("6667:\nnop\nnop\nnop\nnop\nnop\nnop\n6668:\n" \
  16.545 ++		     ".section __smp_alternatives,\"a\"\n"          \
  16.546 ++		     ".long 6667b\n"                                \
  16.547 ++                     ".long 6673f\n"                                \
  16.548 ++		     ".previous\n"                                  \
  16.549 ++		     ".section __smp_replacements,\"a\"\n"          \
  16.550 ++		     "6673:.byte 6668b-6667b\n"                     \
  16.551 ++		     ".byte 6670f-6669f\n"                          \
  16.552 ++		     ".byte 6671f-6670f\n"                          \
  16.553 ++                     ".byte 0\n"                                    \
  16.554 ++		     ".byte %c0\n"                                  \
  16.555 ++		     "6669:lock;addl $0,0(%%esp)\n"                 \
  16.556 ++		     "6670:" instr "\n"                             \
  16.557 ++		     "6671:\n"                                      \
  16.558 ++		     ".previous\n"                                  \
  16.559 ++		     :                                              \
  16.560 ++		     : "i" (X86_FEATURE_XMM2)                       \
  16.561 ++		     : "memory")
  16.562 ++#define smp_rmb() smp_alt_mb("lfence")
  16.563 ++#define smp_mb()  smp_alt_mb("mfence")
  16.564 ++#define set_mb(var, value) do {                                     \
  16.565 ++unsigned long __set_mb_temp;                                        \
  16.566 ++__asm__ __volatile__("6667:movl %1, %0\n6668:\n"                    \
  16.567 ++		     ".section __smp_alternatives,\"a\"\n"          \
  16.568 ++		     ".long 6667b\n"                                \
  16.569 ++		     ".long 6673f\n"                                \
  16.570 ++		     ".previous\n"                                  \
  16.571 ++		     ".section __smp_replacements,\"a\"\n"          \
  16.572 ++		     "6673: .byte 6668b-6667b\n"                    \
  16.573 ++		     ".byte 6670f-6669f\n"                          \
  16.574 ++		     ".byte 0\n"                                    \
  16.575 ++		     ".byte 6671f-6670f\n"                          \
  16.576 ++		     ".byte -1\n"                                   \
  16.577 ++		     "6669: xchg %1, %0\n"                          \
  16.578 ++		     "6670:movl %1, %0\n"                           \
  16.579 ++		     "6671:\n"                                      \
  16.580 ++		     ".previous\n"                                  \
  16.581 ++		     : "=m" (var), "=r" (__set_mb_temp)             \
  16.582 ++		     : "1" (value)                                  \
  16.583 ++		     : "memory"); } while (0)
  16.584 ++#else
  16.585 + #define smp_mb()	mb()
  16.586 + #define smp_rmb()	rmb()
  16.587 ++#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
  16.588 ++#endif
  16.589 + #define smp_wmb()	wmb()
  16.590 + #define smp_read_barrier_depends()	read_barrier_depends()
  16.591 +-#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
  16.592 + #else
  16.593 + #define smp_mb()	barrier()
  16.594 + #define smp_rmb()	barrier()