03 Nov, 2011

1 commit

  • Michel while working on the working set estimation code, noticed that
    calling get_page_unless_zero() on a random pfn_to_page(random_pfn)
    wasn't safe, if the pfn ended up being a tail page of a transparent
    hugepage under splitting by __split_huge_page_refcount().

    He then found the problem could also theoretically materialize with
    page_cache_get_speculative() during the speculative radix tree lookups
    that uses get_page_unless_zero() in SMP if the radix tree page is freed
    and reallocated and get_user_pages is called on it before
    page_cache_get_speculative has a chance to call get_page_unless_zero().

    So the best way to fix the problem is to keep page_tail->_count zero at
    all times. This will guarantee that get_page_unless_zero() can never
    succeed on any tail page. page_tail->_mapcount is guaranteed zero and
    is unused for all tail pages of a compound page, so we can simply
    account the tail page references there and transfer them to
    tail_page->_count in __split_huge_page_refcount() (in addition to the
    head_page->_mapcount).

    While debugging this s/_count/_mapcount/ change I also noticed get_page is
    called by direct-io.c on pages returned by get_user_pages. That wasn't
    entirely safe because the two atomic_inc in get_page weren't atomic. As
    opposed to other get_user_page users like secondary-MMU page fault to
    establish the shadow pagetables would never call any superflous get_page
    after get_user_page returns. It's safer to make get_page universally safe
    for tail pages and to use get_page_foll() within follow_page (inside
    get_user_pages()). get_page_foll() is safe to do the refcounting for tail
    pages without taking any locks because it is run within PT lock protected
    critical sections (PT lock for pte and page_table_lock for
    pmd_trans_huge).

    The standard get_page() as invoked by direct-io instead will now take
    the compound_lock but still only for tail pages. The direct-io paths
    are usually I/O bound and the compound_lock is per THP so very
    finegrined, so there's no risk of scalability issues with it. A simple
    direct-io benchmarks with all lockdep prove locking and spinlock
    debugging infrastructure enabled shows identical performance and no
    overhead. So it's worth it. Ideally direct-io should stop calling
    get_page() on pages returned by get_user_pages(). The spinlock in
    get_page() is already optimized away for no-THP builds but doing
    get_page() on tail pages returned by GUP is generally a rare operation
    and usually only run in I/O paths.

    This new refcounting on page_tail->_mapcount in addition to avoiding new
    RCU critical sections will also allow the working set estimation code to
    work without any further complexity associated to the tail page
    refcounting with THP.

    Signed-off-by: Andrea Arcangeli
    Reported-by: Michel Lespinasse
    Reviewed-by: Michel Lespinasse
    Reviewed-by: Minchan Kim
    Cc: Peter Zijlstra
    Cc: Hugh Dickins
    Cc: Johannes Weiner
    Cc: Rik van Riel
    Cc: Mel Gorman
    Cc: KOSAKI Motohiro
    Cc: Benjamin Herrenschmidt
    Cc: David Gibson
    Cc:
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrea Arcangeli
     

02 Nov, 2011

10 commits

  • * 'next/dt' of git://git.linaro.org/people/arnd/arm-soc:
    ARM: gic: use module.h instead of export.h
    ARM: gic: fix irq_alloc_descs handling for sparse irq
    ARM: gic: add OF based initialization
    ARM: gic: add irq_domain support
    irq: support domains with non-zero hwirq base
    of/irq: introduce of_irq_init
    ARM: at91: add at91sam9g20 and Calao USB A9G20 DT support
    ARM: at91: dt: at91sam9g45 family and board device tree files
    arm/mx5: add device tree support for imx51 babbage
    arm/mx5: add device tree support for imx53 boards
    ARM: msm: Add devicetree support for msm8660-surf
    msm_serial: Add devicetree support
    msm_serial: Use relative resources for iomem

    Fix up conflicts in arch/arm/mach-at91/{at91sam9260.c,at91sam9g45.c}

    Linus Torvalds
     
  • * 'next/cleanup2' of git://git.linaro.org/people/arnd/arm-soc: (31 commits)
    ARM: OMAP: Warn if omap_ioremap is called before SoC detection
    ARM: OMAP: Move set_globals initialization to happen in init_early
    ARM: OMAP: Map SRAM later on with ioremap_exec()
    ARM: OMAP: Remove calls to SRAM allocations for framebuffer
    ARM: OMAP: Avoid cpu_is_omapxxxx usage until map_io is done
    ARM: OMAP1: Use generic map_io, init_early and init_irq
    arm/dts: OMAP3+: Add mpu, dsp and iva nodes
    arm/dts: OMAP4: Add a main ocp entry bound to l3-noc driver
    ARM: OMAP2+: l3-noc: Add support for device-tree
    ARM: OMAP2+: board-generic: Add i2c static init
    ARM: OMAP2+: board-generic: Add DT support to generic board
    arm/dts: Add support for OMAP3 Beagle board
    arm/dts: Add initial device tree support for OMAP3 SoC
    arm/dts: Add support for OMAP4 SDP board
    arm/dts: Add support for OMAP4 PandaBoard
    arm/dts: Add initial device tree support for OMAP4 SoC
    ARM: OMAP: omap_device: Add a method to build an omap_device from a DT node
    ARM: OMAP: omap_device: Add omap_device_[alloc|delete] for DT integration
    of: Add helpers to get one string in multiple strings property
    ARM: OMAP2+: devices: Remove all omap_device_pm_latency structures
    ...

    Fix up trivial header file conflicts in arch/arm/mach-omap2/board-generic.c

    Linus Torvalds
     
  • * 'next/pm' of git://git.linaro.org/people/arnd/arm-soc: (66 commits)
    ARM: CSR: PM: use outer_resume to resume L2 cache
    ARM: CSR: call l2x0_of_init to init L2 cache of SiRFprimaII
    ARM: OMAP: voltage: voltage layer present, even when CONFIG_PM=n
    ARM: CSR: PM: add sleep entry for SiRFprimaII
    ARM: CSR: PM: save/restore irq status in suspend cycle
    ARM: CSR: PM: save/restore timer status in suspend cycle
    OMAP4: PM: TWL6030: add cmd register
    OMAP4: PM: TWL6030: fix ON/RET/OFF voltages
    OMAP4: PM: TWL6030: address 0V conversions
    OMAP4: PM: TWL6030: fix uv to voltage for >0x39
    OMAP4: PM: TWL6030: fix voltage conversion formula
    omap: voltage: add a stub header file for external/regulator use
    OMAP2+: VC: more registers are per-channel starting with OMAP5
    OMAP3+: voltage: update nominal voltage in voltdm_scale() not VC post-scale
    OMAP3+: voltage: rename omap_voltage_get_nom_volt -> voltdm_get_voltage
    OMAP3+: voltdm: final removal of omap_vdd_info
    OMAP3+: voltage: move/rename curr_volt from vdd_info into struct voltagedomain
    OMAP3+: voltage: rename scale and reset functions using voltdm_ prefix
    OMAP3+: VP: combine setting init voltage into common function
    OMAP3+: VP: remove unused omap_vp_get_curr_volt()
    ...

    Fix up trivial conflict in arch/arm/mach-prima2/l2x0.c (code removal vs
    edit)

    Linus Torvalds
     
  • * 'next/timer' of git://git.linaro.org/people/arnd/arm-soc:
    clocksource: fixup ux500 build problems
    ARM: omap: use __devexit_p in dmtimer driver
    ARM: ux500: Reprogram timers upon resume
    ARM: plat-nomadik: timer: Export reset functions
    ARM: plat-nomadik: timer: Add support for periodic timers
    ARM: ux500: Move timer code to separate file
    ARM: ux500: add support for clocksource DBX500 PRCMU
    clocksource: add DBX500 PRCMU Timer support
    ARM: plat-nomadik: MTU sched_clock as an option
    ARM: OMAP: dmtimer: add error handling to export APIs
    ARM: OMAP: dmtimer: low-power mode support
    ARM: OMAP: dmtimer: skip reserved timers
    ARM: OMAP: dmtimer: pm_runtime support
    ARM: OMAP: dmtimer: switch-over to platform device driver
    ARM: OMAP: dmtimer: platform driver
    ARM: OMAP2+: dmtimer: convert to platform devices
    ARM: OMAP1: dmtimer: conversion to platform devices
    ARM: OMAP2+: dmtimer: add device names to flck nodes
    ARM: OMAP: Add support for dmtimer v2 ip

    Linus Torvalds
     
  • * 'for-linus/i2c-3.2' of git://git.fluff.org/bjdooks/linux: (47 commits)
    i2c-s3c2410: Add device tree support
    i2c-s3c2410: Keep a copy of platform data and use it
    i2c-nomadik: cosmetic coding style corrections
    i2c-au1550: dev_pm_ops conversion
    i2c-au1550: increase timeout waiting for master done
    i2c-au1550: remove unused ack_timeout
    i2c-au1550: remove usage of volatile keyword
    i2c-tegra: __iomem annotation fix
    i2c-eg20t: Add initialize processing in case i2c-error occurs
    i2c-eg20t: Fix flag setting issue
    i2c-eg20t: add stop sequence in case wait-event timeout occurs
    i2c-eg20t: Separate error processing
    i2c-eg20t: Fix 10bit access issue
    i2c-eg20t: Modify returned value s32 to long
    i2c-eg20t: Fix bus-idle waiting issue
    i2c-designware: Fix PCI core warning on suspend/resume
    i2c-designware: Add runtime power management support
    i2c-designware: Add support for Designware core behind PCI devices.
    i2c-designware: Push all register reads/writes into the core code.
    i2c-designware: Support multiple cores using same ISR
    ...

    Linus Torvalds
     
  • * 'for-linus' of git://opensource.wolfsonmicro.com/regulator: (22 commits)
    regulator: Constify constraints name
    regulator: Fix possible nullpointer dereference in regulator_enable()
    regulator: gpio-regulator add dependency on GENERIC_GPIO
    regulator: Add module.h include to gpio-regulator
    regulator: Add driver for gpio-controlled regulators
    regulator: remove duplicate REG_CTRL2 defines in tps65023
    regulator: Clarify documentation for regulator-regulator supplies
    regulator: Fix some bitrot in the machine driver documentation
    regulator: tps65023: Added support for the similiar TPS65020 chip
    regulator: tps65023: Setting correct core regulator for tps65021
    regulator: tps65023: Set missing bit for update core-voltage
    regulator: tps65023: Fixes i2c configuration issues
    regulator: Add debugfs file showing the supply map table
    regulator: tps6586x: add SMx slew rate setting
    regulator: tps65023: Fixes i2c configuration issues
    regulator: tps6507x: Remove num_voltages array
    regulator: max8952: removed unused mutex.
    regulator: fix regulator/consumer.h kernel-doc warning
    regulator: Ensure enough enable time for max8649
    regulator: 88pm8607: Fix off-by-one value range checking in the case of no id is matched
    ...

    Linus Torvalds
     
  • * 'pstore' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux:
    pstore: make pstore write function return normal success/fail value
    pstore: change mutex locking to spin_locks
    pstore: defer inserting OOPS entries into pstore

    Linus Torvalds
     
  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband: (62 commits)
    mlx4_core: Deprecate log_num_vlan module param
    IB/mlx4: Don't set VLAN in IBoE WQEs' control segment
    IB/mlx4: Enable 4K mtu for IBoE
    RDMA/cxgb4: Mark QP in error before disabling the queue in firmware
    RDMA/cxgb4: Serialize calls to CQ's comp_handler
    RDMA/cxgb3: Serialize calls to CQ's comp_handler
    IB/qib: Fix issue with link states and QSFP cables
    IB/mlx4: Configure extended active speeds
    mlx4_core: Add extended port capabilities support
    IB/qib: Hold links until tuning data is available
    IB/qib: Clean up checkpatch issue
    IB/qib: Remove s_lock around header validation
    IB/qib: Precompute timeout jiffies to optimize latency
    IB/qib: Use RCU for qpn lookup
    IB/qib: Eliminate divide/mod in converting idx to egr buf pointer
    IB/qib: Decode path MTU optimization
    IB/qib: Optimize RC/UC code by IB operation
    IPoIB: Use the right function to do DMA unmap pages
    RDMA/cxgb4: Use correct QID in insert_recv_cqe()
    RDMA/cxgb4: Make sure flush CQ entries are collected on connection close
    ...

    Linus Torvalds
     
  • …sc', 'mlx4', 'misc', 'nes', 'qib' and 'xrc' into for-next

    Roland Dreier
     
  • * git://github.com/herbertx/crypto: (48 commits)
    crypto: user - Depend on NET instead of selecting it
    crypto: user - Add dependency on NET
    crypto: talitos - handle descriptor not found in error path
    crypto: user - Initialise match in crypto_alg_match
    crypto: testmgr - add twofish tests
    crypto: testmgr - add blowfish test-vectors
    crypto: Make hifn_795x build depend on !ARCH_DMA_ADDR_T_64BIT
    crypto: twofish-x86_64-3way - fix ctr blocksize to 1
    crypto: blowfish-x86_64 - fix ctr blocksize to 1
    crypto: whirlpool - count rounds from 0
    crypto: Add userspace report for compress type algorithms
    crypto: Add userspace report for cipher type algorithms
    crypto: Add userspace report for rng type algorithms
    crypto: Add userspace report for pcompress type algorithms
    crypto: Add userspace report for nivaead type algorithms
    crypto: Add userspace report for aead type algorithms
    crypto: Add userspace report for givcipher type algorithms
    crypto: Add userspace report for ablkcipher type algorithms
    crypto: Add userspace report for blkcipher type algorithms
    crypto: Add userspace report for ahash type algorithms
    ...

    Linus Torvalds
     

01 Nov, 2011

29 commits

  • This is the fifth version of the patchset (with one tiny whitespace fix)
    to the Linux kernel to support the Qualcomm Hexagon architecture.

    Between now and the next pull requests, Richard Kuo should have his key
    signed, etc., and should be back on kernel.org. In the meantime, this
    got merged as a emailed patch-series.

    * Hexagon: (36 commits)
    Add extra arch overrides to asm-generic/checksum.h
    Hexagon: Add self to MAINTAINERS
    Hexagon: Add basic stacktrace functionality for Hexagon architecture.
    Hexagon: Add configuration and makefiles for the Hexagon architecture.
    Hexagon: Comet platform support
    Hexagon: kgdb support files
    Hexagon: Add page-fault support.
    Hexagon: Add page table header files & etc.
    Hexagon: Add ioremap support
    Hexagon: Provide DMA implementation
    Hexagon: Implement basic TLB management routines for Hexagon.
    Hexagon: Implement basic cache-flush support
    Hexagon: Provide basic implementation and/or stubs for I/O routines.
    Hexagon: Add user access functions
    Hexagon: Add locking types and functions
    Hexagon: Add SMP support
    Hexagon: Provide basic debugging and system trap support.
    Hexagon: Add ptrace support
    Hexagon: Add time and timer functions
    Hexagon: Add interrupts
    ...

    Linus Torvalds
     
  • There are plausible reasons for architectures to provide their own
    versions of csum_partial_copy_nocheck and csum_tcpudp_magic.
    By protecting these, the architecture can still re-use the
    asm-generic checksum.h, instead of copying it.

    Signed-off-by: Linas Vepstas
    Acked-by: Arnd Bergmann
    Signed-off-by: Richard Kuo
    Signed-off-by: Linus Torvalds

    Linas Vepstas
     
  • Signed-off-by: Richard Kuo
    Acked-by: Arnd Bergmann
    Signed-off-by: Linus Torvalds

    Richard Kuo
     
  • Quoth Andrew:

    - Most of MM. Still waiting for the poweroc guys to get off their
    butts and review some threaded hugepages patches.

    - alpha

    - vfs bits

    - drivers/misc

    - a few core kerenl tweaks

    - printk() features

    - MAINTAINERS updates

    - backlight merge

    - leds merge

    - various lib/ updates

    - checkpatch updates

    * akpm: (127 commits)
    epoll: fix spurious lockdep warnings
    checkpatch: add a --strict check for utf-8 in commit logs
    kernel.h/checkpatch: mark strict_strto and simple_strto as obsolete
    llist-return-whether-list-is-empty-before-adding-in-llist_add-fix
    wireless: at76c50x: follow rename pack_hex_byte to hex_byte_pack
    fat: follow rename pack_hex_byte() to hex_byte_pack()
    security: follow rename pack_hex_byte() to hex_byte_pack()
    kgdb: follow rename pack_hex_byte() to hex_byte_pack()
    lib: rename pack_hex_byte() to hex_byte_pack()
    lib/string.c: fix strim() semantics for strings that have only blanks
    lib/idr.c: fix comment for ida_get_new_above()
    lib/percpu_counter.c: enclose hotplug only variables in hotplug ifdef
    lib/bitmap.c: quiet sparse noise about address space
    lib/spinlock_debug.c: print owner on spinlock lockup
    lib/kstrtox: common code between kstrto*() and simple_strto*() functions
    drivers/leds/leds-lp5521.c: check if reset is successful
    leds: turn the blink_timer off before starting to blink
    leds: save the delay values after a successful call to blink_set()
    drivers/leds/leds-gpio.c: use gpio_get_value_cansleep() when initializing
    drivers/leds/leds-lm3530.c: add __devexit_p where needed
    ...

    Linus Torvalds
     
  • Mark obsolete/deprecated strict_strto and simple_strto functions
    and macros as obsolete.

    Update checkpatch to warn about their use.

    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • clarify comment

    Cc: Huang Ying
    Cc: Mathieu Desnoyers
    Cc: Peter Zijlstra
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     
  • As suggested by Andrew Morton in [1] there is better to have most
    significant part first in the function name.

    [1] https://lkml.org/lkml/2011/9/20/22

    There is no functional change.

    Signed-off-by: Andy Shevchenko
    Cc: Jesper Nilsson
    Cc: David Howells
    Cc: Koichi Yasutake
    Cc: Jason Wessel
    Cc: Mimi Zohar
    Cc: James Morris
    Cc: OGAWA Hirofumi
    Cc: "John W. Linville"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andy Shevchenko
     
  • Use the platform_data include directory for the TPU LED driver, as
    suggested by Paul Mundt.

    Signed-off-by: Magnus Damm
    Cc: Paul Mundt
    Cc: Richard Purdie
    Cc: Grant Likely
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Magnus Damm
     
  • Add V2 of the LED driver for a single timer channel for the TPU hardware
    block commonly found in Renesas SoCs.

    The driver has been written with optimal Power Management in mind, so to
    save power the LED is driven as a regular GPIO pin in case of maximum
    brightness and power off which allows the TPU hardware to be idle and
    which in turn allows the clocks to be stopped and the power domain to be
    turned off transparently.

    Any other brightness level requires use of the TPU hardware in PWM mode.
    TPU hardware device clocks and power are managed through Runtime PM.
    System suspend and resume is known to be working - during suspend the LED
    is set to off by the generic LED code.

    The TPU hardware timer is equipeed with a 16-bit counter together with an
    up-to-divide-by-64 prescaler which makes the hardware suitable for
    brightness control. Hardware blink is unsupported.

    The LED PWM waveform has been verified with a Fluke 123 Scope meter on a
    sh7372 Mackerel board. Tested with experimental sh7372 A3SP power domain
    patches. Platform device bind/unbind tested ok.

    V2 has been tested on the DS2 LED of the sh73a0-based AG5EVM.

    [axel.lin@gmail.com: include linux/module.h]
    Signed-off-by: Magnus Damm
    Cc: Paul Mundt
    Cc: Richard Purdie
    Cc: Grant Likely
    Signed-off-by: Axel Lin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Magnus Damm
     
  • The regulator support in the l4f00242t03 is very non-idiomatic. Rather
    than requesting the regulators based on the device name and the supply
    names used by the device the driver requires boards to pass system
    specific supply names around through platform data. The driver also
    conditionally requests the regulators based on this platform data, adding
    unneeded conditional code to the driver.

    Fix this by removing the platform data and converting to the standard
    idiom, also updating all in tree users of the driver. As no datasheet
    appears to be available for the LCD I'm guessing the names for the
    supplies based on the existing users and I've no ability to do anything
    more than compile test.

    The use of regulator_set_voltage() in the driver is also problematic,
    since fixed voltages are required the expectation would be that the
    voltages would be fixed in the constraints set by the machines rather than
    manually configured by the driver, but is less problematic.

    Signed-off-by: Mark Brown
    Tested-by: Fabio Estevam
    Cc: Richard Purdie
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mark Brown
     
  • Standardize the style for compiler based printf format verification.
    Standardized the location of __printf too.

    Done via script and a little typing.

    $ grep -rPl --include=*.[ch] -w "__attribute__" * | \
    grep -vP "^(tools|scripts|include/linux/compiler-gcc.h)" | \
    xargs perl -n -i -e 'local $/; while (<>) { s/\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf\s*,\s*(.+)\s*,\s*(.+)\s*\)\s*\)\s*\)/__printf($1, $2)/g ; print; }'

    [akpm@linux-foundation.org: revert arch bits]
    Signed-off-by: Joe Perches
    Cc: "Kirill A. Shutemov"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • The regulator API contains a range of features for stubbing itself out
    when not in use and for transparently restricting the actual effect of
    regulator API calls where they can't be supported on a particular system
    so that drivers don't need to individually implement this. Simplify the
    driver slightly by making use of this idiom.

    The only in tree user is ecovec24 which does not use the regulator API.

    Signed-off-by: Mark Brown
    Cc: Éric Piel
    Cc: Ilkka Koskinen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mark Brown
     
  • There's no compact_zone_order() user outside file scope, so make it static.

    Signed-off-by: Kyungmin Park
    Acked-by: David Rientjes
    Reviewed-by: Minchan Kim
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kyungmin Park
     
  • The callback must not return -1 when nr_to_scan is zero. Fix the bug in
    fs/super.c and add this requirement to the callback specification.

    Signed-off-by: Mikulas Patocka
    Cc: Dave Chinner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mikulas Patocka
     
  • Add __attribute__((format (printf...) to the function to validate format
    and arguments. Use vsprintf extension %pV to avoid any possible message
    interleaving. Coalesce format string. Convert printks/pr_warning to
    pr_warn.

    [akpm@linux-foundation.org: use the __printf() macro]
    Signed-off-by: Joe Perches
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • On NOMMU architectures, if physical memory doesn't start from 0,
    ARCH_PFN_OFFSET is defined to generate page index in mem_map array.
    Because virtual address is equal to physical address, PAGE_OFFSET is
    always 0. virt_to_page and page_to_virt should not index page by
    PAGE_OFFSET directly.

    Signed-off-by: Sonic Zhang
    Cc: Greg Ungerer
    Cc: Geert Uytterhoeven
    Cc: David Howells
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sonic Zhang
     
  • This adds THP support to mremap (decreases the number of split_huge_page()
    calls).

    Here are also some benchmarks with a proggy like this:

    ===
    #define _GNU_SOURCE
    #include
    #include
    #include
    #include
    #include

    #define SIZE (5UL*1024*1024*1024)

    int main()
    {
    static struct timeval oldstamp, newstamp;
    long diffsec;
    char *p, *p2, *p3, *p4;
    if (posix_memalign((void **)&p, 2*1024*1024, SIZE))
    perror("memalign"), exit(1);
    if (posix_memalign((void **)&p2, 2*1024*1024, SIZE))
    perror("memalign"), exit(1);
    if (posix_memalign((void **)&p3, 2*1024*1024, 4096))
    perror("memalign"), exit(1);

    memset(p, 0xff, SIZE);
    memset(p2, 0xff, SIZE);
    memset(p3, 0x77, 4096);
    gettimeofday(&oldstamp, NULL);
    p4 = mremap(p, SIZE, SIZE, MREMAP_FIXED|MREMAP_MAYMOVE, p3);
    gettimeofday(&newstamp, NULL);
    diffsec = newstamp.tv_sec - oldstamp.tv_sec;
    diffsec = newstamp.tv_usec - oldstamp.tv_usec + 1000000 * diffsec;
    printf("usec %ld\n", diffsec);
    if (p == MAP_FAILED || p4 != p3)
    //if (p == MAP_FAILED)
    perror("mremap"), exit(1);
    if (memcmp(p4, p2, SIZE))
    printf("mremap bug\n"), exit(1);
    printf("ok\n");

    return 0;
    }
    ===

    THP on

    Performance counter stats for './largepage13' (3 runs):

    69195836 dTLB-loads ( +- 3.546% ) (scaled from 50.30%)
    60708 dTLB-load-misses ( +- 11.776% ) (scaled from 52.62%)
    676266476 dTLB-stores ( +- 5.654% ) (scaled from 69.54%)
    29856 dTLB-store-misses ( +- 4.081% ) (scaled from 89.22%)
    1055848782 iTLB-loads ( +- 4.526% ) (scaled from 80.18%)
    8689 iTLB-load-misses ( +- 2.987% ) (scaled from 58.20%)

    7.314454164 seconds time elapsed ( +- 0.023% )

    THP off

    Performance counter stats for './largepage13' (3 runs):

    1967379311 dTLB-loads ( +- 0.506% ) (scaled from 60.59%)
    9238687 dTLB-load-misses ( +- 22.547% ) (scaled from 61.87%)
    2014239444 dTLB-stores ( +- 0.692% ) (scaled from 60.40%)
    3312335 dTLB-store-misses ( +- 7.304% ) (scaled from 67.60%)
    6764372065 iTLB-loads ( +- 0.925% ) (scaled from 79.00%)
    8202 iTLB-load-misses ( +- 0.475% ) (scaled from 70.55%)

    9.693655243 seconds time elapsed ( +- 0.069% )

    grep thp /proc/vmstat
    thp_fault_alloc 35849
    thp_fault_fallback 0
    thp_collapse_alloc 3
    thp_collapse_alloc_failed 0
    thp_split 0

    thp_split 0 confirms no thp split despite plenty of hugepages allocated.

    The measurement of only the mremap time (so excluding the 3 long
    memset and final long 10GB memory accessing memcmp):

    THP on

    usec 14824
    usec 14862
    usec 14859

    THP off

    usec 256416
    usec 255981
    usec 255847

    With an older kernel without the mremap optimizations (the below patch
    optimizes the non THP version too).

    THP on

    usec 392107
    usec 390237
    usec 404124

    THP off

    usec 444294
    usec 445237
    usec 445820

    I guess with a threaded program that sends more IPI on large SMP it'd
    create an even larger difference.

    All debug options are off except DEBUG_VM to avoid skewing the
    results.

    The only problem for native 2M mremap like it happens above both the
    source and destination address must be 2M aligned or the hugepmd can't be
    moved without a split but that is an hardware limitation.

    [akpm@linux-foundation.org: coding-style nitpicking]
    Signed-off-by: Andrea Arcangeli
    Acked-by: Johannes Weiner
    Acked-by: Mel Gorman
    Acked-by: Rik van Riel
    Cc: Hugh Dickins
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrea Arcangeli
     
  • SPARC32 require access to the start address. Add a new helper
    memblock_start_of_DRAM() to give access to the address of the first
    memblock - which contains the lowest address.

    The awkward name was chosen to match the already present
    memblock_end_of_DRAM().

    Signed-off-by: Sam Ravnborg
    Cc: "David S. Miller"
    Cc: Yinghai Lu
    Acked-by: Tejun Heo
    Cc: "H. Peter Anvin"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sam Ravnborg
     
  • The /proc/vmallocinfo shows information about vmalloc allocations in
    vmlist that is a linklist of vm_struct. It, however, may access pages
    field of vm_struct where a page was not allocated. This results in a null
    pointer access and leads to a kernel panic.

    Why this happens: In __vmalloc_node_range() called from vmalloc(), newly
    allocated vm_struct is added to vmlist at __get_vm_area_node() and then,
    some fields of vm_struct such as nr_pages and pages are set at
    __vmalloc_area_node(). In other words, it is added to vmlist before it is
    fully initialized. At the same time, when the /proc/vmallocinfo is read,
    it accesses the pages field of vm_struct according to the nr_pages field
    at show_numa_info(). Thus, a null pointer access happens.

    The patch adds the newly allocated vm_struct to the vmlist *after* it is
    fully initialized. So, it can avoid accessing the pages field with
    unallocated page when show_numa_info() is called.

    Signed-off-by: Mitsuo Hayasaka
    Cc: Andrew Morton
    Cc: David Rientjes
    Cc: Namhyung Kim
    Cc: "Paul E. McKenney"
    Cc: Jeremy Fitzhardinge
    Cc:
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mitsuo Hayasaka
     
  • memchr_inv() is mainly used to check whether the whole buffer is filled
    with just a specified byte.

    The function name and prototype are stolen from logfs and the
    implementation is from SLUB.

    Signed-off-by: Akinobu Mita
    Acked-by: Christoph Lameter
    Acked-by: Pekka Enberg
    Cc: Matt Mackall
    Acked-by: Joern Engel
    Cc: Marcin Slusarz
    Cc: Eric Dumazet
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Akinobu Mita
     
  • When direct reclaim encounters a dirty page, it gets recycled around the
    LRU for another cycle. This patch marks the page PageReclaim similar to
    deactivate_page() so that the page gets reclaimed almost immediately after
    the page gets cleaned. This is to avoid reclaiming clean pages that are
    younger than a dirty page encountered at the end of the LRU that might
    have been something like a use-once page.

    Signed-off-by: Mel Gorman
    Acked-by: Johannes Weiner
    Cc: Dave Chinner
    Cc: Christoph Hellwig
    Cc: Wu Fengguang
    Cc: Jan Kara
    Cc: Minchan Kim
    Cc: Rik van Riel
    Cc: Mel Gorman
    Cc: Alex Elder
    Cc: Theodore Ts'o
    Cc: Chris Mason
    Cc: Dave Hansen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mel Gorman
     
  • Testing from the XFS folk revealed that there is still too much I/O from
    the end of the LRU in kswapd. Previously it was considered acceptable by
    VM people for a small number of pages to be written back from reclaim with
    testing generally showing about 0.3% of pages reclaimed were written back
    (higher if memory was low). That writing back a small number of pages is
    ok has been heavily disputed for quite some time and Dave Chinner
    explained it well;

    It doesn't have to be a very high number to be a problem. IO
    is orders of magnitude slower than the CPU time it takes to
    flush a page, so the cost of making a bad flush decision is
    very high. And single page writeback from the LRU is almost
    always a bad flush decision.

    To complicate matters, filesystems respond very differently to requests
    from reclaim according to Christoph Hellwig;

    xfs tries to write it back if the requester is kswapd
    ext4 ignores the request if it's a delayed allocation
    btrfs ignores the request

    As a result, each filesystem has different performance characteristics
    when under memory pressure and there are many pages being dirtied. In
    some cases, the request is ignored entirely so the VM cannot depend on the
    IO being dispatched.

    The objective of this series is to reduce writing of filesystem-backed
    pages from reclaim, play nicely with writeback that is already in progress
    and throttle reclaim appropriately when writeback pages are encountered.
    The assumption is that the flushers will always write pages faster than if
    reclaim issues the IO.

    A secondary goal is to avoid the problem whereby direct reclaim splices
    two potentially deep call stacks together.

    There is a potential new problem as reclaim has less control over how long
    before a page in a particularly zone or container is cleaned and direct
    reclaimers depend on kswapd or flusher threads to do the necessary work.
    However, as filesystems sometimes ignore direct reclaim requests already,
    it is not expected to be a serious issue.

    Patch 1 disables writeback of filesystem pages from direct reclaim
    entirely. Anonymous pages are still written.

    Patch 2 removes dead code in lumpy reclaim as it is no longer able
    to synchronously write pages. This hurts lumpy reclaim but
    there is an expectation that compaction is used for hugepage
    allocations these days and lumpy reclaim's days are numbered.

    Patches 3-4 add warnings to XFS and ext4 if called from
    direct reclaim. With patch 1, this "never happens" and is
    intended to catch regressions in this logic in the future.

    Patch 5 disables writeback of filesystem pages from kswapd unless
    the priority is raised to the point where kswapd is considered
    to be in trouble.

    Patch 6 throttles reclaimers if too many dirty pages are being
    encountered and the zones or backing devices are congested.

    Patch 7 invalidates dirty pages found at the end of the LRU so they
    are reclaimed quickly after being written back rather than
    waiting for a reclaimer to find them

    I consider this series to be orthogonal to the writeback work but it is
    worth noting that the writeback work affects the viability of patch 8 in
    particular.

    I tested this on ext4 and xfs using fs_mark, a simple writeback test based
    on dd and a micro benchmark that does a streaming write to a large mapping
    (exercises use-once LRU logic) followed by streaming writes to a mix of
    anonymous and file-backed mappings. The command line for fs_mark when
    botted with 512M looked something like

    ./fs_mark -d /tmp/fsmark-2676 -D 100 -N 150 -n 150 -L 25 -t 1 -S0 -s 10485760

    The number of files was adjusted depending on the amount of available
    memory so that the files created was about 3xRAM. For multiple threads,
    the -d switch is specified multiple times.

    The test machine is x86-64 with an older generation of AMD processor with
    4 cores. The underlying storage was 4 disks configured as RAID-0 as this
    was the best configuration of storage I had available. Swap is on a
    separate disk. Dirty ratio was tuned to 40% instead of the default of
    20%.

    Testing was run with and without monitors to both verify that the patches
    were operating as expected and that any performance gain was real and not
    due to interference from monitors.

    Here is a summary of results based on testing XFS.

    512M1P-xfs Files/s mean 32.69 ( 0.00%) 34.44 ( 5.08%)
    512M1P-xfs Elapsed Time fsmark 51.41 48.29
    512M1P-xfs Elapsed Time simple-wb 114.09 108.61
    512M1P-xfs Elapsed Time mmap-strm 113.46 109.34
    512M1P-xfs Kswapd efficiency fsmark 62% 63%
    512M1P-xfs Kswapd efficiency simple-wb 56% 61%
    512M1P-xfs Kswapd efficiency mmap-strm 44% 42%
    512M-xfs Files/s mean 30.78 ( 0.00%) 35.94 (14.36%)
    512M-xfs Elapsed Time fsmark 56.08 48.90
    512M-xfs Elapsed Time simple-wb 112.22 98.13
    512M-xfs Elapsed Time mmap-strm 219.15 196.67
    512M-xfs Kswapd efficiency fsmark 54% 56%
    512M-xfs Kswapd efficiency simple-wb 54% 55%
    512M-xfs Kswapd efficiency mmap-strm 45% 44%
    512M-4X-xfs Files/s mean 30.31 ( 0.00%) 33.33 ( 9.06%)
    512M-4X-xfs Elapsed Time fsmark 63.26 55.88
    512M-4X-xfs Elapsed Time simple-wb 100.90 90.25
    512M-4X-xfs Elapsed Time mmap-strm 261.73 255.38
    512M-4X-xfs Kswapd efficiency fsmark 49% 50%
    512M-4X-xfs Kswapd efficiency simple-wb 54% 56%
    512M-4X-xfs Kswapd efficiency mmap-strm 37% 36%
    512M-16X-xfs Files/s mean 60.89 ( 0.00%) 65.22 ( 6.64%)
    512M-16X-xfs Elapsed Time fsmark 67.47 58.25
    512M-16X-xfs Elapsed Time simple-wb 103.22 90.89
    512M-16X-xfs Elapsed Time mmap-strm 237.09 198.82
    512M-16X-xfs Kswapd efficiency fsmark 45% 46%
    512M-16X-xfs Kswapd efficiency simple-wb 53% 55%
    512M-16X-xfs Kswapd efficiency mmap-strm 33% 33%

    Up until 512-4X, the FSmark improvements were statistically significant.
    For the 4X and 16X tests the results were within standard deviations but
    just barely. The time to completion for all tests is improved which is an
    important result. In general, kswapd efficiency is not affected by
    skipping dirty pages.

    1024M1P-xfs Files/s mean 39.09 ( 0.00%) 41.15 ( 5.01%)
    1024M1P-xfs Elapsed Time fsmark 84.14 80.41
    1024M1P-xfs Elapsed Time simple-wb 210.77 184.78
    1024M1P-xfs Elapsed Time mmap-strm 162.00 160.34
    1024M1P-xfs Kswapd efficiency fsmark 69% 75%
    1024M1P-xfs Kswapd efficiency simple-wb 71% 77%
    1024M1P-xfs Kswapd efficiency mmap-strm 43% 44%
    1024M-xfs Files/s mean 35.45 ( 0.00%) 37.00 ( 4.19%)
    1024M-xfs Elapsed Time fsmark 94.59 91.00
    1024M-xfs Elapsed Time simple-wb 229.84 195.08
    1024M-xfs Elapsed Time mmap-strm 405.38 440.29
    1024M-xfs Kswapd efficiency fsmark 79% 71%
    1024M-xfs Kswapd efficiency simple-wb 74% 74%
    1024M-xfs Kswapd efficiency mmap-strm 39% 42%
    1024M-4X-xfs Files/s mean 32.63 ( 0.00%) 35.05 ( 6.90%)
    1024M-4X-xfs Elapsed Time fsmark 103.33 97.74
    1024M-4X-xfs Elapsed Time simple-wb 204.48 178.57
    1024M-4X-xfs Elapsed Time mmap-strm 528.38 511.88
    1024M-4X-xfs Kswapd efficiency fsmark 81% 70%
    1024M-4X-xfs Kswapd efficiency simple-wb 73% 72%
    1024M-4X-xfs Kswapd efficiency mmap-strm 39% 38%
    1024M-16X-xfs Files/s mean 42.65 ( 0.00%) 42.97 ( 0.74%)
    1024M-16X-xfs Elapsed Time fsmark 103.11 99.11
    1024M-16X-xfs Elapsed Time simple-wb 200.83 178.24
    1024M-16X-xfs Elapsed Time mmap-strm 397.35 459.82
    1024M-16X-xfs Kswapd efficiency fsmark 84% 69%
    1024M-16X-xfs Kswapd efficiency simple-wb 74% 73%
    1024M-16X-xfs Kswapd efficiency mmap-strm 39% 40%

    All FSMark tests up to 16X had statistically significant improvements.
    For the most part, tests are completing faster with the exception of the
    streaming writes to a mixture of anonymous and file-backed mappings which
    were slower in two cases

    In the cases where the mmap-strm tests were slower, there was more
    swapping due to dirty pages being skipped. The number of additional pages
    swapped is almost identical to the fewer number of pages written from
    reclaim. In other words, roughly the same number of pages were reclaimed
    but swapping was slower. As the test is a bit unrealistic and stresses
    memory heavily, the small shift is acceptable.

    4608M1P-xfs Files/s mean 29.75 ( 0.00%) 30.96 ( 3.91%)
    4608M1P-xfs Elapsed Time fsmark 512.01 492.15
    4608M1P-xfs Elapsed Time simple-wb 618.18 566.24
    4608M1P-xfs Elapsed Time mmap-strm 488.05 465.07
    4608M1P-xfs Kswapd efficiency fsmark 93% 86%
    4608M1P-xfs Kswapd efficiency simple-wb 88% 84%
    4608M1P-xfs Kswapd efficiency mmap-strm 46% 45%
    4608M-xfs Files/s mean 27.60 ( 0.00%) 28.85 ( 4.33%)
    4608M-xfs Elapsed Time fsmark 555.96 532.34
    4608M-xfs Elapsed Time simple-wb 659.72 571.85
    4608M-xfs Elapsed Time mmap-strm 1082.57 1146.38
    4608M-xfs Kswapd efficiency fsmark 89% 91%
    4608M-xfs Kswapd efficiency simple-wb 88% 82%
    4608M-xfs Kswapd efficiency mmap-strm 48% 46%
    4608M-4X-xfs Files/s mean 26.00 ( 0.00%) 27.47 ( 5.35%)
    4608M-4X-xfs Elapsed Time fsmark 592.91 564.00
    4608M-4X-xfs Elapsed Time simple-wb 616.65 575.07
    4608M-4X-xfs Elapsed Time mmap-strm 1773.02 1631.53
    4608M-4X-xfs Kswapd efficiency fsmark 90% 94%
    4608M-4X-xfs Kswapd efficiency simple-wb 87% 82%
    4608M-4X-xfs Kswapd efficiency mmap-strm 43% 43%
    4608M-16X-xfs Files/s mean 26.07 ( 0.00%) 26.42 ( 1.32%)
    4608M-16X-xfs Elapsed Time fsmark 602.69 585.78
    4608M-16X-xfs Elapsed Time simple-wb 606.60 573.81
    4608M-16X-xfs Elapsed Time mmap-strm 1549.75 1441.86
    4608M-16X-xfs Kswapd efficiency fsmark 98% 98%
    4608M-16X-xfs Kswapd efficiency simple-wb 88% 82%
    4608M-16X-xfs Kswapd efficiency mmap-strm 44% 42%

    Unlike the other tests, the fsmark results are not statistically
    significant but the min and max times are both improved and for the most
    part, tests completed faster.

    There are other indications that this is an improvement as well. For
    example, in the vast majority of cases, there were fewer pages scanned by
    direct reclaim implying in many cases that stalls due to direct reclaim
    are reduced. KSwapd is scanning more due to skipping dirty pages which is
    unfortunate but the CPU usage is still acceptable

    In an earlier set of tests, I used blktrace and in almost all cases
    throughput throughout the entire test was higher. However, I ended up
    discarding those results as recording blktrace data was too heavy for my
    liking.

    On a laptop, I plugged in a USB stick and ran a similar tests of tests
    using it as backing storage. A desktop environment was running and for
    the entire duration of the tests, firefox and gnome terminal were
    launching and exiting to vaguely simulate a user.

    1024M-xfs Files/s mean 0.41 ( 0.00%) 0.44 ( 6.82%)
    1024M-xfs Elapsed Time fsmark 2053.52 1641.03
    1024M-xfs Elapsed Time simple-wb 1229.53 768.05
    1024M-xfs Elapsed Time mmap-strm 4126.44 4597.03
    1024M-xfs Kswapd efficiency fsmark 84% 85%
    1024M-xfs Kswapd efficiency simple-wb 92% 81%
    1024M-xfs Kswapd efficiency mmap-strm 60% 51%
    1024M-xfs Avg wait ms fsmark 5404.53 4473.87
    1024M-xfs Avg wait ms simple-wb 2541.35 1453.54
    1024M-xfs Avg wait ms mmap-strm 3400.25 3852.53

    The mmap-strm results were hurt because firefox launching had a tendency
    to push the test out of memory. On the postive side, firefox launched
    marginally faster with the patches applied. Time to completion for many
    tests was faster but more importantly - the "Avg wait" time as measured by
    iostat was far lower implying the system would be more responsive. It was
    also the case that "Avg wait ms" on the root filesystem was lower. I
    tested it manually and while the system felt slightly more responsive
    while copying data to a USB stick, it was marginal enough that it could be
    my imagination.

    This patch: do not writeback filesystem pages in direct reclaim.

    When kswapd is failing to keep zones above the min watermark, a process
    will enter direct reclaim in the same manner kswapd does. If a dirty page
    is encountered during the scan, this page is written to backing storage
    using mapping->writepage.

    This causes two problems. First, it can result in very deep call stacks,
    particularly if the target storage or filesystem are complex. Some
    filesystems ignore write requests from direct reclaim as a result. The
    second is that a single-page flush is inefficient in terms of IO. While
    there is an expectation that the elevator will merge requests, this does
    not always happen. Quoting Christoph Hellwig;

    The elevator has a relatively small window it can operate on,
    and can never fix up a bad large scale writeback pattern.

    This patch prevents direct reclaim writing back filesystem pages by
    checking if current is kswapd. Anonymous pages are still written to swap
    as there is not the equivalent of a flusher thread for anonymous pages.
    If the dirty pages cannot be written back, they are placed back on the LRU
    lists. There is now a direct dependency on dirty page balancing to
    prevent too many pages in the system being dirtied which would prevent
    reclaim making forward progress.

    Signed-off-by: Mel Gorman
    Reviewed-by: Minchan Kim
    Cc: Dave Chinner
    Cc: Christoph Hellwig
    Cc: Johannes Weiner
    Cc: Wu Fengguang
    Cc: Jan Kara
    Cc: Rik van Riel
    Cc: Mel Gorman
    Cc: Alex Elder
    Cc: Theodore Ts'o
    Cc: Chris Mason
    Cc: Dave Hansen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mel Gorman
     
  • Add comments to explain the page statistics field in the mm_struct.

    [akpm@linux-foundation.org: add missing ;]
    Signed-off-by: Christoph Lameter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Lameter
     
  • Some kernel components pin user space memory (infiniband and perf) (by
    increasing the page count) and account that memory as "mlocked".

    The difference between mlocking and pinning is:

    A. mlocked pages are marked with PG_mlocked and are exempt from
    swapping. Page migration may move them around though.
    They are kept on a special LRU list.

    B. Pinned pages cannot be moved because something needs to
    directly access physical memory. They may not be on any
    LRU list.

    I recently saw an mlockalled process where mm->locked_vm became
    bigger than the virtual size of the process (!) because some
    memory was accounted for twice:

    Once when the page was mlocked and once when the Infiniband
    layer increased the refcount because it needt to pin the RDMA
    memory.

    This patch introduces a separate counter for pinned pages and
    accounts them seperately.

    Signed-off-by: Christoph Lameter
    Cc: Mike Marciniszyn
    Cc: Roland Dreier
    Cc: Sean Hefty
    Cc: Hugh Dickins
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Lameter
     
  • test_set_oom_score_adj() was introduced in 72788c385604 ("oom: replace
    PF_OOM_ORIGIN with toggling oom_score_adj") to temporarily elevate
    current's oom_score_adj for ksm and swapoff without requiring an
    additional per-process flag.

    Using that function to both set oom_score_adj to OOM_SCORE_ADJ_MAX and
    then reinstate the previous value is racy since it's possible that
    userspace can set the value to something else itself before the old value
    is reinstated. That results in userspace setting current's oom_score_adj
    to a different value and then the kernel immediately setting it back to
    its previous value without notification.

    To fix this, a new compare_swap_oom_score_adj() function is introduced
    with the same semantics as the compare and swap CAS instruction, or
    CMPXCHG on x86. It is used to reinstate the previous value of
    oom_score_adj if and only if the present value is the same as the old
    value.

    Signed-off-by: David Rientjes
    Cc: Oleg Nesterov
    Cc: Ying Han
    Cc: KOSAKI Motohiro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Rientjes
     
  • This removes mm->oom_disable_count entirely since it's unnecessary and
    currently buggy. The counter was intended to be per-process but it's
    currently decremented in the exit path for each thread that exits, causing
    it to underflow.

    The count was originally intended to prevent oom killing threads that
    share memory with threads that cannot be killed since it doesn't lead to
    future memory freeing. The counter could be fixed to represent all
    threads sharing the same mm, but it's better to remove the count since:

    - it is possible that the OOM_DISABLE thread sharing memory with the
    victim is waiting on that thread to exit and will actually cause
    future memory freeing, and

    - there is no guarantee that a thread is disabled from oom killing just
    because another thread sharing its mm is oom disabled.

    Signed-off-by: David Rientjes
    Reported-by: Oleg Nesterov
    Reviewed-by: Oleg Nesterov
    Cc: Ying Han
    Cc: KOSAKI Motohiro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Rientjes
     
  • In __zone_reclaim case, we don't want to shrink mapped page. Nonetheless,
    we have isolated mapped page and re-add it into LRU's head. It's
    unnecessary CPU overhead and makes LRU churning.

    Of course, when we isolate the page, the page might be mapped but when we
    try to migrate the page, the page would be not mapped. So it could be
    migrated. But race is rare and although it happens, it's no big deal.

    Signed-off-by: Minchan Kim
    Acked-by: Johannes Weiner
    Reviewed-by: KAMEZAWA Hiroyuki
    Reviewed-by: KOSAKI Motohiro
    Reviewed-by: Michal Hocko
    Cc: Mel Gorman
    Cc: Rik van Riel
    Cc: Andrea Arcangeli
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Minchan Kim
     
  • In async mode, compaction doesn't migrate dirty or writeback pages. So,
    it's meaningless to pick the page and re-add it to lru list.

    Of course, when we isolate the page in compaction, the page might be dirty
    or writeback but when we try to migrate the page, the page would be not
    dirty, writeback. So it could be migrated. But it's very unlikely as
    isolate and migration cycle is much faster than writeout.

    So, this patch helps cpu overhead and prevent unnecessary LRU churning.

    Signed-off-by: Minchan Kim
    Acked-by: Johannes Weiner
    Reviewed-by: KAMEZAWA Hiroyuki
    Reviewed-by: KOSAKI Motohiro
    Acked-by: Mel Gorman
    Acked-by: Rik van Riel
    Reviewed-by: Michal Hocko
    Cc: Andrea Arcangeli
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Minchan Kim
     
  • Change ISOLATE_XXX macro with bitwise isolate_mode_t type. Normally,
    macro isn't recommended as it's type-unsafe and making debugging harder as
    symbol cannot be passed throught to the debugger.

    Quote from Johannes
    " Hmm, it would probably be cleaner to fully convert the isolation mode
    into independent flags. INACTIVE, ACTIVE, BOTH is currently a
    tri-state among flags, which is a bit ugly."

    This patch moves isolate mode from swap.h to mmzone.h by memcontrol.h

    Signed-off-by: Minchan Kim
    Cc: Johannes Weiner
    Cc: KAMEZAWA Hiroyuki
    Cc: KOSAKI Motohiro
    Cc: Mel Gorman
    Cc: Rik van Riel
    Cc: Michal Hocko
    Cc: Andrea Arcangeli
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Minchan Kim