]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 19 Dec 2009 17:48:14 +0000 (09:48 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 19 Dec 2009 17:48:14 +0000 (09:48 -0800)
* 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  x86, irq: Allow 0xff for /proc/irq/[n]/smp_affinity on an 8-cpu system
  Makefile: Unexport LC_ALL instead of clearing it
  x86: Fix objdump version check in arch/x86/tools/chkobjdump.awk
  x86: Reenable TSC sync check at boot, even with NONSTOP_TSC
  x86: Don't use POSIX character classes in gen-insn-attr-x86.awk
  Makefile: set LC_CTYPE, LC_COLLATE, LC_NUMERIC to C
  x86: Increase MAX_EARLY_RES; insufficient on 32-bit NUMA
  x86: Fix checking of SRAT when node 0 ram is not from 0
  x86, cpuid: Add "volatile" to asm in native_cpuid()
  x86, msr: msrs_alloc/free for CONFIG_SMP=n
  x86, amd: Get multi-node CPU info from NodeId MSR instead of PCI config space
  x86: Add IA32_TSC_AUX MSR and use it
  x86, msr/cpuid: Register enough minors for the MSR and CPUID drivers
  initramfs: add missing decompressor error check
  bzip2: Add missing checks for malloc returning NULL
  bzip2/lzma/gzip: pre-boot malloc doesn't return NULL on failure

1  2 
Makefile
arch/x86/kernel/apic/io_apic.c
arch/x86/lib/Makefile
include/linux/mm.h
mm/page_alloc.c

diff --combined Makefile
index 0ac5812f3b6dd785142ade665ef901edc78d5e94,5e92ca58fb6db18f9834a6a8a3b15647660e9e90..e6b06cbeb47e407a823eb25f393eb7c2c570cee0
+++ b/Makefile
@@@ -1,7 -1,7 +1,7 @@@
  VERSION = 2
  PATCHLEVEL = 6
 -SUBLEVEL = 32
 -EXTRAVERSION =
 +SUBLEVEL = 33
 +EXTRAVERSION = -rc1
  NAME = Man-Eating Seals of Antiquity
  
  # *DOCUMENTATION*
  # o  print "Entering directory ...";
  MAKEFLAGS += -rR --no-print-directory
  
+ # Avoid funny character set dependencies
+ unexport LC_ALL
+ LC_CTYPE=C
+ LC_COLLATE=C
+ LC_NUMERIC=C
+ export LC_CTYPE LC_COLLATE LC_NUMERIC
  # We are using a recursive build, so we need to do a little thinking
  # to get the ordering right.
  #
@@@ -334,9 -341,10 +341,9 @@@ CFLAGS_GCOV       = -fprofile-arcs -ftest-cov
  
  # Use LINUXINCLUDE when you must reference the include/ directory.
  # Needed to be compatible with the O= option
 -LINUXINCLUDE    := -Iinclude \
 -                   $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \
 -                   -I$(srctree)/arch/$(hdr-arch)/include               \
 -                   -include include/linux/autoconf.h
 +LINUXINCLUDE    := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
 +                   $(if $(KBUILD_SRC), -I$(srctree)/include) \
 +                   -include include/generated/autoconf.h
  
  KBUILD_CPPFLAGS := -D__KERNEL__
  
@@@ -464,7 -472,7 +471,7 @@@ ifeq ($(KBUILD_EXTMOD),
  # Carefully list dependencies so we do not try to build scripts twice
  # in parallel
  PHONY += scripts
 -scripts: scripts_basic include/config/auto.conf
 +scripts: scripts_basic include/config/auto.conf include/config/tristate.conf
        $(Q)$(MAKE) $(build)=$(@)
  
  # Objects we will link into vmlinux / subdirs we need to visit
@@@ -491,18 -499,18 +498,18 @@@ $(KCONFIG_CONFIG) include/config/auto.c
  # with it and forgot to run make oldconfig.
  # if auto.conf.cmd is missing then we are probably in a cleaned tree so
  # we execute the config step to be sure to catch updated Kconfig files
 -include/config/auto.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
 +include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
        $(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
  else
 -# external modules needs include/linux/autoconf.h and include/config/auto.conf
 +# external modules needs include/generated/autoconf.h and include/config/auto.conf
  # but do not care if they are up-to-date. Use auto.conf to trigger the test
  PHONY += include/config/auto.conf
  
  include/config/auto.conf:
 -      $(Q)test -e include/linux/autoconf.h -a -e $@ || (              \
 +      $(Q)test -e include/generated/autoconf.h -a -e $@ || (          \
        echo;                                                           \
        echo "  ERROR: Kernel configuration is invalid.";               \
 -      echo "         include/linux/autoconf.h or $@ are missing.";    \
 +      echo "         include/generated/autoconf.h or $@ are missing.";\
        echo "         Run 'make oldconfig && make prepare' on kernel src to fix it.";  \
        echo;                                                           \
        /bin/false)
@@@ -876,9 -884,6 +883,9 @@@ $(sort $(vmlinux-init) $(vmlinux-main)
  PHONY += $(vmlinux-dirs)
  $(vmlinux-dirs): prepare scripts
        $(Q)$(MAKE) $(build)=$@
 +ifdef CONFIG_MODULES
 +      $(Q)$(MAKE) $(modbuiltin)=$@
 +endif
  
  # Build the kernel release string
  #
@@@ -957,6 -962,7 +964,6 @@@ PHONY += prepare archprepare prepare0 p
  # prepare3 is used to check if we are building in a separate output directory,
  # and if so do:
  # 1) Check that make has not been executed in the kernel src $(srctree)
 -# 2) Create the include2 directory, used for the second asm symlink
  prepare3: include/config/kernel.release
  ifneq ($(KBUILD_SRC),)
        @$(kecho) '  Using $(srctree) as source for kernel'
                echo "  in the '$(srctree)' directory.";\
                /bin/false; \
        fi;
 -      $(Q)if [ ! -d include2 ]; then                                  \
 -          mkdir -p include2;                                          \
 -          ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm;     \
 -      fi
  endif
  
  # prepare2 creates a makefile if using a separate output directory
  prepare2: prepare3 outputmakefile
  
 -prepare1: prepare2 include/linux/version.h include/linux/utsrelease.h \
 -                   include/asm include/config/auto.conf
 +prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
 +                   include/config/auto.conf
        $(cmd_crmodverdir)
  
  archprepare: prepare1 scripts_basic
@@@ -983,6 -993,42 +990,6 @@@ prepare0: archprepare FORC
  # All the preparing..
  prepare: prepare0
  
 -# The asm symlink changes when $(ARCH) changes.
 -# Detect this and ask user to run make mrproper
 -# If asm is a stale symlink (point to dir that does not exist) remove it
 -define check-symlink
 -      set -e;                                                            \
 -      if [ -L include/asm ]; then                                        \
 -              asmlink=`readlink include/asm | cut -d '-' -f 2`;          \
 -              if [ "$$asmlink" != "$(SRCARCH)" ]; then                   \
 -                      echo "ERROR: the symlink $@ points to asm-$$asmlink but asm-$(SRCARCH) was expected"; \
 -                      echo "       set ARCH or save .config and run 'make mrproper' to fix it";             \
 -                      exit 1;                                            \
 -              fi;                                                        \
 -              test -e $$asmlink || rm include/asm;                       \
 -      elif [ -d include/asm ]; then                                      \
 -              echo "ERROR: $@ is a directory but a symlink was expected";\
 -              exit 1;                                                    \
 -      fi
 -endef
 -
 -# We create the target directory of the symlink if it does
 -# not exist so the test in check-symlink works and we have a
 -# directory for generated filesas used by some architectures.
 -define create-symlink
 -      if [ ! -L include/asm ]; then                                      \
 -                      $(kecho) '  SYMLINK $@ -> include/asm-$(SRCARCH)'; \
 -                      if [ ! -d include/asm-$(SRCARCH) ]; then           \
 -                              mkdir -p include/asm-$(SRCARCH);           \
 -                      fi;                                                \
 -                      ln -fsn asm-$(SRCARCH) $@;                         \
 -      fi
 -endef
 -
 -include/asm: FORCE
 -      $(Q)$(check-symlink)
 -      $(Q)$(create-symlink)
 -
  # Generate some files
  # ---------------------------------------------------------------------------
  
@@@ -1007,7 -1053,7 +1014,7 @@@ ende
  include/linux/version.h: $(srctree)/Makefile FORCE
        $(call filechk,version.h)
  
 -include/linux/utsrelease.h: include/config/kernel.release FORCE
 +include/generated/utsrelease.h: include/config/kernel.release FORCE
        $(call filechk,utsrelease.h)
  
  PHONY += headerdep
@@@ -1037,6 -1083,11 +1044,6 @@@ firmware_install: FORC
  export INSTALL_HDR_PATH = $(objtree)/usr
  
  hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
 -# Find out where the Kbuild file is located to support
 -# arch/$(ARCH)/include/asm
 -hdr-dir = $(strip                                                         \
 -          $(if $(wildcard $(srctree)/arch/$(hdr-arch)/include/asm/Kbuild), \
 -               arch/$(hdr-arch)/include/asm, include/asm-$(hdr-arch)))
  
  # If we do an all arch process set dst to asm-$(hdr-arch)
  hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
@@@ -1051,10 -1102,10 +1058,10 @@@ headers_install_all
  
  PHONY += headers_install
  headers_install: __headers
 -      $(if $(wildcard $(srctree)/$(hdr-dir)/Kbuild),, \
 +      $(if $(wildcard $(srctree)/arch/$(hdr-arch)/include/asm/Kbuild),, \
        $(error Headers not exportable for the $(SRCARCH) architecture))
        $(Q)$(MAKE) $(hdr-inst)=include
 -      $(Q)$(MAKE) $(hdr-inst)=$(hdr-dir) $(hdr-dst)
 +      $(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/asm $(hdr-dst)
  
  PHONY += headers_check_all
  headers_check_all: headers_install_all
  PHONY += headers_check
  headers_check: headers_install
        $(Q)$(MAKE) $(hdr-inst)=include HDRCHECK=1
 -      $(Q)$(MAKE) $(hdr-inst)=$(hdr-dir) $(hdr-dst) HDRCHECK=1
 +      $(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/asm $(hdr-dst) HDRCHECK=1
  
  # ---------------------------------------------------------------------------
  # Modules
@@@ -1083,7 -1134,6 +1090,7 @@@ all: module
  PHONY += modules
  modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux)
        $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
 +      $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.builtin) > $(objtree)/modules.builtin
        @$(kecho) '  Building modules, stage 2.';
        $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
        $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modbuild
@@@ -1113,7 -1163,6 +1120,7 @@@ _modinst_
                ln -s $(objtree) $(MODLIB)/build ; \
        fi
        @cp -f $(objtree)/modules.order $(MODLIB)/
 +      @cp -f $(objtree)/modules.builtin $(MODLIB)/
        $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
  
  # This depmod is only for convenience to give the initial
@@@ -1152,10 -1201,12 +1159,10 @@@ CLEAN_FILES +=       vmlinux System.map 
                  .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
  
  # Directories & files removed with 'make mrproper'
 -MRPROPER_DIRS  += include/config include2 usr/include include/generated
 -MRPROPER_FILES += .config .config.old include/asm .version .old_version \
 -                  include/linux/autoconf.h include/linux/version.h      \
 -                  include/linux/utsrelease.h                            \
 -                  include/linux/bounds.h include/asm*/asm-offsets.h     \
 -                Module.symvers Module.markers tags TAGS cscope*
 +MRPROPER_DIRS  += include/config usr/include include/generated
 +MRPROPER_FILES += .config .config.old .version .old_version             \
 +                  include/linux/version.h                               \
 +                Module.symvers tags TAGS cscope*
  
  # clean - Delete most, but leave enough to build external modules
  #
@@@ -1174,7 -1225,7 +1181,7 @@@ clean: archclean $(clean-dirs
                \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
                -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
                -o -name '*.symtypes' -o -name 'modules.order' \
 -              -o -name 'Module.markers' -o -name '.tmp_*.o.*' \
 +              -o -name modules.builtin -o -name '.tmp_*.o.*' \
                -o -name '*.gcno' \) -type f -print | xargs rm -f
  
  # mrproper - Delete all generated files, including .config
@@@ -1372,8 -1423,8 +1379,8 @@@ $(clean-dirs)
  
  clean:        rm-dirs := $(MODVERDIR)
  clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers \
 -                   $(KBUILD_EXTMOD)/Module.markers \
 -                   $(KBUILD_EXTMOD)/modules.order
 +                   $(KBUILD_EXTMOD)/modules.order \
 +                   $(KBUILD_EXTMOD)/modules.builtin
  clean: $(clean-dirs)
        $(call cmd,rmdirs)
        $(call cmd,rmfiles)
index 11a5851f1f50d9119531fe97da622499d8804062,98ced709e8290ac226722d95a5a8536aa5013476..de00c4619a55b85060a362a5640b141a7492d501
@@@ -2276,26 -2276,28 +2276,28 @@@ static void __target_IO_APIC_irq(unsign
  
  /*
   * Either sets desc->affinity to a valid value, and returns
-  * ->cpu_mask_to_apicid of that, or returns BAD_APICID and
+  * ->cpu_mask_to_apicid of that in dest_id, or returns -1 and
   * leaves desc->affinity untouched.
   */
  unsigned int
- set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask)
+ set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask,
+                 unsigned int *dest_id)
  {
        struct irq_cfg *cfg;
        unsigned int irq;
  
        if (!cpumask_intersects(mask, cpu_online_mask))
-               return BAD_APICID;
+               return -1;
  
        irq = desc->irq;
        cfg = desc->chip_data;
        if (assign_irq_vector(irq, cfg, mask))
-               return BAD_APICID;
+               return -1;
  
        cpumask_copy(desc->affinity, mask);
  
-       return apic->cpu_mask_to_apicid_and(desc->affinity, cfg->domain);
+       *dest_id = apic->cpu_mask_to_apicid_and(desc->affinity, cfg->domain);
+       return 0;
  }
  
  static int
@@@ -2311,12 -2313,11 +2313,11 @@@ set_ioapic_affinity_irq_desc(struct irq
        cfg = desc->chip_data;
  
        spin_lock_irqsave(&ioapic_lock, flags);
-       dest = set_desc_affinity(desc, mask);
-       if (dest != BAD_APICID) {
+       ret = set_desc_affinity(desc, mask, &dest);
+       if (!ret) {
                /* Only the high 8 bits are valid. */
                dest = SET_APIC_LOGICAL_ID(dest);
                __target_IO_APIC_irq(irq, dest, cfg);
-               ret = 0;
        }
        spin_unlock_irqrestore(&ioapic_lock, flags);
  
@@@ -2431,7 -2432,7 +2432,7 @@@ asmlinkage void smp_irq_move_cleanup_in
                        continue;
  
                cfg = irq_cfg(irq);
 -              spin_lock(&desc->lock);
 +              raw_spin_lock(&desc->lock);
  
                if (vector == cfg->vector && cpumask_test_cpu(me, cfg->domain))
                        goto unlock;
                }
                __get_cpu_var(vector_irq)[vector] = -1;
  unlock:
 -              spin_unlock(&desc->lock);
 +              raw_spin_unlock(&desc->lock);
        }
  
        irq_exit();
@@@ -3351,8 -3352,7 +3352,7 @@@ static int set_msi_irq_affinity(unsigne
        struct msi_msg msg;
        unsigned int dest;
  
-       dest = set_desc_affinity(desc, mask);
-       if (dest == BAD_APICID)
+       if (set_desc_affinity(desc, mask, &dest))
                return -1;
  
        cfg = desc->chip_data;
@@@ -3384,8 -3384,7 +3384,7 @@@ ir_set_msi_irq_affinity(unsigned int ir
        if (get_irte(irq, &irte))
                return -1;
  
-       dest = set_desc_affinity(desc, mask);
-       if (dest == BAD_APICID)
+       if (set_desc_affinity(desc, mask, &dest))
                return -1;
  
        irte.vector = cfg->vector;
@@@ -3567,8 -3566,7 +3566,7 @@@ static int dmar_msi_set_affinity(unsign
        struct msi_msg msg;
        unsigned int dest;
  
-       dest = set_desc_affinity(desc, mask);
-       if (dest == BAD_APICID)
+       if (set_desc_affinity(desc, mask, &dest))
                return -1;
  
        cfg = desc->chip_data;
@@@ -3623,8 -3621,7 +3621,7 @@@ static int hpet_msi_set_affinity(unsign
        struct msi_msg msg;
        unsigned int dest;
  
-       dest = set_desc_affinity(desc, mask);
-       if (dest == BAD_APICID)
+       if (set_desc_affinity(desc, mask, &dest))
                return -1;
  
        cfg = desc->chip_data;
@@@ -3730,8 -3727,7 +3727,7 @@@ static int set_ht_irq_affinity(unsigne
        struct irq_cfg *cfg;
        unsigned int dest;
  
-       dest = set_desc_affinity(desc, mask);
-       if (dest == BAD_APICID)
+       if (set_desc_affinity(desc, mask, &dest))
                return -1;
  
        cfg = desc->chip_data;
diff --combined arch/x86/lib/Makefile
index 45b20e486c2f40e5895cb288851d0f2d3f7f59ab,706be8bf967baa50e01d39b50675d1216a792f9c..cffd754f30396f447b9eb8955b8cccbad7420107
@@@ -5,7 -5,7 +5,7 @@@
  inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk
  inat_tables_maps = $(srctree)/arch/x86/lib/x86-opcode-map.txt
  quiet_cmd_inat_tables = GEN     $@
 -      cmd_inat_tables = $(AWK) -f $(inat_tables_script) $(inat_tables_maps) > $@
 +      cmd_inat_tables = $(AWK) -f $(inat_tables_script) $(inat_tables_maps) > $@ || rm -f $@
  
  $(obj)/inat-tables.c: $(inat_tables_script) $(inat_tables_maps)
        $(call cmd,inat_tables)
@@@ -14,15 -14,15 +14,15 @@@ $(obj)/inat.o: $(obj)/inat-tables.
  
  clean-files := inat-tables.c
  
- obj-$(CONFIG_SMP) := msr.o
+ obj-$(CONFIG_SMP) += msr-smp.o
  
  lib-y := delay.o
  lib-y += thunk_$(BITS).o
  lib-y += usercopy_$(BITS).o getuser.o putuser.o
  lib-y += memcpy_$(BITS).o
 -lib-y += insn.o inat.o
 +lib-$(CONFIG_KPROBES) += insn.o inat.o
  
- obj-y += msr-reg.o msr-reg-export.o
+ obj-y += msr.o msr-reg.o msr-reg-export.o
  
  ifeq ($(CONFIG_X86_32),y)
          obj-y += atomic64_32.o
diff --combined include/linux/mm.h
index 849b4a61bd8fbf983c3d0656062b41ab28f13274,20a2036f3a94f830bd7ddcc855e6e28299218b60..2265f28eb47a92bd858c0bf664b37a46d41b1831
@@@ -620,22 -620,13 +620,22 @@@ void page_address_init(void)
  /*
   * On an anonymous page mapped into a user virtual memory area,
   * page->mapping points to its anon_vma, not to a struct address_space;
 - * with the PAGE_MAPPING_ANON bit set to distinguish it.
 + * with the PAGE_MAPPING_ANON bit set to distinguish it.  See rmap.h.
 + *
 + * On an anonymous page in a VM_MERGEABLE area, if CONFIG_KSM is enabled,
 + * the PAGE_MAPPING_KSM bit may be set along with the PAGE_MAPPING_ANON bit;
 + * and then page->mapping points, not to an anon_vma, but to a private
 + * structure which KSM associates with that merged page.  See ksm.h.
 + *
 + * PAGE_MAPPING_KSM without PAGE_MAPPING_ANON is currently never used.
   *
   * Please note that, confusingly, "page_mapping" refers to the inode
   * address_space which maps the page from disk; whereas "page_mapped"
   * refers to user virtual address space into which the page is mapped.
   */
  #define PAGE_MAPPING_ANON     1
 +#define PAGE_MAPPING_KSM      2
 +#define PAGE_MAPPING_FLAGS    (PAGE_MAPPING_ANON | PAGE_MAPPING_KSM)
  
  extern struct address_space swapper_space;
  static inline struct address_space *page_mapping(struct page *page)
        struct address_space *mapping = page->mapping;
  
        VM_BUG_ON(PageSlab(page));
 -#ifdef CONFIG_SWAP
        if (unlikely(PageSwapCache(page)))
                mapping = &swapper_space;
 -      else
 -#endif
 -      if (unlikely((unsigned long)mapping & PAGE_MAPPING_ANON))
 +      else if (unlikely((unsigned long)mapping & PAGE_MAPPING_ANON))
                mapping = NULL;
        return mapping;
  }
  
 +/* Neutral page->mapping pointer to address_space or anon_vma or other */
 +static inline void *page_rmapping(struct page *page)
 +{
 +      return (void *)((unsigned long)page->mapping & ~PAGE_MAPPING_FLAGS);
 +}
 +
  static inline int PageAnon(struct page *page)
  {
        return ((unsigned long)page->mapping & PAGE_MAPPING_ANON) != 0;
@@@ -770,7 -758,6 +770,7 @@@ unsigned long unmap_vmas(struct mmu_gat
   * @pmd_entry: if set, called for each non-empty PMD (3rd-level) entry
   * @pte_entry: if set, called for each non-empty PTE (4th-level) entry
   * @pte_hole: if set, called for each hole at all levels
 + * @hugetlb_entry: if set, called for each hugetlb entry
   *
   * (see walk_page_range for more details)
   */
@@@ -780,8 -767,6 +780,8 @@@ struct mm_walk 
        int (*pmd_entry)(pmd_t *, unsigned long, unsigned long, struct mm_walk *);
        int (*pte_entry)(pte_t *, unsigned long, unsigned long, struct mm_walk *);
        int (*pte_hole)(unsigned long, unsigned long, struct mm_walk *);
 +      int (*hugetlb_entry)(pte_t *, unsigned long, unsigned long,
 +                           struct mm_walk *);
        struct mm_struct *mm;
        void *private;
  };
@@@ -1037,6 -1022,9 +1037,9 @@@ extern void add_active_range(unsigned i
  extern void remove_active_range(unsigned int nid, unsigned long start_pfn,
                                        unsigned long end_pfn);
  extern void remove_all_active_ranges(void);
+ void sort_node_map(void);
+ unsigned long __absent_pages_in_range(int nid, unsigned long start_pfn,
+                                               unsigned long end_pfn);
  extern unsigned long absent_pages_in_range(unsigned long start_pfn,
                                                unsigned long end_pfn);
  extern void get_pfn_range_for_nid(unsigned int nid,
@@@ -1331,17 -1319,11 +1334,17 @@@ extern int account_locked_memory(struc
                                 size_t size);
  extern void refund_locked_memory(struct mm_struct *mm, size_t size);
  
 +enum mf_flags {
 +      MF_COUNT_INCREASED = 1 << 0,
 +};
  extern void memory_failure(unsigned long pfn, int trapno);
 -extern int __memory_failure(unsigned long pfn, int trapno, int ref);
 +extern int __memory_failure(unsigned long pfn, int trapno, int flags);
 +extern int unpoison_memory(unsigned long pfn);
  extern int sysctl_memory_failure_early_kill;
  extern int sysctl_memory_failure_recovery;
 +extern void shake_page(struct page *p, int access);
  extern atomic_long_t mce_bad_pages;
 +extern int soft_offline_page(struct page *page, int flags);
  
  #endif /* __KERNEL__ */
  #endif /* _LINUX_MM_H */
diff --combined mm/page_alloc.c
index 74af449b1f1dd3a5ed51f139d1e4903a33ec5f24,873c86308b4e97ce3982769105b6d5d0a4a2efce..4e869657cb51623c18c31022fb74f8e50cebdd44
@@@ -486,6 -486,7 +486,6 @@@ static inline void __free_one_page(stru
        zone->free_area[order].nr_free++;
  }
  
 -#ifdef CONFIG_HAVE_MLOCKED_PAGE_BIT
  /*
   * free_page_mlock() -- clean up attempts to free and mlocked() page.
   * Page should not be on lru, so no need to fix that up.
@@@ -496,6 -497,9 +496,6 @@@ static inline void free_page_mlock(stru
        __dec_zone_page_state(page, NR_MLOCK);
        __count_vm_event(UNEVICTABLE_MLOCKFREED);
  }
 -#else
 -static void free_page_mlock(struct page *page) { }
 -#endif
  
  static inline int free_pages_check(struct page *page)
  {
@@@ -1654,22 -1658,12 +1654,22 @@@ __alloc_pages_may_oom(gfp_t gfp_mask, u
        if (page)
                goto out;
  
 -      /* The OOM killer will not help higher order allocs */
 -      if (order > PAGE_ALLOC_COSTLY_ORDER && !(gfp_mask & __GFP_NOFAIL))
 -              goto out;
 -
 +      if (!(gfp_mask & __GFP_NOFAIL)) {
 +              /* The OOM killer will not help higher order allocs */
 +              if (order > PAGE_ALLOC_COSTLY_ORDER)
 +                      goto out;
 +              /*
 +               * GFP_THISNODE contains __GFP_NORETRY and we never hit this.
 +               * Sanity check for bare calls of __GFP_THISNODE, not real OOM.
 +               * The caller should handle page allocation failure by itself if
 +               * it specifies __GFP_THISNODE.
 +               * Note: Hugepage uses it but will hit PAGE_ALLOC_COSTLY_ORDER.
 +               */
 +              if (gfp_mask & __GFP_THISNODE)
 +                      goto out;
 +      }
        /* Exhausted what can be done so it's blamo time */
 -      out_of_memory(zonelist, gfp_mask, order);
 +      out_of_memory(zonelist, gfp_mask, order, nodemask);
  
  out:
        clear_zonelist_oom(zonelist, gfp_mask);
@@@ -3133,7 -3127,7 +3133,7 @@@ static int __cpuinit process_zones(int 
  
                if (percpu_pagelist_fraction)
                        setup_pagelist_highmark(zone_pcp(zone, cpu),
 -                              (zone->present_pages / percpu_pagelist_fraction));
 +                          (zone->present_pages / percpu_pagelist_fraction));
        }
  
        return 0;
@@@ -3579,7 -3573,7 +3579,7 @@@ static unsigned long __meminit zone_spa
   * Return the number of holes in a range on a node. If nid is MAX_NUMNODES,
   * then all holes in the requested range will be accounted for.
   */
static unsigned long __meminit __absent_pages_in_range(int nid,
+ unsigned long __meminit __absent_pages_in_range(int nid,
                                unsigned long range_start_pfn,
                                unsigned long range_end_pfn)
  {
@@@ -4108,7 -4102,7 +4108,7 @@@ static int __init cmp_node_active_regio
  }
  
  /* sort the node_map by start_pfn */
static void __init sort_node_map(void)
+ void __init sort_node_map(void)
  {
        sort(early_node_map, (size_t)nr_nodemap_entries,
                        sizeof(struct node_active_region),
@@@ -5091,24 -5085,3 +5091,24 @@@ __offline_isolated_pages(unsigned long 
        spin_unlock_irqrestore(&zone->lock, flags);
  }
  #endif
 +
 +#ifdef CONFIG_MEMORY_FAILURE
 +bool is_free_buddy_page(struct page *page)
 +{
 +      struct zone *zone = page_zone(page);
 +      unsigned long pfn = page_to_pfn(page);
 +      unsigned long flags;
 +      int order;
 +
 +      spin_lock_irqsave(&zone->lock, flags);
 +      for (order = 0; order < MAX_ORDER; order++) {
 +              struct page *page_head = page - (pfn & ((1 << order) - 1));
 +
 +              if (PageBuddy(page_head) && page_order(page_head) >= order)
 +                      break;
 +      }
 +      spin_unlock_irqrestore(&zone->lock, flags);
 +
 +      return order < MAX_ORDER;
 +}
 +#endif