1. 27 Feb, 2013 3 commits
  2. 24 Feb, 2013 37 commits
    • Benson Leung's avatar
      Platform: x86: Add Chrome OS Laptop driver · d1381f45
      Benson Leung authored
      This adds the chromeos_laptop driver. It supports
      the Cypress APA SMBUS touchpad as well as the isl29018 i2c ambient
      light sensor on the Samsung Series 5 550 Chromebook.
      Signed-off-by: default avatarBenson Leung <bleung@chromium.org>
      Reviewed-by: default avatarOlof Johansson <olof@lixom.net>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      d1381f45
    • Manoj Iyer's avatar
      thinkpad-acpi: enable loading module with new B-series Lenovo BIOS · 16a3d9f5
      Manoj Iyer authored
      The new B series BIOS has version string 43CN46WW. The driver
      requires that 2nd and 3rd characters be 'E' and 'T' respectively,
      where as the newer BIOS has 'C' and 'N' respectively. Failing to
      load the module causes some of the hotkeys to not work.
      
      Before the patch
      ================
      sudo modprobe thinkpad_acpi
      FATAL: Error inserting thinkpad_acpi (/lib/modules/3.5.0-15-generic/kernel/drivers/platform/x86/thinkpad_acpi.ko): No such device
      
      After the patch
      ===============
      [44937.265438] thinkpad_acpi: ThinkPad ACPI Extras v0.24
      [44937.265445] thinkpad_acpi: http://ibm-acpi.sf.net/
      [44937.265449] thinkpad_acpi: ThinkPad BIOS 43CN46WW, EC unknown
      [44937.265453] thinkpad_acpi: Lenovo Lenovo B470e, model HuronRiver Platform
      [44937.266479] thinkpad_acpi: detected a 8-level brightness capable ThinkPad
      [44937.266557] thinkpad_acpi: Standard ACPI backlight interface available, not loading native one
      [44937.267846] thinkpad_acpi: Console audio control enabled, mode: monitor (read only)
      [44937.268131] input: ThinkPad Extra Buttons as /devices/platform/thinkpad_acpi/input/input17
      Signed-off-by: default avatarManoj Iyer <manoj.iyer@canonical.com>
      Tested-by: default avatarJames Ferguson <james.ferguson@canonical.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      16a3d9f5
    • Trepák Vilmos's avatar
      Platform: hp-wmi: add rfkill support for integrated GPS · 4fca7ce3
      Trepák Vilmos authored
      Add rfkill support for the GPS radio found in HP laptops (HP Elitebook 2170p and the like)
      using the Ericsson F5321/H5321 Mobile Broadband Module.
      Signed-off-by: default avatarViliam Trepák <trepo@netcomga.sk>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      4fca7ce3
    • Lee, Chun-Yi's avatar
      acer-wmi: support Lenovo ideapad S205 1038DPG wifi switch · 5f3511d2
      Lee, Chun-Yi authored
      Found another Lenovo ideapad S205 the product name is 1038DPG, it has
      a 0x78 EC register exposes the state of wifi hardware switch on the machine.
      
      So, add this patch to support Lenovo ideapad S205-1038DPG wifi hardware
      switch in acer-wmi driver.
      
      Evidently the Ideapad S205 is just a model name on the market, but they have
      totally different product name in DMI table.
      
      Reference: bko#43007
              https://bugzilla.kernel.org/show_bug.cgi?id=43007Tested-by: default avatarColin <colin.newell@gmail.com>
      Cc: Carlos Corbacho <carlos@strangeworlds.co.uk>
      Cc: Matthew Garrett <mjg@redhat.com>
      Cc: Dmitry Torokhov <dtor@mail.ru>
      Cc: Corentin Chary <corentincj@iksaif.net>
      Cc: Thomas Renninger <trenn@suse.de>
      Signed-off-by: default avatarLee, Chun-Yi <jlee@suse.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      5f3511d2
    • Lee, Chun-Yi's avatar
      acer-wmi: support Lenovo ideapad S205 10382JG wifi switch · e6c33f1f
      Lee, Chun-Yi authored
      Found another Lenovo ideapad S205 the product name is 10382JG, it has
      a 0x78 EC register exposes the state of wifi hardware switch on the machine.
      
      So, add this patch to support Lenovo ideapad S205-10382JG wifi hardware
      switch in acer-wmi driver.
      
      Evidently the Ideapad S205 is just a model name on the market, but they have
      totally different product name in DMI table.
      
      Reference: bko#43007
              https://bugzilla.kernel.org/show_bug.cgi?id=43007Tested-by: default avatarIvo Anjo <knuckles@gmail.com>
      Cc: Carlos Corbacho <carlos@strangeworlds.co.uk>
      Cc: Matthew Garrett <mjg@redhat.com>
      Cc: Dmitry Torokhov <dtor@mail.ru>
      Cc: Corentin Chary <corentincj@iksaif.net>
      Cc: Thomas Renninger <trenn@suse.de>
      Signed-off-by: default avatarLee, Chun-Yi <jlee@suse.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      e6c33f1f
    • AceLan Kao's avatar
      asus-nb-wmi: add all video switch keys · 24c8a4c4
      AceLan Kao authored
      Fill up all the video switch keys in the map.
      Signed-off-by: default avatarAceLan Kao <acelan.kao@canonical.com>
      Signed-off-by: default avatarCorentin Chary <corentin.chary@gmail.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      24c8a4c4
    • AceLan Kao's avatar
      asus-wmi: add display toggle quirk · a2a96f0c
      AceLan Kao authored
      For machines with AMD graphic chips, it will send out WMI event and ACPI
      interrupt at the same time while hitting the hotkey. BIOS will notify the
      system the next display output mode throught WMI event code, so that
      windows' application can show an OSD to tell the user which mode will be
      taken effect. User can hit the display toggle key many times within 2
      seconds to choose the mode they want. After 2 seconds, WMI dirver should
      send a WMIMethod(SDSP) command to tell the BIOS which mode the user chose.
      And then BIOS will raise another ACPI interrupt to tell the system to
      really switch the display mode.
      
      In Linux desktop, we don't have this kind of OSD to let users to choose
      the mode they want, so we don't need to call WMIMethod(SDSP) to have
      another ACPI interrupt. To simplify the problem, we just have to ignore
      the WMI event, and let the first ACPI interrupt to send out the key event.
      
      For the need, here comes another quirk to add machines with this kind of
      behavior. When the WMI driver receives the display toggle WMI event, and
      found the machin is in the list, it will do nothing and let ACPI video
      driver to report the key event.
      Signed-off-by: default avatarAceLan Kao <acelan.kao@canonical.com>
      Signed-off-by: default avatarCorentin Chary <corentincj@iksaif.net>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      a2a96f0c
    • AceLan Kao's avatar
      asus-laptop: add all video switch keys · 3da4cd20
      AceLan Kao authored
      Fill up all the video switch keys in the map.
      Signed-off-by: default avatarAceLan Kao <acelan.kao@canonical.com>
      Signed-off-by: default avatarCorentin Chary <corentin.chary@gmail.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      3da4cd20
    • AceLan Kao's avatar
      asus-nb-wmi: correct a touchpad hotkey mapping · 98bfcb8e
      AceLan Kao authored
      0x60 is touchpad enable key, but is misdefined in the keymap.
      Signed-off-by: default avatarAceLan Kao <acelan.kao@canonical.com>
      Signed-off-by: default avatarCorentin Chary <corentin.chary@gmail.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      98bfcb8e
    • AceLan Kao's avatar
      asus-laptop: correct a touchpad hotkey mapping · 19d3ab12
      AceLan Kao authored
      0x60 is touchpad enable key, but is misdefined in the keymap.
      Signed-off-by: default avatarAceLan Kao <acelan.kao@canonical.com>
      Signed-off-by: default avatarCorentin Chary <corentin.chary@gmail.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      19d3ab12
    • Corentin Chary's avatar
      asus-{nb-wmi|laptop}.c: sync keymaps · a935eaec
      Corentin Chary authored
      Maybe this should be shared in another module...
      Signed-off-by: default avatarCorentin Chary <corentin.chary@gmail.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      a935eaec
    • Corentin Chary's avatar
      982d385a
    • Maxim Mikityanskiy's avatar
      msi-wmi: Add MSI Wind support · c11ac2aa
      Maxim Mikityanskiy authored
      Add MSI Wind support to msi-wmi driver. MSI Wind has different GUID for
      key events, different WMI key scan codes, it does not need filtering
      consecutive identical events and it does not support backlight control
      via MSIWMI_BIOS_GUID WMI. Tested on MSI Wind U100.
      Signed-off-by: default avatarMaxim Mikityanskiy <maxtram95@gmail.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      c11ac2aa
    • Maxim Mikityanskiy's avatar
      msi-wmi: Introduced quirk_last_pressed · fedda8e7
      Maxim Mikityanskiy authored
      Introduced quirk_last_pressed variable that would indicate if
      last_pressed is used or not. Also converted last_pressed to simple
      variable in order to allow keymap to be non-contiguous.
      Signed-off-by: default avatarMaxim Mikityanskiy <maxtram95@gmail.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      fedda8e7
    • Maxim Mikityanskiy's avatar
      msi-wmi: Make keys and backlight independent · da850628
      Maxim Mikityanskiy authored
      Introduced function msi_wmi_backlight_setup() that initializes backlight
      device. Made driver load and work if only one WMI (only for hotkeys or
      only for backlight) is present.
      Signed-off-by: default avatarMaxim Mikityanskiy <maxtram95@gmail.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      da850628
    • Maxim Mikityanskiy's avatar
      msi-wmi: Use enums for scancodes · b0d3bb53
      Maxim Mikityanskiy authored
      Use enums for consecutive scancodes, rename key names from MSI_WMI_* to
      MSI_KEY_* and use tabs for whitespace in msi_wmi_keymap.
      Signed-off-by: default avatarMaxim Mikityanskiy <maxtram95@gmail.com>
      Acked-by: default avatarLee, Chun-Yi <jlee@suse.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      b0d3bb53
    • Maxim Mikityanskiy's avatar
      msi-wmi: Avoid repeating constants · dd2b0251
      Maxim Mikityanskiy authored
      Use UUID defines in MODULE_ALIAS strings to avoid repeating strings.
      Signed-off-by: default avatarMaxim Mikityanskiy <maxtram95@gmail.com>
      Acked-by: default avatarLee, Chun-Yi <jlee@suse.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      dd2b0251
    • Maxim Mikityanskiy's avatar
      msi-wmi: Fix memory leak · 51c94491
      Maxim Mikityanskiy authored
      Fix memory leak - don't forget to kfree ACPI object when returning from
      msi_wmi_notify() after suppressing key event.
      Signed-off-by: default avatarMaxim Mikityanskiy <maxtram95@gmail.com>
      Acked-by: default avatarAnisse Astier <anisse@astier.eu>
      Signed-off-by: default avatarLee, Chun-Yi <jlee@suse.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      51c94491
    • Maxim Mikityanskiy's avatar
      msi-laptop: Disable brightness control for new EC · 03696e51
      Maxim Mikityanskiy authored
      It seems that existing brightness control works only for old EC models.
      On newer ones auto_brightness access always timeouts and lcd_level
      always shows 0. So disable brightness control for new EC models. It
      works fine with ACPI video driver anyway.
      Signed-off-by: default avatarMaxim Mikityanskiy <maxtram95@gmail.com>
      Signed-off-by: default avatarLee, Chun-Yi <jlee@suse.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      03696e51
    • Maxim Mikityanskiy's avatar
      msi-laptop: Add missing ABI documentation · cdeaf386
      Maxim Mikityanskiy authored
      Add ABI documentation for all sysfs files exposed by msi-laptop driver.
      Signed-off-by: default avatarMaxim Mikityanskiy <maxtram95@gmail.com>
      Signed-off-by: default avatarLee, Chun-Yi <jlee@suse.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      cdeaf386
    • Maxim Mikityanskiy's avatar
      msi-laptop: Add MSI Wind U90/U100 support · 0de6575a
      Maxim Mikityanskiy authored
      Add MSI Wind U90/U100 to DMI table and add some missing EC features
      support such as basic fan control, turbo and ECO modes and touchpad
      state. Tested on MSI Wind U100.
      Signed-off-by: default avatarMaxim Mikityanskiy <maxtram95@gmail.com>
      Signed-off-by: default avatarLee, Chun-Yi <jlee@suse.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      0de6575a
    • Lee, Chun-Yi's avatar
      msi-laptop: merge quirk tables to one · 0816392b
      Lee, Chun-Yi authored
      This patch introduced a quirk_entry struct, then we merged all quirk
      tables to msi_dmi_table. Then we can more easily to set different quirk
      attributes for different machine.
      Signed-off-by: default avatarLee, Chun-Yi <jlee@suse.com>
      
      Changed this patch so that it could be applied before MSI Wind U100
      support patch. Changed rfkill logic for ec_read_only quirk support.
      Removed delays if ec_delay = false.
      Signed-off-by: default avatarMaxim Mikityanskiy <maxtram95@gmail.com>
      Acked-by: default avatarLee, Chun-Yi <jlee@suse.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      0816392b
    • Maxim Mikityanskiy's avatar
      msi-laptop: Work around gcc warning · 1b6517a0
      Maxim Mikityanskiy authored
      Assign initial value to variable in order to prevent gcc warning about
      uninitialized variable.
      Signed-off-by: default avatarMaxim Mikityanskiy <maxtram95@gmail.com>
      Signed-off-by: default avatarLee, Chun-Yi <jlee@suse.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      1b6517a0
    • Maxim Mikityanskiy's avatar
      msi-laptop: Use proper return codes instead of -1 · 27eb9e7f
      Maxim Mikityanskiy authored
      Use proper function return codes instead of -1
      Signed-off-by: default avatarMaxim Mikityanskiy <maxtram95@gmail.com>
      Signed-off-by: default avatarLee, Chun-Yi <jlee@suse.com>
      Signed-off-by: default avatarMatthew Garrett <matthew.garrett@nebula.com>
      27eb9e7f
    • AceLan Kao's avatar
      asus-wmi: update wlan LED through rfkill led trigger · 6cae06e6
      AceLan Kao authored
      For those machines with wapf=4, BIOS won't update the wireless LED,
      since wapf=4 means user application will take in chage of the wifi and bt.
      So, we have to update wlan LED status explicitly.
      
      But I found there is another wireless LED bug in launchpad and which is
      not in the wapf=4 quirk.
      So, it might be better to set wireless LED status explicitly for all
      machines.
      
      BugLink: https://launchpad.net/bugs/901105Signed-off-by: default avatarAceLan Kao <acelan.kao@canonical.com>
      Signed-off-by: default avatarMatthew Garrett <mjg@redhat.com>
      6cae06e6
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal · 9e2d59ad
      Linus Torvalds authored
      Pull signal handling cleanups from Al Viro:
       "This is the first pile; another one will come a bit later and will
        contain SYSCALL_DEFINE-related patches.
      
         - a bunch of signal-related syscalls (both native and compat)
           unified.
      
         - a bunch of compat syscalls switched to COMPAT_SYSCALL_DEFINE
           (fixing several potential problems with missing argument
           validation, while we are at it)
      
         - a lot of now-pointless wrappers killed
      
         - a couple of architectures (cris and hexagon) forgot to save
           altstack settings into sigframe, even though they used the
           (uninitialized) values in sigreturn; fixed.
      
         - microblaze fixes for delivery of multiple signals arriving at once
      
         - saner set of helpers for signal delivery introduced, several
           architectures switched to using those."
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal: (143 commits)
        x86: convert to ksignal
        sparc: convert to ksignal
        arm: switch to struct ksignal * passing
        alpha: pass k_sigaction and siginfo_t using ksignal pointer
        burying unused conditionals
        make do_sigaltstack() static
        arm64: switch to generic old sigaction() (compat-only)
        arm64: switch to generic compat rt_sigaction()
        arm64: switch compat to generic old sigsuspend
        arm64: switch to generic compat rt_sigqueueinfo()
        arm64: switch to generic compat rt_sigpending()
        arm64: switch to generic compat rt_sigprocmask()
        arm64: switch to generic sigaltstack
        sparc: switch to generic old sigsuspend
        sparc: COMPAT_SYSCALL_DEFINE does all sign-extension as well as SYSCALL_DEFINE
        sparc: kill sign-extending wrappers for native syscalls
        kill sparc32_open()
        sparc: switch to use of generic old sigaction
        sparc: switch sys_compat_rt_sigaction() to COMPAT_SYSCALL_DEFINE
        mips: switch to generic sys_fork() and sys_clone()
        ...
      9e2d59ad
    • Linus Torvalds's avatar
      Merge branch 'akpm' (more incoming from Andrew) · 5ce1a70e
      Linus Torvalds authored
      Merge second patch-bomb from Andrew Morton:
      
       - A little DM fix
      
       - the MM queue
      
      * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (154 commits)
        ksm: allocate roots when needed
        mm: cleanup "swapcache" in do_swap_page
        mm,ksm: swapoff might need to copy
        mm,ksm: FOLL_MIGRATION do migration_entry_wait
        ksm: shrink 32-bit rmap_item back to 32 bytes
        ksm: treat unstable nid like in stable tree
        ksm: add some comments
        tmpfs: fix mempolicy object leaks
        tmpfs: fix use-after-free of mempolicy object
        mm/fadvise.c: drain all pagevecs if POSIX_FADV_DONTNEED fails to discard all pages
        mm: export mmu notifier invalidates
        mm: accelerate mm_populate() treatment of THP pages
        mm: use long type for page counts in mm_populate() and get_user_pages()
        mm: accurately document nr_free_*_pages functions with code comments
        HWPOISON: change order of error_states[]'s elements
        HWPOISON: fix misjudgement of page_action() for errors on mlocked pages
        memcg: stop warning on memcg_propagate_kmem
        net: change type of virtio_chan->p9_max_pages
        vmscan: change type of vm_total_pages to unsigned long
        fs/nfsd: change type of max_delegations, nfsd_drc_max_mem and nfsd_drc_mem_used
        ...
      5ce1a70e
    • Hugh Dickins's avatar
      ksm: allocate roots when needed · ef53d16c
      Hugh Dickins authored
      It is a pity to have MAX_NUMNODES+MAX_NUMNODES tree roots statically
      allocated, particularly when very few users will ever actually tune
      merge_across_nodes 0 to use more than 1+1 of those trees.  Not a big
      deal (only 16kB wasted on each machine with CONFIG_MAXSMP), but a pity.
      
      Start off with 1+1 statically allocated, then if merge_across_nodes is
      ever tuned, allocate for nr_node_ids+nr_node_ids.  Do not attempt to
      free up the extra if it's tuned back, that would be a waste of effort.
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Petr Holasek <pholasek@redhat.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Izik Eidus <izik.eidus@ravellosystems.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ef53d16c
    • Hugh Dickins's avatar
      mm: cleanup "swapcache" in do_swap_page · 56f31801
      Hugh Dickins authored
      I dislike the way in which "swapcache" gets used in do_swap_page():
      there is always a page from swapcache there (even if maybe uncached by
      the time we lock it), but tests are made according to "swapcache".
      Rework that with "page != swapcache", as has been done in unuse_pte().
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Petr Holasek <pholasek@redhat.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Izik Eidus <izik.eidus@ravellosystems.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      56f31801
    • Hugh Dickins's avatar
      mm,ksm: swapoff might need to copy · 9e16b7fb
      Hugh Dickins authored
      Before establishing that KSM page migration was the cause of my
      WARN_ON_ONCE(page_mapped(page))s, I suspected that they came from the
      lack of a ksm_might_need_to_copy() in swapoff's unuse_pte() - which in
      many respects is equivalent to faulting in a page.
      
      In fact I've never caught that as the cause: but in theory it does at
      least need the KSM_RUN_UNMERGE check in ksm_might_need_to_copy(), to
      avoid bringing a KSM page back in when it's not supposed to be.
      
      I intended to copy how it's done in do_swap_page(), but have a strong
      aversion to how "swapcache" ends up being used there: rework it with
      "page != swapcache".
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Petr Holasek <pholasek@redhat.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Izik Eidus <izik.eidus@ravellosystems.com>
      Acked-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9e16b7fb
    • Hugh Dickins's avatar
      mm,ksm: FOLL_MIGRATION do migration_entry_wait · 5117b3b8
      Hugh Dickins authored
      In "ksm: remove old stable nodes more thoroughly" I said that I'd never
      seen its WARN_ON_ONCE(page_mapped(page)).  True at the time of writing,
      but it soon appeared once I tried fuller tests on the whole series.
      
      It turned out to be due to the KSM page migration itself: unmerge_and_
      remove_all_rmap_items() failed to locate and replace all the KSM pages,
      because of that hiatus in page migration when old pte has been replaced
      by migration entry, but not yet by new pte.  follow_page() finds no page
      at that instant, but a KSM page reappears shortly after, without a
      fault.
      
      Add FOLL_MIGRATION flag, so follow_page() can do migration_entry_wait()
      for KSM's break_cow().  I'd have preferred to avoid another flag, and do
      it every time, in case someone else makes the same easy mistake; but did
      not find another transgressor (the common get_user_pages() is of course
      safe), and cannot be sure that every follow_page() caller is prepared to
      sleep - ia64's xencomm_vtop()? Now, THP's wait_split_huge_page() can
      already sleep there, since anon_vma locking was changed to mutex, but
      maybe that's somehow excluded.
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Petr Holasek <pholasek@redhat.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Izik Eidus <izik.eidus@ravellosystems.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5117b3b8
    • Hugh Dickins's avatar
      ksm: shrink 32-bit rmap_item back to 32 bytes · bc56620b
      Hugh Dickins authored
      Think of struct rmap_item as an extension of struct page (restricted to
      MADV_MERGEABLE areas): there may be a lot of them, we need to keep them
      small, especially on 32-bit architectures of limited lowmem.
      
      Siting "int nid" after "unsigned int checksum" works nicely on 64-bit,
      making no change to its 64-byte struct rmap_item; but bloats the 32-bit
      struct rmap_item from (nicely cache-aligned) 32 bytes to 36 bytes, which
      rounds up to 40 bytes once allocated from slab.  We'd better avoid that.
      
      Hey, I only just remembered that the anon_vma pointer in struct
      rmap_item has no purpose until the rmap_item is hung from a stable tree
      node (which has its own nid field); and rmap_item's nid field no purpose
      than to say which tree root to tell rb_erase() when unlinking from an
      unstable tree.
      
      Double them up in a union.  There's just one place where we set anon_vma
      early (when we already hold mmap_sem): now we must remove tree_rmap_item
      from its unstable tree there, before overwriting nid.  No need to
      spatter BUG()s around: we'd be seeing oopses if this were wrong.
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Petr Holasek <pholasek@redhat.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Izik Eidus <izik.eidus@ravellosystems.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      bc56620b
    • Hugh Dickins's avatar
      ksm: treat unstable nid like in stable tree · b599cbdf
      Hugh Dickins authored
      An inconsistency emerged in reviewing the NUMA node changes to KSM: when
      meeting a page from the wrong NUMA node in a stable tree, we say that
      it's okay for comparisons, but not as a leaf for merging; whereas when
      meeting a page from the wrong NUMA node in an unstable tree, we bail out
      immediately.
      
      Now, it might be that a wrong NUMA node in an unstable tree is more
      likely to correlate with instablility (different content, with rbnode
      now misplaced) than page migration; but even so, we are accustomed to
      instablility in the unstable tree.
      
      Without strong evidence for which strategy is generally better, I'd
      rather be consistent with what's done in the stable tree: accept a page
      from the wrong NUMA node for comparison, but not as a leaf for merging.
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Petr Holasek <pholasek@redhat.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Izik Eidus <izik.eidus@ravellosystems.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      b599cbdf
    • Hugh Dickins's avatar
      ksm: add some comments · 8fdb3dbf
      Hugh Dickins authored
      Added slightly more detail to the Documentation of merge_across_nodes, a
      few comments in areas indicated by review, and renamed get_ksm_page()'s
      argument from "locked" to "lock_it".  No functional change.
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Petr Holasek <pholasek@redhat.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Izik Eidus <izik.eidus@ravellosystems.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      8fdb3dbf
    • Greg Thelen's avatar
      tmpfs: fix mempolicy object leaks · 49cd0a5c
      Greg Thelen authored
      Fix several mempolicy leaks in the tmpfs mount logic.  These leaks are
      slow - on the order of one object leaked per mount attempt.
      
      Leak 1 (umount doesn't free mpol allocated in mount):
          while true; do
              mount -t tmpfs -o mpol=interleave,size=100M nodev /mnt
              umount /mnt
          done
      
      Leak 2 (errors parsing remount options will leak mpol):
          mount -t tmpfs -o size=100M nodev /mnt
          while true; do
              mount -o remount,mpol=interleave,size=x /mnt 2> /dev/null
          done
          umount /mnt
      
      Leak 3 (multiple mpol per mount leak mpol):
          while true; do
              mount -t tmpfs -o mpol=interleave,mpol=interleave,size=100M nodev /mnt
              umount /mnt
          done
      
      This patch fixes all of the above.  I could have broken the patch into
      three pieces but is seemed easier to review as one.
      
      [akpm@linux-foundation.org: fix handling of mpol_parse_str() errors, per Hugh]
      Signed-off-by: default avatarGreg Thelen <gthelen@google.com>
      Acked-by: default avatarHugh Dickins <hughd@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      49cd0a5c
    • Greg Thelen's avatar
      tmpfs: fix use-after-free of mempolicy object · 5f00110f
      Greg Thelen authored
      The tmpfs remount logic preserves filesystem mempolicy if the mpol=M
      option is not specified in the remount request.  A new policy can be
      specified if mpol=M is given.
      
      Before this patch remounting an mpol bound tmpfs without specifying
      mpol= mount option in the remount request would set the filesystem's
      mempolicy object to a freed mempolicy object.
      
      To reproduce the problem boot a DEBUG_PAGEALLOC kernel and run:
          # mkdir /tmp/x
      
          # mount -t tmpfs -o size=100M,mpol=interleave nodev /tmp/x
      
          # grep /tmp/x /proc/mounts
          nodev /tmp/x tmpfs rw,relatime,size=102400k,mpol=interleave:0-3 0 0
      
          # mount -o remount,size=200M nodev /tmp/x
      
          # grep /tmp/x /proc/mounts
          nodev /tmp/x tmpfs rw,relatime,size=204800k,mpol=??? 0 0
              # note ? garbage in mpol=... output above
      
          # dd if=/dev/zero of=/tmp/x/f count=1
              # panic here
      
      Panic:
          BUG: unable to handle kernel NULL pointer dereference at           (null)
          IP: [<          (null)>]           (null)
          [...]
          Oops: 0010 [#1] SMP DEBUG_PAGEALLOC
          Call Trace:
            mpol_shared_policy_init+0xa5/0x160
            shmem_get_inode+0x209/0x270
            shmem_mknod+0x3e/0xf0
            shmem_create+0x18/0x20
            vfs_create+0xb5/0x130
            do_last+0x9a1/0xea0
            path_openat+0xb3/0x4d0
            do_filp_open+0x42/0xa0
            do_sys_open+0xfe/0x1e0
            compat_sys_open+0x1b/0x20
            cstar_dispatch+0x7/0x1f
      
      Non-debug kernels will not crash immediately because referencing the
      dangling mpol will not cause a fault.  Instead the filesystem will
      reference a freed mempolicy object, which will cause unpredictable
      behavior.
      
      The problem boils down to a dropped mpol reference below if
      shmem_parse_options() does not allocate a new mpol:
      
          config = *sbinfo
          shmem_parse_options(data, &config, true)
          mpol_put(sbinfo->mpol)
          sbinfo->mpol = config.mpol  /* BUG: saves unreferenced mpol */
      
      This patch avoids the crash by not releasing the mempolicy if
      shmem_parse_options() doesn't create a new mpol.
      
      How far back does this issue go? I see it in both 2.6.36 and 3.3.  I did
      not look back further.
      Signed-off-by: default avatarGreg Thelen <gthelen@google.com>
      Acked-by: default avatarHugh Dickins <hughd@google.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      5f00110f
    • Mel Gorman's avatar
      mm/fadvise.c: drain all pagevecs if POSIX_FADV_DONTNEED fails to discard all pages · 67d46b29
      Mel Gorman authored
      Rob van der Heij reported the following (paraphrased) on private mail.
      
      	The scenario is that I want to avoid backups to fill up the page
      	cache and purge stuff that is more likely to be used again (this is
      	with s390x Linux on z/VM, so I don't give it as much memory that
      	we don't care anymore). So I have something with LD_PRELOAD that
      	intercepts the close() call (from tar, in this case) and issues
      	a posix_fadvise() just before closing the file.
      
      	This mostly works, except for small files (less than 14 pages)
      	that remains in page cache after the face.
      
      Unfortunately Rob has not had a chance to test this exact patch but the
      test program below should be reproducing the problem he described.
      
      The issue is the per-cpu pagevecs for LRU additions.  If the pages are
      added by one CPU but fadvise() is called on another then the pages
      remain resident as the invalidate_mapping_pages() only drains the local
      pagevecs via its call to pagevec_release().  The user-visible effect is
      that a program that uses fadvise() properly is not obeyed.
      
      A possible fix for this is to put the necessary smarts into
      invalidate_mapping_pages() to globally drain the LRU pagevecs if a
      pagevec page could not be discarded.  The downside with this is that an
      inode cache shrink would send a global IPI and memory pressure
      potentially causing global IPI storms is very undesirable.
      
      Instead, this patch adds a check during fadvise(POSIX_FADV_DONTNEED) to
      check if invalidate_mapping_pages() discarded all the requested pages.
      If a subset of pages are discarded it drains the LRU pagevecs and tries
      again.  If the second attempt fails, it assumes it is due to the pages
      being mapped, locked or dirty and does not care.  With this patch, an
      application using fadvise() correctly will be obeyed but there is a
      downside that a malicious application can force the kernel to send
      global IPIs and increase overhead.
      
      If accepted, I would like this to be considered as a -stable candidate.
      It's not an urgent issue but it's a system call that is not working as
      advertised which is weak.
      
      The following test program demonstrates the problem.  It should never
      report that pages are still resident but will without this patch.  It
      assumes that CPU 0 and 1 exist.
      
      int main() {
      	int fd;
      	int pagesize = getpagesize();
      	ssize_t written = 0, expected;
      	char *buf;
      	unsigned char *vec;
      	int resident, i;
      	cpu_set_t set;
      
      	/* Prepare a buffer for writing */
      	expected = FILESIZE_PAGES * pagesize;
      	buf = malloc(expected + 1);
      	if (buf == NULL) {
      		printf("ENOMEM\n");
      		exit(EXIT_FAILURE);
      	}
      	buf[expected] = 0;
      	memset(buf, 'a', expected);
      
      	/* Prepare the mincore vec */
      	vec = malloc(FILESIZE_PAGES);
      	if (vec == NULL) {
      		printf("ENOMEM\n");
      		exit(EXIT_FAILURE);
      	}
      
      	/* Bind ourselves to CPU 0 */
      	CPU_ZERO(&set);
      	CPU_SET(0, &set);
      	if (sched_setaffinity(getpid(), sizeof(set), &set) == -1) {
      		perror("sched_setaffinity");
      		exit(EXIT_FAILURE);
      	}
      
      	/* open file, unlink and write buffer */
      	fd = open("fadvise-test-file", O_CREAT|O_EXCL|O_RDWR);
      	if (fd == -1) {
      		perror("open");
      		exit(EXIT_FAILURE);
      	}
      	unlink("fadvise-test-file");
      	while (written < expected) {
      		ssize_t this_write;
      		this_write = write(fd, buf + written, expected - written);
      
      		if (this_write == -1) {
      			perror("write");
      			exit(EXIT_FAILURE);
      		}
      
      		written += this_write;
      	}
      	free(buf);
      
      	/*
      	 * Force ourselves to another CPU. If fadvise only flushes the local
      	 * CPUs pagevecs then the fadvise will fail to discard all file pages
      	 */
      	CPU_ZERO(&set);
      	CPU_SET(1, &set);
      	if (sched_setaffinity(getpid(), sizeof(set), &set) == -1) {
      		perror("sched_setaffinity");
      		exit(EXIT_FAILURE);
      	}
      
      	/* sync and fadvise to discard the page cache */
      	fsync(fd);
      	if (posix_fadvise(fd, 0, expected, POSIX_FADV_DONTNEED) == -1) {
      		perror("posix_fadvise");
      		exit(EXIT_FAILURE);
      	}
      
      	/* map the file and use mincore to see which parts of it are resident */
      	buf = mmap(NULL, expected, PROT_READ, MAP_SHARED, fd, 0);
      	if (buf == NULL) {
      		perror("mmap");
      		exit(EXIT_FAILURE);
      	}
      	if (mincore(buf, expected, vec) == -1) {
      		perror("mincore");
      		exit(EXIT_FAILURE);
      	}
      
      	/* Check residency */
      	for (i = 0, resident = 0; i < FILESIZE_PAGES; i++) {
      		if (vec[i])
      			resident++;
      	}
      	if (resident != 0) {
      		printf("Nr unexpected pages resident: %d\n", resident);
      		exit(EXIT_FAILURE);
      	}
      
      	munmap(buf, expected);
      	close(fd);
      	free(vec);
      	exit(EXIT_SUCCESS);
      }
      Signed-off-by: default avatarMel Gorman <mgorman@suse.de>
      Reported-by: default avatarRob van der Heij <rvdheij@gmail.com>
      Tested-by: default avatarRob van der Heij <rvdheij@gmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      67d46b29