1. 30 4月, 2013 40 次提交
    • L
      Merge branch 'for-3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq · 46d9be3e
      Linus Torvalds 提交于
      Pull workqueue updates from Tejun Heo:
       "A lot of activities on workqueue side this time.  The changes achieve
        the followings.
      
         - WQ_UNBOUND workqueues - the workqueues which are per-cpu - are
           updated to be able to interface with multiple backend worker pools.
           This involved a lot of churning but the end result seems actually
           neater as unbound workqueues are now a lot closer to per-cpu ones.
      
         - The ability to interface with multiple backend worker pools are
           used to implement unbound workqueues with custom attributes.
           Currently the supported attributes are the nice level and CPU
           affinity.  It may be expanded to include cgroup association in
           future.  The attributes can be specified either by calling
           apply_workqueue_attrs() or through /sys/bus/workqueue/WQ_NAME/* if
           the workqueue in question is exported through sysfs.
      
           The backend worker pools are keyed by the actual attributes and
           shared by any workqueues which share the same attributes.  When
           attributes of a workqueue are changed, the workqueue binds to the
           worker pool with the specified attributes while leaving the work
           items which are already executing in its previous worker pools
           alone.
      
           This allows converting custom worker pool implementations which
           want worker attribute tuning to use workqueues.  The writeback pool
           is already converted in block tree and there are a couple others
           are likely to follow including btrfs io workers.
      
         - WQ_UNBOUND's ability to bind to multiple worker pools is also used
           to make it NUMA-aware.  Because there's no association between work
           item issuer and the specific worker assigned to execute it, before
           this change, using unbound workqueue led to unnecessary cross-node
           bouncing and it couldn't be helped by autonuma as it requires tasks
           to have implicit node affinity and workers are assigned randomly.
      
           After these changes, an unbound workqueue now binds to multiple
           NUMA-affine worker pools so that queued work items are executed in
           the same node.  This is turned on by default but can be disabled
           system-wide or for individual workqueues.
      
           Crypto was requesting NUMA affinity as encrypting data across
           different nodes can contribute noticeable overhead and doing it
           per-cpu was too limiting for certain cases and IO throughput could
           be bottlenecked by one CPU being fully occupied while others have
           idle cycles.
      
        While the new features required a lot of changes including
        restructuring locking, it didn't complicate the execution paths much.
        The unbound workqueue handling is now closer to per-cpu ones and the
        new features are implemented by simply associating a workqueue with
        different sets of backend worker pools without changing queue,
        execution or flush paths.
      
        As such, even though the amount of change is very high, I feel
        relatively safe in that it isn't likely to cause subtle issues with
        basic correctness of work item execution and handling.  If something
        is wrong, it's likely to show up as being associated with worker pools
        with the wrong attributes or OOPS while workqueue attributes are being
        changed or during CPU hotplug.
      
        While this creates more backend worker pools, it doesn't add too many
        more workers unless, of course, there are many workqueues with unique
        combinations of attributes.  Assuming everything else is the same,
        NUMA awareness costs an extra worker pool per NUMA node with online
        CPUs.
      
        There are also a couple things which are being routed outside the
        workqueue tree.
      
         - block tree pulled in workqueue for-3.10 so that writeback worker
           pool can be converted to unbound workqueue with sysfs control
           exposed.  This simplifies the code, makes writeback workers
           NUMA-aware and allows tuning nice level and CPU affinity via sysfs.
      
         - The conversion to workqueue means that there's no 1:1 association
           between a specific worker, which makes writeback folks unhappy as
           they want to be able to tell which filesystem caused a problem from
           backtrace on systems with many filesystems mounted.  This is
           resolved by allowing work items to set debug info string which is
           printed when the task is dumped.  As this change involves unifying
           implementations of dump_stack() and friends in arch codes, it's
           being routed through Andrew's -mm tree."
      
      * 'for-3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq: (84 commits)
        workqueue: use kmem_cache_free() instead of kfree()
        workqueue: avoid false negative WARN_ON() in destroy_workqueue()
        workqueue: update sysfs interface to reflect NUMA awareness and a kernel param to disable NUMA affinity
        workqueue: implement NUMA affinity for unbound workqueues
        workqueue: introduce put_pwq_unlocked()
        workqueue: introduce numa_pwq_tbl_install()
        workqueue: use NUMA-aware allocation for pool_workqueues
        workqueue: break init_and_link_pwq() into two functions and introduce alloc_unbound_pwq()
        workqueue: map an unbound workqueues to multiple per-node pool_workqueues
        workqueue: move hot fields of workqueue_struct to the end
        workqueue: make workqueue->name[] fixed len
        workqueue: add workqueue->unbound_attrs
        workqueue: determine NUMA node of workers accourding to the allowed cpumask
        workqueue: drop 'H' from kworker names of unbound worker pools
        workqueue: add wq_numa_tbl_len and wq_numa_possible_cpumask[]
        workqueue: move pwq_pool_locking outside of get/put_unbound_pool()
        workqueue: fix memory leak in apply_workqueue_attrs()
        workqueue: fix unbound workqueue attrs hashing / comparison
        workqueue: fix race condition in unbound workqueue free path
        workqueue: remove pwq_lock which is no longer used
        ...
      46d9be3e
    • L
      Merge branch 'for-3.10-async' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq · ce8aa489
      Linus Torvalds 提交于
      Pull async update from Tejun Heo:
       "This contains three cleanup patches for async from Lai.  All three
        patches are essentially cosmetic."
      
      * 'for-3.10-async' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq:
        async: rename and redefine async_func_ptr
        async: remove unused @node from struct async_domain
        async: simplify lowest_in_progress()
      ce8aa489
    • L
      Merge branch 'for-3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu · b97db075
      Linus Torvalds 提交于
      Pull percpu patch from Tejun Heo:
       "A puny pull request for percpu.  We were expecting more cleanup
        patches but didn't happen this time, so just a single patch adding
        documentation from Christoph."
      
      * 'for-3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu:
        percpu: add documentation on this_cpu operations
      b97db075
    • L
      Merge branch 'akpm' (incoming from Andrew) · 73154383
      Linus Torvalds 提交于
      Merge first batch of fixes from Andrew Morton:
      
       - A couple of kthread changes
      
       - A few minor audit patches
      
       - A number of fbdev patches.  Florian remains AWOL so I'm picking up
         some of these.
      
       - A few kbuild things
      
       - ocfs2 updates
      
       - Almost all of the MM queue
      
      (And in the meantime, I already have the second big batch from Andrew
      pending in my mailbox ;^)
      
      * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (149 commits)
        memcg: take reference before releasing rcu_read_lock
        mem hotunplug: fix kfree() of bootmem memory
        mmKconfig: add an option to disable bounce
        mm, nobootmem: do memset() after memblock_reserve()
        mm, nobootmem: clean-up of free_low_memory_core_early()
        fs/buffer.c: remove unnecessary init operation after allocating buffer_head.
        numa, cpu hotplug: change links of CPU and node when changing node number by onlining CPU
        mm: fix memory_hotplug.c printk format warning
        mm: swap: mark swap pages writeback before queueing for direct IO
        swap: redirty page if page write fails on swap file
        mm, memcg: give exiting processes access to memory reserves
        thp: fix huge zero page logic for page with pfn == 0
        memcg: avoid accessing memcg after releasing reference
        fs: fix fsync() error reporting
        memblock: fix missing comment of memblock_insert_region()
        mm: Remove unused parameter of pages_correctly_reserved()
        firmware, memmap: fix firmware_map_entry leak
        mm/vmstat: add note on safety of drain_zonestat
        mm: thp: add split tail pages to shrink page list in page reclaim
        mm: allow for outstanding swap writeback accounting
        ...
      73154383
    • L
      Merge tag 'clk-for-linus-3.10' of git://git.linaro.org/people/mturquette/linux · 362ed48d
      Linus Torvalds 提交于
      Pull clock framework update from Michael Turquette:
       "The common clock framework changes for 3.10 include many fixes for
        existing platforms, as well as adoption of the framework by new
        platforms and devices.
      
        Some long-needed fixes to the core framework are here as well as new
        features such as improved initialization of clocks from DT as well as
        framework reentrancy for nested clock operations."
      
      * tag 'clk-for-linus-3.10' of git://git.linaro.org/people/mturquette/linux: (44 commits)
        clk: add clk_ignore_unused option to keep boot clocks on
        clk: ux500: fix mismatched types
        clk: vexpress: Add separate SP810 driver
        clk: si5351: make clk-si5351 depend on CONFIG_OF
        clk: export __clk_get_flags for modular clock providers
        clk: vt8500: Missing breaks in vtwm_pll_round_rate/_set_rate.
        clk: sunxi: Unify oscillator clock
        clk: composite: allow fixed rates & fixed dividers
        clk: composite: rename 'div' references to 'rate'
        clk: add si5351 i2c common clock driver
        clk: add device tree fixed-factor-clock binding support
        clk: Properly handle notifier return values
        clk: ux500: abx500: Define clock tree for ab850x
        clk: ux500: Add support for sysctrl clocks
        clk: mvebu: Fix valid value range checking for cpu_freq_select
        clk: Fixup locking issues for clk_set_parent
        clk: Fixup errorhandling for clk_set_parent
        clk: Restructure code for __clk_reparent
        clk: sunxi: drop an unnecesary kmalloc
        clk: sunxi: drop CLK_IGNORE_UNUSED
        ...
      362ed48d
    • L
      Merge tag 'spi-v3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi · 61f3d0a9
      Linus Torvalds 提交于
      Pull spi updates from Mark Brown:
       "A fairly quiet release for SPI, mainly driver work.  A few highlights:
      
         - Supports bits per word compatibility checking in the core.
         - Allow use of the IP used in Freescale SPI controllers outside
           Freescale SoCs.
         - DMA support for the Atmel SPI driver.
         - New drivers for the BCM2835 and Tegra114"
      
      * tag 'spi-v3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi: (68 commits)
        spi-topcliff-pch: fix to use list_for_each_entry_safe() when delete list items
        spi-topcliff-pch: missing platform_driver_unregister() on error in pch_spi_init()
        ARM: dts: add pinctrl property for spi node for atmel SoC
        ARM: dts: add spi nodes for the atmel boards
        ARM: dts: add spi nodes for atmel SoC
        ARM: at91: add clocks for spi dt entries
        spi/spi-atmel: add dmaengine support
        spi/spi-atmel: add flag to controller data for lock operations
        spi/spi-atmel: add physical base address
        spi/sirf: fix MODULE_DEVICE_TABLE
        MAINTAINERS: Add git repository and update my address
        spi/s3c64xx: Check for errors in dmaengine prepare_transfer()
        spi/s3c64xx: Fix non-dmaengine usage
        spi: omap2-mcspi: fix error return code in omap2_mcspi_probe()
        spi/s3c64xx: let device core setup the default pin configuration
        MAINTAINERS: Update Grant's email address and maintainership
        spi: omap2-mcspi: Fix transfers if DMADEVICES is not set
        spi: s3c64xx: move to generic dmaengine API
        spi-gpio: init CS before spi_bitbang_setup()
        spi: spi-mpc512x-psc: let transmiter/receiver enabled when in xfer loop
        ...
      61f3d0a9
    • L
      Merge tag 'regulator-v3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator · 8ded8d4e
      Linus Torvalds 提交于
      Pull regulator updates from Mark Brown:
       "The diffstat and changelog here is dominated by Lee Jones' heroic
        efforts to sync the ab8500 driver that's been maintained out of tree
        with mainline (plus Axel's cleanup work on the results) but there's a
        few other things here:
      
         - Axel Lin added regulator_map_voltage_ascend() optimising a common
           pattern for drivers using the core code.
         - Milo Kim tought the regulator core to handle regulators sharing an
           enable GPIO, avoiding the need to do hacks to support such systems.
         - Andrew Bresticker added code to handle missing supplies for
           regulators more sensibly for device tree systems, reducing the need
           for stubbing there.
      
        plus the usual batch of driver specific updates and fixes"
      
      * tag 'regulator-v3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (152 commits)
        regulator: mc13892: Fix MC13892_SWITCHERS0_SWxHI bit in set_voltage_sel
        regulator: Remove NULL test before calling regulator_unregister()
        regulator: mc13783: Add device tree probe support
        regulator: mc13xxx: Add warning of incorrect names of regulators
        regulator: max77686: Don't update max77686->opmode if update register fails
        regulator: max8952: Add missing config.of_node setting for regulator register
        regulator: ab3100: Fix regulator register error handling
        regulator: tps6524x: Use regulator_map_voltage_ascend
        regulator: lp8788-buck: Use regulator_map_voltage_ascend
        regulator: lp872x: Use regulator_map_voltage_ascend
        regulator: mc13892: Use regulator_map_voltage_ascend for mc13892_sw_regulator_ops
        regulator: tps65023: Use regulator_map_voltage_ascend
        regulator: tps65023: Merge tps65020 ldo1 and ldo2 vsel table
        regulator: tps6507x: Use regulator_map_voltage_ascend
        regulator: mc13892: Fix MC13892_SWITCHERS0_SWxHI bit in set_voltage_sel
        regulator: ab3100: device tree support
        regulator: ab3100: refactor probe to use IDs
        regulator: max8973: Don't override control1 variable when set ramp delay bits
        regulator: tps80031: Convert tps80031_dcdc_ops to [get|set]_voltage_sel_regmap
        regulator: tps80031: Fix LDO2 track mode for TPS80031 or TPS80032-ES1.0
        ...
      8ded8d4e
    • L
      Merge tag 'regmap-v3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap · 7b053842
      Linus Torvalds 提交于
      Pull regmap updates from Mark Brown:
       "In user visible terms just a couple of enhancements here, though there
        was a moderate amount of refactoring required in order to support the
        register cache sync performance improvements.
      
         - Support for block and asynchronous I/O during register cache
           syncing; this provides a use case dependant performance
           improvement.
         - Additional debugfs information on the memory consuption and
           register set"
      
      * tag 'regmap-v3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap: (23 commits)
        regmap: don't corrupt work buffer in _regmap_raw_write()
        regmap: cache: Fix format specifier in dev_dbg
        regmap: cache: Make regcache_sync_block_raw static
        regmap: cache: Write consecutive registers in a single block write
        regmap: cache: Split raw and non-raw syncs
        regmap: cache: Factor out block sync
        regmap: cache: Factor out reg_present support from rbtree cache
        regmap: cache: Use raw I/O to sync rbtrees if we can
        regmap: core: Provide regmap_can_raw_write() operation
        regmap: cache: Provide a get address of value operation
        regmap: Cut down on the average # of nodes in the rbtree cache
        regmap: core: Make raw write available to regcache
        regmap: core: Warn on invalid operation combinations
        regmap: irq: Clarify error message when we fail to request primary IRQ
        regmap: rbtree Expose total memory consumption in the rbtree debugfs entry
        regmap: debugfs: Add a registers `range' file
        regmap: debugfs: Simplify calculation of `c->max_reg'
        regmap: cache: Store caches in native register format where possible
        regmap: core: Split out in place value parsing
        regmap: cache: Use regcache_get_value() to check if we updated
        ...
      7b053842
    • L
      memcg: take reference before releasing rcu_read_lock · ca0dde97
      Li Zefan 提交于
      The memcg is not referenced, so it can be destroyed at anytime right
      after we exit rcu read section, so it's not safe to access it.
      
      To fix this, we call css_tryget() to get a reference while we're still
      in rcu read section.
      
      This also removes a bogus comment above __memcg_create_cache_enqueue().
      Signed-off-by: NLi Zefan <lizefan@huawei.com>
      Acked-by: NGlauber Costa <glommer@parallels.com>
      Acked-by: NMichal Hocko <mhocko@suse.cz>
      Acked-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ca0dde97
    • Y
      mem hotunplug: fix kfree() of bootmem memory · ebff7d8f
      Yasuaki Ishimatsu 提交于
      When hot removing memory presented at boot time, following messages are shown:
      
        kernel BUG at mm/slub.c:3409!
        invalid opcode: 0000 [#1] SMP
        Modules linked in: ebtable_nat ebtables xt_CHECKSUM iptable_mangle bridge stp llc ipmi_devintf ipmi_msghandler sunrpc ipt_REJECT nf_conntrack_ipv4 nf_defrag_ipv4 iptable_filter ip_tables ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 xt_state nf_conntrack ip6table_filter ip6_tables binfmt_misc vfat fat dm_mirror dm_region_hash dm_log dm_mod vhost_net macvtap macvlan tun uinput iTCO_wdt iTCO_vendor_support coretemp kvm_intel kvm crc32c_intel ghash_clmulni_intel microcode pcspkr sg i2c_i801 lpc_ich mfd_core igb i2c_algo_bit i2c_core e1000e ptp pps_core tpm_infineon ioatdma dca sr_mod cdrom sd_mod crc_t10dif usb_storage megaraid_sas lpfc scsi_transport_fc scsi_tgt scsi_mod
        CPU 0
        Pid: 5091, comm: kworker/0:2 Tainted: G        W    3.9.0-rc6+ #15
        RIP: kfree+0x232/0x240
        Process kworker/0:2 (pid: 5091, threadinfo ffff88084678c000, task ffff88083928ca80)
        Call Trace:
          __release_region+0xd4/0xe0
          __remove_pages+0x52/0x110
          arch_remove_memory+0x89/0xd0
          remove_memory+0xc4/0x100
          acpi_memory_device_remove+0x6d/0xb1
          acpi_device_remove+0x89/0xab
          __device_release_driver+0x7c/0xf0
          device_release_driver+0x2f/0x50
          acpi_bus_device_detach+0x6c/0x70
          acpi_ns_walk_namespace+0x11a/0x250
          acpi_walk_namespace+0xee/0x137
          acpi_bus_trim+0x33/0x7a
          acpi_bus_hot_remove_device+0xc4/0x1a1
          acpi_os_execute_deferred+0x27/0x34
          process_one_work+0x1f7/0x590
          worker_thread+0x11a/0x370
          kthread+0xee/0x100
          ret_from_fork+0x7c/0xb0
        RIP  [<ffffffff811c41d2>] kfree+0x232/0x240
         RSP <ffff88084678d968>
      
      The reason why the messages are shown is to release a resource
      structure, allocated by bootmem, by kfree().  So when we release a
      resource structure, we should check whether it is allocated by bootmem
      or not.
      
      But even if we know a resource structure is allocated by bootmem, we
      cannot release it since SLxB cannot treat it.  So for reusing a resource
      structure, this patch remembers it by using bootmem_resource as follows:
      
      When releasing a resource structure by free_resource(), free_resource()
      checks whether the resource structure is allocated by bootmem or not.
      If it is allocated by bootmem, free_resource() adds it to
      bootmem_resource.  If it is not allocated by bootmem, free_resource()
      release it by kfree().
      
      And when getting a new resource structure by get_resource(),
      get_resource() checks whether bootmem_resource has released resource
      structures or not.  If there is a released resource structure,
      get_resource() returns it.  If there is not a releaed resource
      structure, get_resource() returns new resource structure allocated by
      kzalloc().
      
      [akpm@linux-foundation.org: s/get_resource/alloc_resource/]
      Signed-off-by: NYasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
      Reviewed-by: NToshi Kani <toshi.kani@hp.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Ram Pai <linuxram@us.ibm.com>
      Cc: David Rientjes <rientjes@google.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ebff7d8f
    • V
      mmKconfig: add an option to disable bounce · 9ca24e2e
      Vinayak Menon 提交于
      There are times when HIGHMEM is enabled, but we don't prefer
      CONFIG_BOUNCE to be enabled.  CONFIG_BOUNCE can reduce the block device
      throughput, and this is not ideal for machines where we don't gain much
      by enabling it.  So provide an option to deselect CONFIG_BOUNCE.  The
      observation was made while measuring eMMC throughput using iozone on an
      ARM device with 1GB RAM.
      Signed-off-by: NVinayak Menon <vinayakm.list@gmail.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: Russell King <rmk@arm.linux.org.uk>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9ca24e2e
    • J
      mm, nobootmem: do memset() after memblock_reserve() · b476e295
      Joonsoo Kim 提交于
      Currently, we do memset() before reserving the area.  This may not cause
      any problem, but it is somewhat weird.  So change execution order.
      Signed-off-by: NJoonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Yinghai Lu <yinghai@kernel.org>
      Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
      Cc: Jiang Liu <liuj97@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b476e295
    • J
      mm, nobootmem: clean-up of free_low_memory_core_early() · b4def350
      Joonsoo Kim 提交于
      Remove unused argument and make function static, because there is no user
      outside of nobootmem.c
      Signed-off-by: NJoonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Yinghai Lu <yinghai@kernel.org>
      Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
      Cc: Jiang Liu <liuj97@gmail.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b4def350
    • M
      fs/buffer.c: remove unnecessary init operation after allocating buffer_head. · e7600409
      majianpeng 提交于
      bh allocation uses kmem_cache_zalloc() so we needn't call
      'init_buffer(bh, NULL, NULL)' and perform other set-zero-operations.
      Signed-off-by: NJianpeng Ma <majianpeng@gmail.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Theodore Ts'o <tytso@mit.edu>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e7600409
    • Y
      numa, cpu hotplug: change links of CPU and node when changing node number by onlining CPU · 34640468
      Yasuaki Ishimatsu 提交于
      When booting x86 system contains memoryless node, node numbers of CPUs
      on memoryless node were changed to nearest online node number by
      init_cpu_to_node() because the node is not online.
      
      In my system, node numbers of cpu#30-44 and 75-89 were changed from 2 to
      0 as follows:
      
        $ numactl --hardware
        available: 2 nodes (0-1)
        node 0 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 30 31 32 33 34 35 36 37 38 39 40
        41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 75 76 77 78 79 80 81 82
        83 84 85 86 87 88 89
        node 0 size: 32394 MB
        node 0 free: 27898 MB
        node 1 cpus: 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 60 61 62 63 64 65 66
        67 68 69 70 71 72 73 74
        node 1 size: 32768 MB
        node 1 free: 30335 MB
      
      If we hot add memory to memoryless node and offine/online all CPUs on
      the node, node numbers of these CPUs are changed to correct node numbers
      by srat_detect_node() because the node become online.
      
      In this case, node numbers of cpu#30-44 and 75-89 were changed from 0 to
      2 in my system as follows:
      
        $ numactl --hardware
        available: 3 nodes (0-2)
        node 0 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 45 46 47 48 49 50 51 52 53 54 55
        56 57 58 59
        node 0 size: 32394 MB
        node 0 free: 27218 MB
        node 1 cpus: 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 60 61 62 63 64 65 66
        67 68 69 70 71 72 73 74
        node 1 size: 32768 MB
        node 1 free: 30014 MB
        node 2 cpus: 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 75 76 77 78 79 80 81
        82 83 84 85 86 87 88 89
        node 2 size: 16384 MB
        node 2 free: 16384 MB
      
      But "cpu to node" and "node to cpu" links were not changed as follows:
      
        $ ls /sys/devices/system/cpu/cpu30/|grep node
        node0
        $ ls /sys/devices/system/node/node0/|grep cpu30
        cpu30
      
      "numactl --hardware" shows that cpu30 belongs to node 2.  But sysfs
      links does not change.
      
      This patch changes "cpu to node" and "node to cpu" links when node
      number changed by onlining CPU.
      Signed-off-by: NYasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
      Cc: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
      Cc: Greg KH <greg@kroah.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      34640468
    • R
      mm: fix memory_hotplug.c printk format warning · 349daa0f
      Randy Dunlap 提交于
      PFN_PHYS() is a phys_addr_t, which can be u32 or u64.
      Fix the build warning when phys_addr_t is u32.
      
        mm/memory_hotplug.c: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 2 has type 'unsigned int' [-Wformat]:  => 1685:3
        mm/memory_hotplug.c: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'unsigned int' [-Wformat]:  => 1685:3
      Signed-off-by: NRandy Dunlap <rdunlap@infradead.org>
      Reported-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      349daa0f
    • M
      mm: swap: mark swap pages writeback before queueing for direct IO · 0cdc444a
      Mel Gorman 提交于
      As pointed out by Andrew Morton, the swap-over-NFS writeback is not
      setting PageWriteback before it is queued for direct IO.  While swap
      pages do not participate in BDI or process dirty accounting and the IO
      is synchronous, the writeback bit is still required and not setting it
      in this case was an oversight.  swapoff depends on the page writeback to
      synchronoise all pending writes on a swap page before it is reused.
      Swapcache freeing and reuse depend on checking the PageWriteback under
      lock to ensure the page is safe to reuse.
      
      Direct IO handlers and the direct IO handler for NFS do not deal with
      PageWriteback as they are synchronous writes.  In the case of NFS, it
      schedules pages (or a page in the case of swap) for IO and then waits
      synchronously for IO to complete in nfs_direct_write().  It is
      recognised that this is a slowdown from normal swap handling which is
      asynchronous and uses a completion handler.  Shoving PageWriteback
      handling down into direct IO handlers looks like a bad fit to handle the
      swap case although it may have to be dealt with some day if swap is
      converted to use direct IO in general and bmap is finally done away
      with.  At that point it will be necessary to refit asynchronous direct
      IO with completion handlers onto the swap subsystem.
      
      As swapcache currently depends on PageWriteback to protect against
      races, this patch sets PageWriteback under the page lock before queueing
      it for direct IO.  It is cleared when the direct IO handler returns.  IO
      errors are treated similarly to the direct-to-bio case except PageError
      is not set as in the case of swap-over-NFS, it is likely to be a
      transient error.
      
      It was asked what prevents such a page being reclaimed in parallel.
      With this patch applied, such a page will now be skipped (most of the
      time) or blocked until the writeback completes.  Reclaim checks
      PageWriteback under the page lock before calling try_to_free_swap and
      the page lock should prevent the page being requeued for IO before it is
      freed.
      
      This and Jerome's related patch should considered for -stable as far
      back as 3.6 when swap-over-NFS was introduced.
      
      [akpm@linux-foundation.org: use pr_err_ratelimited()]
      [akpm@linux-foundation.org: remove hopefully-unneeded cast in printk]
      Signed-off-by: NMel Gorman <mgorman@suse.de>
      Cc: Jerome Marchand <jmarchan@redhat.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: <stable@vger.kernel.org>	[3.6+]
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      0cdc444a
    • J
      swap: redirty page if page write fails on swap file · 2d30d31e
      Jerome Marchand 提交于
      Since commit 62c230bc ("mm: add support for a filesystem to activate
      swap files and use direct_IO for writing swap pages"), swap_writepage()
      calls direct_IO on swap files.  However, in that case the page isn't
      redirtied if I/O fails, and is therefore handled afterwards as if it has
      been successfully written to the swap file, leading to memory corruption
      when the page is eventually swapped back in.
      
      This patch sets the page dirty when direct_IO() fails.  It fixes a
      memory corruption that happened while using swap-over-NFS.
      Signed-off-by: NJerome Marchand <jmarchan@redhat.com>
      Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
      Acked-by: NMel Gorman <mgorman@suse.de>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: <stable@vger.kernel.org>	[3.6+]
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2d30d31e
    • D
      mm, memcg: give exiting processes access to memory reserves · 465adcf1
      David Rientjes 提交于
      A memcg may livelock when oom if the process that grabs the hierarchy's
      oom lock is never the first process with PF_EXITING set in the memcg's
      task iteration.
      
      The oom killer, both global and memcg, will defer if it finds an
      eligible process that is in the process of exiting and it is not being
      ptraced.  The idea is to allow it to exit without using memory reserves
      before needlessly killing another process.
      
      This normally works fine except in the memcg case with a large number of
      threads attached to the oom memcg.  In this case, the memcg oom killer
      only gets called for the process that grabs the hierarchy's oom lock;
      all others end up blocked on the memcg's oom waitqueue.  Thus, if the
      process that grabs the hierarchy's oom lock is never the first
      PF_EXITING process in the memcg's task iteration, the oom killer is
      constantly deferred without anything making progress.
      
      The fix is to give PF_EXITING processes access to memory reserves so
      that we've marked them as oom killed without any iteration.  This allows
      __mem_cgroup_try_charge() to succeed so that the process may exit.  This
      makes the memcg oom killer exemption for TIF_MEMDIE tasks, now
      immediately granted for processes with pending SIGKILLs and those in the
      exit path, to be equivalent to what is done for the global oom killer.
      Signed-off-by: NDavid Rientjes <rientjes@google.com>
      Acked-by: NMichal Hocko <mhocko@suse.cz>
      Acked-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      465adcf1
    • K
      thp: fix huge zero page logic for page with pfn == 0 · 5918d10a
      Kirill A. Shutemov 提交于
      Current implementation of huge zero page uses pfn value 0 to indicate
      that the page hasn't allocated yet.  It assumes that buddy page
      allocator can't return page with pfn == 0.
      
      Let's rework the code to store 'struct page *' of huge zero page, not
      its pfn.  This way we can avoid the weak assumption.
      
      [akpm@linux-foundation.org: fix sparse warning]
      Signed-off-by: NKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Reported-by: NMinchan Kim <minchan@kernel.org>
      Acked-by: NMinchan Kim <minchan@kernel.org>
      Reviewed-by: NAndrea Arcangeli <aarcange@redhat.com>
      Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
      Cc: Wu Fengguang <fengguang.wu@intel.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5918d10a
    • L
      memcg: avoid accessing memcg after releasing reference · fd0ccaf2
      Li Zefan 提交于
      This might cause a use-after-free bug.
      Signed-off-by: NLi Zefan <lizefan@huawei.com>
      Cc: Glauber Costa <glommer@parallels.com>
      Acked-by: NMichal Hocko <mhocko@suse.cz>
      Acked-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      fd0ccaf2
    • D
      fs: fix fsync() error reporting · 865ffef3
      Dmitry Monakhov 提交于
      There are two convenient ways to report errors to userspace
      
      1) retun error to original syscall for example write(2)
      2) mark mapping with error flag and return it on later fsync(2)
      
      Second one is broken if (mapping->nrpages == 0) This is real-life
      situation because after error pages are likey to be truncated or
      invalidated.
      
      We have to return an error regardless to number of pages in the mapping.
      
      #Original testcase: git@github.com:dmonakhov/xfstests.git
      MOUNT_OPTIONS="-b1024"
      ./check shared/305
      Signed-off-by: NDmitry Monakhov <dmonakhov@openvz.org>
      Reviewed-by: NJan Kara <jack@suse.cz>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      865ffef3
    • T
      memblock: fix missing comment of memblock_insert_region() · 209ff86d
      Tang Chen 提交于
      There is no comment for parameter nid of memblock_insert_region().
      This patch adds comment for it.
      Signed-off-by: NTang Chen <tangchen@cn.fujitsu.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      209ff86d
    • T
      mm: Remove unused parameter of pages_correctly_reserved() · 6056d619
      Tang Chen 提交于
      nr_pages is not used in pages_correctly_reserved().
      So remove it.
      Signed-off-by: NTang Chen <tangchen@cn.fujitsu.com>
      Reviewed-by: NWang Shilong <wangsl-fnst@cn.fujitsu.com>
      Reviewed-by: NWen Congyang <wency@cn.fujitsu.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6056d619
    • Y
      firmware, memmap: fix firmware_map_entry leak · 7a6f93b0
      Yasuaki Ishimatsu 提交于
      When hot removing memory, a firmware_map_entry which has memory range of
      the memory is released by release_firmware_map_entry().  If the entry is
      allocated by bootmem, release_firmware_map_entry() adds the entry to
      map_entires_bootmem list when firmware_map_find_entry() finds the entry
      from map_entries list.  But firmware_map_find_entry never find the entry
      sicne map_entires list does not have the entry.  So the entry just
      leaks.
      
      Here are steps of leaking firmware_map_entry:
      firmware_map_remove()
      -> firmware_map_find_entry()
         Find released entry from map_entries list
      -> firmware_map_remove_entry()
         Delete the entry from map_entries list
      -> remove_sysfs_fw_map_entry()
         ...
         -> release_firmware_map_entry()
            -> firmware_map_find_entry()
               Find the entry from map_entries list but the entry has been
               deleted from map_entries list. So the entry is not added
               to map_entries_bootmem. Thus the entry leaks
      
      release_firmware_map_entry() should not call firmware_map_find_entry()
      since releaed entry has been deleted from map_entries list.  So the
      patch delete firmware_map_find_entry() from releae_firmware_map_entry()
      Signed-off-by: NYasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
      Reviewed-by: NWanpeng Li <liwanp@linux.vnet.ibm.com>
      Reviewed-by: NTang Chen <tangchen@cn.fujitsu.com>
      Acked-by: NToshi Kani <toshi.kani@hp.com>
      Cc: Wen Congyang <wency@cn.fujitsu.com>
      Cc: Greg KH <greg@kroah.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7a6f93b0
    • C
    • S
      mm: thp: add split tail pages to shrink page list in page reclaim · 5bc7b8ac
      Shaohua Li 提交于
      In page reclaim, huge page is split.  split_huge_page() adds tail pages
      to LRU list.  Since we are reclaiming a huge page, it's better we
      reclaim all subpages of the huge page instead of just the head page.
      This patch adds split tail pages to shrink page list so the tail pages
      can be reclaimed soon.
      
      Before this patch, run a swap workload:
        thp_fault_alloc 3492
        thp_fault_fallback 608
        thp_collapse_alloc 6
        thp_collapse_alloc_failed 0
        thp_split 916
      
      With this patch:
        thp_fault_alloc 4085
        thp_fault_fallback 16
        thp_collapse_alloc 90
        thp_collapse_alloc_failed 0
        thp_split 1272
      
      fallback allocation is reduced a lot.
      
      [akpm@linux-foundation.org: fix CONFIG_SWAP=n build]
      Signed-off-by: NShaohua Li <shli@fusionio.com>
      Acked-by: NRik van Riel <riel@redhat.com>
      Acked-by: NMinchan Kim <minchan@kernel.org>
      Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
      Reviewed-by: NWanpeng Li <liwanp@linux.vnet.ibm.com>
      Cc: Andrea Arcangeli <aarcange@redhat.com>
      Cc: Hugh Dickins <hughd@google.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5bc7b8ac
    • S
      mm: allow for outstanding swap writeback accounting · 1eec6702
      Seth Jennings 提交于
      To prevent flooding the swap device with writebacks, frontswap backends
      need to count and limit the number of outstanding writebacks.  The
      incrementing of the counter can be done before the call to
      __swap_writepage().  However, the caller must receive a notification
      when the writeback completes in order to decrement the counter.
      
      To achieve this functionality, this patch modifies __swap_writepage() to
      take the bio completion callback function as an argument.
      
      end_swap_bio_write(), the normal bio completion function, is also made
      non-static so that code doing the accounting can call it after the
      accounting is done.
      
      There should be no behavioural change to existing code.
      Signed-off-by: NSeth Jennings <sjenning@linux.vnet.ibm.com>
      Signed-off-by: NBob Liu <bob.liu@oracle.com>
      Acked-by: NMinchan Kim <minchan@kernel.org>
      Reviewed-by: NDan Magenheimer <dan.magenheimer@oracle.com>
      Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1eec6702
    • S
      mm: break up swap_writepage() for frontswap backends · 2f772e6c
      Seth Jennings 提交于
      swap_writepage() is currently where frontswap hooks into the swap write
      path to capture pages with the frontswap_store() function.  However, if
      a frontswap backend wants to "resume" the writeback of a page to the
      swap device, it can't call swap_writepage() as the page will simply
      reenter the backend.
      
      This patch separates swap_writepage() into a top and bottom half, the
      bottom half named __swap_writepage() to allow a frontswap backend, like
      zswap, to resume writeback beyond the frontswap_store() hook.
      
      __add_to_swap_cache() is also made non-static so that the page for which
      writeback is to be resumed can be added to the swap cache.
      Signed-off-by: NSeth Jennings <sjenning@linux.vnet.ibm.com>
      Signed-off-by: NBob Liu <bob.liu@oracle.com>
      Acked-by: NMinchan Kim <minchan@kernel.org>
      Reviewed-by: NDan Magenheimer <dan.magenheimer@oracle.com>
      Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2f772e6c
    • C
      mm/mmap: check for RLIMIT_AS before unmapping · e8420a8e
      Cyril Hrubis 提交于
      Fix a corner case for MAP_FIXED when requested mapping length is larger
      than rlimit for virtual memory.  In such case any overlapping mappings
      are unmapped before we check for the limit and return ENOMEM.
      
      The check is moved before the loop that unmaps overlapping parts of
      existing mappings.  When we are about to hit the limit (currently mapped
      pages + len > limit) we scan for overlapping pages and check again
      accounting for them.
      
      This fixes situation when userspace program expects that the previous
      mappings are preserved after the mmap() syscall has returned with error.
      (POSIX clearly states that successfull mapping shall replace any
      previous mappings.)
      
      This corner case was found and can be tested with LTP testcase:
      
      testcases/open_posix_testsuite/conformance/interfaces/mmap/24-2.c
      
      In this case the mmap, which is clearly over current limit, unmaps
      dynamic libraries and the testcase segfaults right after returning into
      userspace.
      
      I've also looked at the second instance of the unmapping loop in the
      do_brk().  The do_brk() is called from brk() syscall and from vm_brk().
      The brk() syscall checks for overlapping mappings and bails out when
      there are any (so it can't be triggered from the brk syscall).  The
      vm_brk() is called only from binmft handlers so it shouldn't be
      triggered unless binmft handler created overlapping mappings.
      Signed-off-by: NCyril Hrubis <chrubis@suse.cz>
      Reviewed-by: NMel Gorman <mgorman@suse.de>
      Reviewed-by: NWanpeng Li <liwanp@linux.vnet.ibm.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e8420a8e
    • A
      memcg: add memory.pressure_level events · 70ddf637
      Anton Vorontsov 提交于
      With this patch userland applications that want to maintain the
      interactivity/memory allocation cost can use the pressure level
      notifications.  The levels are defined like this:
      
      The "low" level means that the system is reclaiming memory for new
      allocations.  Monitoring this reclaiming activity might be useful for
      maintaining cache level.  Upon notification, the program (typically
      "Activity Manager") might analyze vmstat and act in advance (i.e.
      prematurely shutdown unimportant services).
      
      The "medium" level means that the system is experiencing medium memory
      pressure, the system might be making swap, paging out active file
      caches, etc.  Upon this event applications may decide to further analyze
      vmstat/zoneinfo/memcg or internal memory usage statistics and free any
      resources that can be easily reconstructed or re-read from a disk.
      
      The "critical" level means that the system is actively thrashing, it is
      about to out of memory (OOM) or even the in-kernel OOM killer is on its
      way to trigger.  Applications should do whatever they can to help the
      system.  It might be too late to consult with vmstat or any other
      statistics, so it's advisable to take an immediate action.
      
      The events are propagated upward until the event is handled, i.e.  the
      events are not pass-through.  Here is what this means: for example you
      have three cgroups: A->B->C.  Now you set up an event listener on
      cgroups A, B and C, and suppose group C experiences some pressure.  In
      this situation, only group C will receive the notification, i.e.  groups
      A and B will not receive it.  This is done to avoid excessive
      "broadcasting" of messages, which disturbs the system and which is
      especially bad if we are low on memory or thrashing.  So, organize the
      cgroups wisely, or propagate the events manually (or, ask us to
      implement the pass-through events, explaining why would you need them.)
      
      Performance wise, the memory pressure notifications feature itself is
      lightweight and does not require much of bookkeeping, in contrast to the
      rest of memcg features.  Unfortunately, as of current memcg
      implementation, pages accounting is an inseparable part and cannot be
      turned off.  The good news is that there are some efforts[1] to improve
      the situation; plus, implementing the same, fully API-compatible[2]
      interface for CONFIG_MEMCG=n case (e.g.  embedded) is also a viable
      option, so it will not require any changes on the userland side.
      
      [1] http://permalink.gmane.org/gmane.linux.kernel.cgroups/6291
      [2] http://lkml.org/lkml/2013/2/21/454
      
      [akpm@linux-foundation.org: coding-style fixes]
      [akpm@linux-foundation.org: fix CONFIG_CGROPUPS=n warnings]
      Signed-off-by: NAnton Vorontsov <anton.vorontsov@linaro.org>
      Acked-by: NKirill A. Shutemov <kirill@shutemov.name>
      Acked-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Glauber Costa <glommer@parallels.com>
      Cc: Michal Hocko <mhocko@suse.cz>
      Cc: Luiz Capitulino <lcapitulino@redhat.com>
      Cc: Greg Thelen <gthelen@google.com>
      Cc: Leonid Moiseichuk <leonid.moiseichuk@nokia.com>
      Cc: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: John Stultz <john.stultz@linaro.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      70ddf637
    • R
      mm: madvise: complete input validation before taking lock · 84d96d89
      Rasmus Villemoes 提交于
      In madvise(), there doesn't seem to be any reason for taking the
      &current->mm->mmap_sem before start and len_in have been validated.
      Incidentally, this removes the need for the out: label.
      
      [akpm@linux-foundation.org: s/out_plug/out/, per David]
      Signed-off-by: NRasmus Villemoes <linux@rasmusvillemoes.dk>
      Acked-by: NKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Acked-by: NDavid Rientjes <rientjes@google.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      84d96d89
    • D
      mm, hotplug: avoid compiling memory hotremove functions when disabled · 4edd7cef
      David Rientjes 提交于
      __remove_pages() is only necessary for CONFIG_MEMORY_HOTREMOVE.  PowerPC
      pseries will return -EOPNOTSUPP if unsupported.
      
      Adding an #ifdef causes several other functions it depends on to also
      become unnecessary, which saves in .text when disabled (it's disabled in
      most defconfigs besides powerpc, including x86).  remove_memory_block()
      becomes static since it is not referenced outside of
      drivers/base/memory.c.
      
      Build tested on x86 and powerpc with CONFIG_MEMORY_HOTREMOVE both enabled
      and disabled.
      Signed-off-by: NDavid Rientjes <rientjes@google.com>
      Acked-by: NToshi Kani <toshi.kani@hp.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Wen Congyang <wency@cn.fujitsu.com>
      Cc: Tang Chen <tangchen@cn.fujitsu.com>
      Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      4edd7cef
    • T
      mm: change __remove_pages() to call release_mem_region_adjustable() · fe74ebb1
      Toshi Kani 提交于
      Change __remove_pages() to call release_mem_region_adjustable().  This
      allows a requested memory range to be released from the iomem_resource
      table even if it does not match exactly to an resource entry but still
      fits into.  The resource entries initialized at bootup usually cover the
      whole contiguous memory ranges and may not necessarily match with the
      size of memory hot-delete requests.
      
      If release_mem_region_adjustable() failed, __remove_pages() emits a
      warning message and continues to proceed as it was the case with
      release_mem_region().  release_mem_region(), which is defined to
      __release_region(), emits a warning message and returns no error since a
      void function.
      Signed-off-by: NToshi Kani <toshi.kani@hp.com>
      Reviewed-by : Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
      Acked-by: NDavid Rientjes <rientjes@google.com>
      Cc: Ram Pai <linuxram@us.ibm.com>
      Cc: T Makphaibulchoke <tmac@hp.com>
      Cc: Wen Congyang <wency@cn.fujitsu.com>
      Cc: Tang Chen <tangchen@cn.fujitsu.com>
      Cc: Jiang Liu <jiang.liu@huawei.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      fe74ebb1
    • T
      resource: add release_mem_region_adjustable() · 825f787b
      Toshi Kani 提交于
      Add release_mem_region_adjustable(), which releases a requested region
      from a currently busy memory resource.  This interface adjusts the
      matched memory resource accordingly even if the requested region does
      not match exactly but still fits into.
      
      This new interface is intended for memory hot-delete.  During bootup,
      memory resources are inserted from the boot descriptor table, such as
      EFI Memory Table and e820.  Each memory resource entry usually covers
      the whole contigous memory range.  Memory hot-delete request, on the
      other hand, may target to a particular range of memory resource, and its
      size can be much smaller than the whole contiguous memory.  Since the
      existing release interfaces like __release_region() require a requested
      region to be exactly matched to a resource entry, they do not allow a
      partial resource to be released.
      
      This new interface is restrictive (i.e.  release under certain
      conditions), which is consistent with other release interfaces,
      __release_region() and __release_resource().  Additional release
      conditions, such as an overlapping region to a resource entry, can be
      supported after they are confirmed as valid cases.
      
      There is no change to the existing interfaces since their restriction is
      valid for I/O resources.
      
      [akpm@linux-foundation.org: use GFP_ATOMIC under write_lock()]
      [akpm@linux-foundation.org: switch back to GFP_KERNEL, less buggily]
      [akpm@linux-foundation.org: remove unneeded and wrong kfree(), per Toshi]
      Signed-off-by: NToshi Kani <toshi.kani@hp.com>
      Reviewed-by : Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
      Cc: David Rientjes <rientjes@google.com>
      Reviewed-by: NRam Pai <linuxram@us.ibm.com>
      Cc: T Makphaibulchoke <tmac@hp.com>
      Cc: Wen Congyang <wency@cn.fujitsu.com>
      Cc: Tang Chen <tangchen@cn.fujitsu.com>
      Cc: Jiang Liu <jiang.liu@huawei.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      825f787b
    • T
      resource: add __adjust_resource() for internal use · ae8e3a91
      Toshi Kani 提交于
      Add __adjust_resource(), which is called by adjust_resource() internally
      after the resource_lock is held.  There is no interface change to
      adjust_resource().  This change allows other functions to call
      __adjust_resource() internally while the resource_lock is held.
      Signed-off-by: NToshi Kani <toshi.kani@hp.com>
      Reviewed-by: NYasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
      Acked-by: NDavid Rientjes <rientjes@google.com>
      Cc: Ram Pai <linuxram@us.ibm.com>
      Cc: T Makphaibulchoke <tmac@hp.com>
      Cc: Wen Congyang <wency@cn.fujitsu.com>
      Cc: Tang Chen <tangchen@cn.fujitsu.com>
      Cc: Jiang Liu <jiang.liu@huawei.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ae8e3a91
    • S
      mm: rewrite the comment over migrate_pages() more comprehensibly · c73e5c9c
      Srivatsa S. Bhat 提交于
      The comment over migrate_pages() looks quite weird, and makes it hard to
      grasp what it is trying to say.  Rewrite it more comprehensibly.
      Signed-off-by: NSrivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
      Acked-by: NChristoph Lameter <cl@linux.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Hugh Dickins <hughd@google.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      c73e5c9c
    • M
      THP: fix comment about memory barrier · 52f37629
      Minchan Kim 提交于
      Currently the memory barrier in __do_huge_pmd_anonymous_page doesn't
      work.  Because lru_cache_add_lru uses pagevec so it could miss spinlock
      easily so above rule was broken so user might see inconsistent data.
      
      I was not first person who pointed out the problem.  Mel and Peter
      pointed out a few months ago and Peter pointed out further that even
      spin_lock/unlock can't make sure of it:
      
        http://marc.info/?t=134333512700004
      
      	In particular:
      
              	*A = a;
              	LOCK
              	UNLOCK
              	*B = b;
      
      	may occur as:
      
              	LOCK, STORE *B, STORE *A, UNLOCK
      
      At last, Hugh pointed out that even we don't need memory barrier in
      there because __SetPageUpdate already have done it from Nick's commit
      0ed361de ("mm: fix PageUptodate data race") explicitly.
      
      So this patch fixes comment on THP and adds same comment for
      do_anonymous_page, too because everybody except Hugh was missing that.
      It means we need a comment about that.
      Signed-off-by: NMinchan Kim <minchan@kernel.org>
      Acked-by: NAndrea Arcangeli <aarcange@redhat.com>
      Acked-by: NDavid Rientjes <rientjes@google.com>
      Acked-by: NKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      52f37629
    • Y
      mm: remove CONFIG_HOTPLUG ifdefs · f1cb0879
      Yijing Wang 提交于
      CONFIG_HOTPLUG is going away as an option, cleanup CONFIG_HOTPLUG
      ifdefs in mm files.
      Signed-off-by: NYijing Wang <wangyijing@huawei.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: NRik van Riel <riel@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f1cb0879
    • M
      mm/memcontrol.c: remove unnecessary ; · 573b400d
      Michel Lespinasse 提交于
      Just a trivial issue I stumbled on while doing something else...
      Signed-off-by: NMichel Lespinasse <walken@google.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      573b400d