--- /dev/null
+From 85df3b3769222894e9692b383c7af124b7721086 Mon Sep 17 00:00:00 2001
+From: Vinson Lee <vlee@twitter.com>
+Date: Wed, 13 Feb 2013 13:48:58 -0800
+Subject: perf tools: Fix build with bison 2.3 and older.
+
+From: Vinson Lee <vlee@twitter.com>
+
+commit 85df3b3769222894e9692b383c7af124b7721086 upstream.
+
+The %name-prefix "prefix" syntax is not available on bison 2.3 and
+older. Substitute with the -p "prefix" command-line option for
+compatibility with older versions of bison.
+
+This patch fixes this build error with older versions of bison.
+
+ CC util/sysfs.o
+ BISON util/pmu-bison.c
+util/pmu.y:2.14-24: syntax error, unexpected string, expecting =
+make: *** [util/pmu-bison.c] Error 1
+
+Signed-off-by: Vinson Lee <vlee@twitter.com>
+Tested-by: Li Zefan <lizefan@huawei.com>
+Cc: Ingo Molnar <mingo@redhat.com>
+Cc: Jiri Olsa <jolsa@redhat.com>
+Cc: Li Zefan <lizefan@huawei.com>
+Cc: Namhyung Kim <namhyung@gmail.com>
+Cc: Paul Mackerras <paulus@samba.org>
+Cc: Pekka Enberg <penberg@kernel.org>
+Link: http://lkml.kernel.org/r/1360792138-29186-1-git-send-email-vlee@twitter.com
+Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ tools/perf/Makefile | 4 ++--
+ tools/perf/util/parse-events.y | 1 -
+ tools/perf/util/pmu.y | 1 -
+ 3 files changed, 2 insertions(+), 4 deletions(-)
+
+--- a/tools/perf/Makefile
++++ b/tools/perf/Makefile
+@@ -276,13 +276,13 @@ $(OUTPUT)util/parse-events-flex.c: util/
+ $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/parse-events-flex.h $(PARSER_DEBUG_FLEX) -t util/parse-events.l > $(OUTPUT)util/parse-events-flex.c
+
+ $(OUTPUT)util/parse-events-bison.c: util/parse-events.y
+- $(QUIET_BISON)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) -o $(OUTPUT)util/parse-events-bison.c
++ $(QUIET_BISON)$(BISON) -v util/parse-events.y -d $(PARSER_DEBUG_BISON) -o $(OUTPUT)util/parse-events-bison.c -p parse_events_
+
+ $(OUTPUT)util/pmu-flex.c: util/pmu.l $(OUTPUT)util/pmu-bison.c
+ $(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/pmu-flex.h -t util/pmu.l > $(OUTPUT)util/pmu-flex.c
+
+ $(OUTPUT)util/pmu-bison.c: util/pmu.y
+- $(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c
++ $(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c -p perf_pmu_
+
+ $(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c
+ $(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c
+--- a/tools/perf/util/parse-events.y
++++ b/tools/perf/util/parse-events.y
+@@ -1,5 +1,4 @@
+ %pure-parser
+-%name-prefix "parse_events_"
+ %parse-param {void *_data}
+ %parse-param {void *scanner}
+ %lex-param {void* scanner}
+--- a/tools/perf/util/pmu.y
++++ b/tools/perf/util/pmu.y
+@@ -1,5 +1,4 @@
+
+-%name-prefix "perf_pmu_"
+ %parse-param {struct list_head *format}
+ %parse-param {char *name}
+
--- /dev/null
+From 07f4207a305c834f528d08428df4531744e25678 Mon Sep 17 00:00:00 2001
+From: "H. Peter Anvin" <hpa@linux.intel.com>
+Date: Thu, 31 Jan 2013 14:00:48 -0800
+Subject: x86-32, mm: Remove reference to alloc_remap()
+
+From: "H. Peter Anvin" <hpa@linux.intel.com>
+
+commit 07f4207a305c834f528d08428df4531744e25678 upstream.
+
+We have removed the remap allocator for x86-32, and x86-64 never had
+it (and doesn't need it). Remove residual reference to it.
+
+Reported-by: Yinghai Lu <yinghai@kernel.org>
+Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
+Cc: Dave Hansen <dave@linux.vnet.ibm.com>
+Link: http://lkml.kernel.org/r/CAE9FiQVn6_QZi3fNQ-JHYiR-7jeDJ5hT0SyT_%2BzVvfOj=PzF3w@mail.gmail.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/mm/numa.c | 29 +++++++++++------------------
+ 1 file changed, 11 insertions(+), 18 deletions(-)
+
+--- a/arch/x86/mm/numa.c
++++ b/arch/x86/mm/numa.c
+@@ -193,7 +193,6 @@ int __init numa_add_memblk(int nid, u64
+ static void __init setup_node_data(int nid, u64 start, u64 end)
+ {
+ const size_t nd_size = roundup(sizeof(pg_data_t), PAGE_SIZE);
+- bool remapped = false;
+ u64 nd_pa;
+ void *nd;
+ int tnid;
+@@ -211,28 +210,22 @@ static void __init setup_node_data(int n
+ nid, start, end - 1);
+
+ /*
+- * Allocate node data. Try remap allocator first, node-local
+- * memory and then any node. Never allocate in DMA zone.
++ * Allocate node data. Try node-local memory and then any node.
++ * Never allocate in DMA zone.
+ */
+- nd = alloc_remap(nid, nd_size);
+- if (nd) {
+- nd_pa = __pa(nd);
+- remapped = true;
+- } else {
+- nd_pa = memblock_alloc_nid(nd_size, SMP_CACHE_BYTES, nid);
+- if (!nd_pa) {
+- pr_err("Cannot find %zu bytes in node %d\n",
+- nd_size, nid);
+- return;
+- }
+- nd = __va(nd_pa);
++ nd_pa = memblock_alloc_nid(nd_size, SMP_CACHE_BYTES, nid);
++ if (!nd_pa) {
++ pr_err("Cannot find %zu bytes in node %d\n",
++ nd_size, nid);
++ return;
+ }
++ nd = __va(nd_pa);
+
+ /* report and initialize */
+- printk(KERN_INFO " NODE_DATA [mem %#010Lx-%#010Lx]%s\n",
+- nd_pa, nd_pa + nd_size - 1, remapped ? " (remapped)" : "");
++ printk(KERN_INFO " NODE_DATA [mem %#010Lx-%#010Lx]\n",
++ nd_pa, nd_pa + nd_size - 1);
+ tnid = early_pfn_to_nid(nd_pa >> PAGE_SHIFT);
+- if (!remapped && tnid != nid)
++ if (tnid != nid)
+ printk(KERN_INFO " NODE_DATA(%d) on node %d\n", nid, tnid);
+
+ node_data[nid] = nd;
--- /dev/null
+From f03574f2d5b2d6229dcdf2d322848065f72953c7 Mon Sep 17 00:00:00 2001
+From: Dave Hansen <dave@linux.vnet.ibm.com>
+Date: Wed, 30 Jan 2013 16:56:16 -0800
+Subject: x86-32, mm: Rip out x86_32 NUMA remapping code
+
+From: Dave Hansen <dave@linux.vnet.ibm.com>
+
+commit f03574f2d5b2d6229dcdf2d322848065f72953c7 upstream.
+
+This code was an optimization for 32-bit NUMA systems.
+
+It has probably been the cause of a number of subtle bugs over
+the years, although the conditions to excite them would have
+been hard to trigger. Essentially, we remap part of the kernel
+linear mapping area, and then sometimes part of that area gets
+freed back in to the bootmem allocator. If those pages get
+used by kernel data structures (say mem_map[] or a dentry),
+there's no big deal. But, if anyone ever tried to use the
+linear mapping for these pages _and_ cared about their physical
+address, bad things happen.
+
+For instance, say you passed __GFP_ZERO to the page allocator
+and then happened to get handed one of these pages, it zero the
+remapped page, but it would make a pte to the _old_ page.
+There are probably a hundred other ways that it could screw
+with things.
+
+We don't need to hang on to performance optimizations for
+these old boxes any more. All my 32-bit NUMA systems are long
+dead and buried, and I probably had access to more than most
+people.
+
+This code is causing real things to break today:
+
+ https://lkml.org/lkml/2013/1/9/376
+
+I looked in to actually fixing this, but it requires surgery
+to way too much brittle code, as well as stuff like
+per_cpu_ptr_to_phys().
+
+[ hpa: Cc: this for -stable, since it is a memory corruption issue.
+ However, an alternative is to simply mark NUMA as depends BROKEN
+ rather than EXPERIMENTAL in the X86_32 subclause... ]
+
+Link: http://lkml.kernel.org/r/20130131005616.1C79F411@kernel.stglabs.ibm.com
+Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/Kconfig | 4 -
+ arch/x86/mm/numa.c | 3
+ arch/x86/mm/numa_32.c | 161 --------------------------------------------
+ arch/x86/mm/numa_internal.h | 6 -
+ 4 files changed, 174 deletions(-)
+
+--- a/arch/x86/Kconfig
++++ b/arch/x86/Kconfig
+@@ -1253,10 +1253,6 @@ config NODES_SHIFT
+ Specify the maximum number of NUMA Nodes available on the target
+ system. Increases memory reserved to accommodate various tables.
+
+-config HAVE_ARCH_ALLOC_REMAP
+- def_bool y
+- depends on X86_32 && NUMA
+-
+ config ARCH_HAVE_MEMORY_PRESENT
+ def_bool y
+ depends on X86_32 && DISCONTIGMEM
+--- a/arch/x86/mm/numa.c
++++ b/arch/x86/mm/numa.c
+@@ -205,9 +205,6 @@ static void __init setup_node_data(int n
+ if (end && (end - start) < NODE_MIN_SIZE)
+ return;
+
+- /* initialize remap allocator before aligning to ZONE_ALIGN */
+- init_alloc_remap(nid, start, end);
+-
+ start = roundup(start, ZONE_ALIGN);
+
+ printk(KERN_INFO "Initmem setup node %d [mem %#010Lx-%#010Lx]\n",
+--- a/arch/x86/mm/numa_32.c
++++ b/arch/x86/mm/numa_32.c
+@@ -73,167 +73,6 @@ unsigned long node_memmap_size_bytes(int
+
+ extern unsigned long highend_pfn, highstart_pfn;
+
+-#define LARGE_PAGE_BYTES (PTRS_PER_PTE * PAGE_SIZE)
+-
+-static void *node_remap_start_vaddr[MAX_NUMNODES];
+-void set_pmd_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags);
+-
+-/*
+- * Remap memory allocator
+- */
+-static unsigned long node_remap_start_pfn[MAX_NUMNODES];
+-static void *node_remap_end_vaddr[MAX_NUMNODES];
+-static void *node_remap_alloc_vaddr[MAX_NUMNODES];
+-
+-/**
+- * alloc_remap - Allocate remapped memory
+- * @nid: NUMA node to allocate memory from
+- * @size: The size of allocation
+- *
+- * Allocate @size bytes from the remap area of NUMA node @nid. The
+- * size of the remap area is predetermined by init_alloc_remap() and
+- * only the callers considered there should call this function. For
+- * more info, please read the comment on top of init_alloc_remap().
+- *
+- * The caller must be ready to handle allocation failure from this
+- * function and fall back to regular memory allocator in such cases.
+- *
+- * CONTEXT:
+- * Single CPU early boot context.
+- *
+- * RETURNS:
+- * Pointer to the allocated memory on success, %NULL on failure.
+- */
+-void *alloc_remap(int nid, unsigned long size)
+-{
+- void *allocation = node_remap_alloc_vaddr[nid];
+-
+- size = ALIGN(size, L1_CACHE_BYTES);
+-
+- if (!allocation || (allocation + size) > node_remap_end_vaddr[nid])
+- return NULL;
+-
+- node_remap_alloc_vaddr[nid] += size;
+- memset(allocation, 0, size);
+-
+- return allocation;
+-}
+-
+-#ifdef CONFIG_HIBERNATION
+-/**
+- * resume_map_numa_kva - add KVA mapping to the temporary page tables created
+- * during resume from hibernation
+- * @pgd_base - temporary resume page directory
+- */
+-void resume_map_numa_kva(pgd_t *pgd_base)
+-{
+- int node;
+-
+- for_each_online_node(node) {
+- unsigned long start_va, start_pfn, nr_pages, pfn;
+-
+- start_va = (unsigned long)node_remap_start_vaddr[node];
+- start_pfn = node_remap_start_pfn[node];
+- nr_pages = (node_remap_end_vaddr[node] -
+- node_remap_start_vaddr[node]) >> PAGE_SHIFT;
+-
+- printk(KERN_DEBUG "%s: node %d\n", __func__, node);
+-
+- for (pfn = 0; pfn < nr_pages; pfn += PTRS_PER_PTE) {
+- unsigned long vaddr = start_va + (pfn << PAGE_SHIFT);
+- pgd_t *pgd = pgd_base + pgd_index(vaddr);
+- pud_t *pud = pud_offset(pgd, vaddr);
+- pmd_t *pmd = pmd_offset(pud, vaddr);
+-
+- set_pmd(pmd, pfn_pmd(start_pfn + pfn,
+- PAGE_KERNEL_LARGE_EXEC));
+-
+- printk(KERN_DEBUG "%s: %08lx -> pfn %08lx\n",
+- __func__, vaddr, start_pfn + pfn);
+- }
+- }
+-}
+-#endif
+-
+-/**
+- * init_alloc_remap - Initialize remap allocator for a NUMA node
+- * @nid: NUMA node to initizlie remap allocator for
+- *
+- * NUMA nodes may end up without any lowmem. As allocating pgdat and
+- * memmap on a different node with lowmem is inefficient, a special
+- * remap allocator is implemented which can be used by alloc_remap().
+- *
+- * For each node, the amount of memory which will be necessary for
+- * pgdat and memmap is calculated and two memory areas of the size are
+- * allocated - one in the node and the other in lowmem; then, the area
+- * in the node is remapped to the lowmem area.
+- *
+- * As pgdat and memmap must be allocated in lowmem anyway, this
+- * doesn't waste lowmem address space; however, the actual lowmem
+- * which gets remapped over is wasted. The amount shouldn't be
+- * problematic on machines this feature will be used.
+- *
+- * Initialization failure isn't fatal. alloc_remap() is used
+- * opportunistically and the callers will fall back to other memory
+- * allocation mechanisms on failure.
+- */
+-void __init init_alloc_remap(int nid, u64 start, u64 end)
+-{
+- unsigned long start_pfn = start >> PAGE_SHIFT;
+- unsigned long end_pfn = end >> PAGE_SHIFT;
+- unsigned long size, pfn;
+- u64 node_pa, remap_pa;
+- void *remap_va;
+-
+- /*
+- * The acpi/srat node info can show hot-add memroy zones where
+- * memory could be added but not currently present.
+- */
+- printk(KERN_DEBUG "node %d pfn: [%lx - %lx]\n",
+- nid, start_pfn, end_pfn);
+-
+- /* calculate the necessary space aligned to large page size */
+- size = node_memmap_size_bytes(nid, start_pfn, end_pfn);
+- size += ALIGN(sizeof(pg_data_t), PAGE_SIZE);
+- size = ALIGN(size, LARGE_PAGE_BYTES);
+-
+- /* allocate node memory and the lowmem remap area */
+- node_pa = memblock_find_in_range(start, end, size, LARGE_PAGE_BYTES);
+- if (!node_pa) {
+- pr_warning("remap_alloc: failed to allocate %lu bytes for node %d\n",
+- size, nid);
+- return;
+- }
+- memblock_reserve(node_pa, size);
+-
+- remap_pa = memblock_find_in_range(min_low_pfn << PAGE_SHIFT,
+- max_low_pfn << PAGE_SHIFT,
+- size, LARGE_PAGE_BYTES);
+- if (!remap_pa) {
+- pr_warning("remap_alloc: failed to allocate %lu bytes remap area for node %d\n",
+- size, nid);
+- memblock_free(node_pa, size);
+- return;
+- }
+- memblock_reserve(remap_pa, size);
+- remap_va = phys_to_virt(remap_pa);
+-
+- /* perform actual remap */
+- for (pfn = 0; pfn < size >> PAGE_SHIFT; pfn += PTRS_PER_PTE)
+- set_pmd_pfn((unsigned long)remap_va + (pfn << PAGE_SHIFT),
+- (node_pa >> PAGE_SHIFT) + pfn,
+- PAGE_KERNEL_LARGE);
+-
+- /* initialize remap allocator parameters */
+- node_remap_start_pfn[nid] = node_pa >> PAGE_SHIFT;
+- node_remap_start_vaddr[nid] = remap_va;
+- node_remap_end_vaddr[nid] = remap_va + size;
+- node_remap_alloc_vaddr[nid] = remap_va;
+-
+- printk(KERN_DEBUG "remap_alloc: node %d [%08llx-%08llx) -> [%p-%p)\n",
+- nid, node_pa, node_pa + size, remap_va, remap_va + size);
+-}
+-
+ void __init initmem_init(void)
+ {
+ x86_numa_init();
+--- a/arch/x86/mm/numa_internal.h
++++ b/arch/x86/mm/numa_internal.h
+@@ -21,12 +21,6 @@ void __init numa_reset_distance(void);
+
+ void __init x86_numa_init(void);
+
+-#ifdef CONFIG_X86_64
+-static inline void init_alloc_remap(int nid, u64 start, u64 end) { }
+-#else
+-void __init init_alloc_remap(int nid, u64 start, u64 end);
+-#endif
+-
+ #ifdef CONFIG_NUMA_EMU
+ void __init numa_emulation(struct numa_meminfo *numa_meminfo,
+ int numa_dist_cnt);