linux/mm
Igor Redko 30416b602f mm/page_alloc.c: calculate 'available' memory in a separate function
commit d02bd27bd3 upstream.

Add a new field, VIRTIO_BALLOON_S_AVAIL, to virtio_balloon memory
statistics protocol, corresponding to 'Available' in /proc/meminfo.

It indicates to the hypervisor how big the balloon can be inflated
without pushing the guest system to swap.  This metric would be very
useful in VM orchestration software to improve memory management of
different VMs under overcommit.

This patch (of 2):

Factor out calculation of the available memory counter into a separate
exportable function, in order to be able to use it in other parts of the
kernel.

In particular, it appears a relevant metric to report to the hypervisor
via virtio-balloon statistics interface (in a followup patch).

Signed-off-by: Igor Redko <redkoi@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[bwh: Backported to 3.16 as dependency of commit a1078e821b
 "xen: let alloc_xenballooned_pages() fail if not enough memory free"]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2019-08-13 12:39:28 +01:00
..
backing-dev.c block: fix bdi vs gendisk lifetime mismatch 2016-11-20 01:17:05 +00:00
balloon_compaction.c mm/balloon_compaction: fix deflation when compaction is disabled 2016-06-15 21:29:35 +01:00
bootmem.c mem-hotplug: reset node managed pages when hot-adding a new pgdat 2014-11-27 11:21:50 +00:00
cleancache.c mm: dump page when hitting a VM_BUG_ON using VM_BUG_ON_PAGE 2014-01-23 16:36:50 -08:00
compaction.c mm/balloon_compaction: redesign ballooned pages management 2016-06-15 21:29:35 +01:00
debug-pagealloc.c mm, x86: Remove debug_pagealloc_enabled 2011-12-06 09:24:07 +01:00
dmapool.c Fix unbalanced mutex in dma_pool_create(). 2014-10-05 13:41:09 -07:00
early_ioremap.c mm: create generic early_ioremap() support 2014-04-07 16:36:15 -07:00
fadvise.c teach SYSCALL_DEFINE<n> how to deal with long long/unsigned long long 2013-03-03 22:46:22 -05:00
failslab.c switch debugfs to umode_t 2012-01-03 22:54:56 -05:00
filemap.c mm/filemap.c: fix NULL pointer in page_cache_tree_insert() 2018-10-21 08:45:34 +01:00
filemap_xip.c mm: drop vm_ops->remap_pages and generic_file_remap_pages() stub 2018-10-03 04:09:51 +01:00
frontswap.c mm: frontswap: invalidate expired data on a dup-store failure 2014-12-10 17:49:41 +00:00
gup.c mm: remove rest usage of VM_NONLINEAR and pte_file() 2018-10-03 04:09:52 +01:00
highmem.c Some nice cleanups, and even a patch my wife did as a "live" demo for 2012-12-20 08:37:05 -08:00
huge_memory.c mremap: properly flush TLB before releasing the page 2018-12-16 22:09:45 +00:00
hugetlb.c mm: migration: fix migration of huge PMD shared pages 2019-04-04 16:14:08 +01:00
hugetlb_cgroup.c cgroup: remove css_parent() 2014-05-16 13:22:48 -04:00
hwpoison-inject.c mm/hwpoison: add '#' to hwpoison_inject 2014-01-21 16:19:48 -08:00
init-mm.c mm: Add a user_ns owner to mm_struct and fix ptrace permission checks 2018-01-01 20:52:10 +00:00
internal.h mm, compaction: properly signal and act upon lock and need_sched() contention 2014-06-04 16:54:11 -07:00
interval_tree.c mm: replace vma->sharead.linear with vma->shared 2018-10-03 04:09:52 +01:00
iov_iter.c Fix thinko in iov_iter_single_seg_count 2014-11-27 11:21:48 +00:00
Kconfig mm/zsmalloc: make zsmalloc module-buildable 2014-06-04 16:54:14 -07:00
Kconfig.debug mm: more intensive memory corruption debugging 2012-01-10 16:30:42 -08:00
kmemcheck.c kmemcheck: Fix build errors due to missing slab.h 2010-03-30 22:02:32 +09:00
kmemleak-test.c mm/kmemleak-test.c: use pr_fmt for logging 2014-06-06 16:08:18 -07:00
kmemleak.c mm: kmemleak: allow safe memory scanning during kmemleak disabling 2015-07-15 10:00:54 +01:00
ksm.c mm/ksm.c: ignore STABLE_FLAG of rmap_item->address in rmap_walk_ksm() 2018-11-20 18:05:14 +00:00
list_lru.c mm: keep page cache radix tree nodes in check 2014-04-03 16:21:01 -07:00
maccess.c mm: Map most files to use export.h instead of module.h 2011-10-31 09:20:12 -04:00
madvise.c mm: madvise(MADV_DODUMP): allow hugetlbfs pages 2018-12-16 22:09:38 +00:00
Makefile mm: replace remap_file_pages() syscall with emulation 2018-10-03 04:09:50 +01:00
memblock.c memblock, memhotplug: fix wrong type in memblock_find_in_range_node(). 2014-10-05 13:41:03 -07:00
memcontrol.c mm: remove rest usage of VM_NONLINEAR and pte_file() 2018-10-03 04:09:52 +01:00
memory-failure.c mm: hwpoison: use do_send_sig_info() instead of force_sig() 2019-05-02 21:41:34 +01:00
memory.c mm: introduce vma_is_anonymous(vma) helper 2019-06-20 18:11:26 +01:00
memory_hotplug.c hwpoison, memory_hotplug: allow hwpoisoned pages to be offlined 2019-04-04 16:14:09 +01:00
mempolicy.c mm/mempolicy.c: avoid use uninitialized preferred_node 2018-06-16 22:22:47 +01:00
mempool.c mm/mempool.c: update the kmemleak stack trace for mempool allocations 2014-06-06 16:08:17 -07:00
migrate.c mm: migrate: don't rely on __PageMovable() of newpage after unlocking it 2019-05-02 21:41:34 +01:00
mincore.c mm/mincore.c: make mincore() more conservative 2019-06-20 18:11:26 +01:00
mlock.c mm: do not bug_on on incorrect length in __mm_populate() 2018-11-20 18:05:41 +00:00
mm_init.c mm: bring back /sys/kernel/mm 2014-01-27 21:02:39 -08:00
mmap.c coredump: fix race condition between mmget_not_zero()/get_task_mm() and core dumping 2019-05-02 21:42:04 +01:00
mmu_context.c mm/mmu_context, sched/core: Fix mmu_context.h assumption 2018-01-09 00:35:08 +00:00
mmu_notifier.c mm: audit/fix non-modular users of module_init in core code 2014-01-23 16:36:52 -08:00
mmzone.c mm: numa: Change page last {nid,pid} into {cpu,pid} 2013-10-09 14:47:45 +02:00
mprotect.c x86/speculation/l1tf: Disallow non privileged high MMIO PROT_NONE mappings 2018-10-03 04:10:02 +01:00
mremap.c mremap: properly flush TLB before releasing the page 2018-12-16 22:09:45 +00:00
msync.c mm: remove rest usage of VM_NONLINEAR and pte_file() 2018-10-03 04:09:52 +01:00
nobootmem.c mem-hotplug: reset node managed pages when hot-adding a new pgdat 2014-11-27 11:21:50 +00:00
nommu.c mm: replace remap_file_pages() syscall with emulation 2018-10-03 04:09:50 +01:00
oom_kill.c mm, oom: fix use-after-free in oom_kill_process 2019-05-02 21:41:34 +01:00
page-writeback.c writeback: use |1 instead of +1 to protect against div by zero 2015-05-20 13:25:57 +01:00
page_alloc.c mm/page_alloc.c: calculate 'available' memory in a separate function 2019-08-13 12:39:28 +01:00
page_cgroup.c swap: cond_resched in swap_cgroup_prepare() 2017-09-15 18:30:12 +01:00
page_io.c fix __swap_writepage() compile failure on old gcc versions 2014-06-14 19:30:48 -05:00
page_isolation.c mm: fix invalid node in alloc_migrate_target() 2016-05-01 00:06:08 +02:00
pagewalk.c pagewalk: improve vma handling 2018-10-03 04:10:02 +01:00
percpu-km.c percpu: clear memory allocated with the km allocator 2010-10-02 10:28:42 +03:00
percpu-vm.c percpu: perform tlb flush after pcpu_map_pages() failure 2014-10-05 13:41:06 -07:00
percpu.c percpu: stop printing kernel addresses 2019-05-11 15:22:49 +01:00
pgtable-generic.c mm: fix TLB flush race between migration, and change_protection_range 2013-12-18 19:04:51 -08:00
process_vm_access.c ptrace: use fsuid, fsgid, effective creds for fs access checks 2017-09-15 18:30:17 +01:00
quicklist.c mm: delete various needless include <linux/module.h> 2011-10-31 09:20:11 -04:00
readahead.c mm/readahead.c: inline ra_submit 2014-04-07 16:35:58 -07:00
rmap.c mm: migration: fix migration of huge PMD shared pages 2019-04-04 16:14:08 +01:00
shmem.c tmpfs: fix uninitialized return value in shmem_link 2019-05-02 21:42:00 +01:00
slab.c cpuset: PF_SPREAD_PAGE and PF_SPREAD_SLAB should be atomic flags 2017-10-12 15:28:22 +01:00
slab.h memcg, slab: merge memcg_{bind,release}_pages to memcg_{un}charge_slab 2014-06-04 16:54:01 -07:00
slab_common.c Merge branch 'slab/urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/penberg/linux into for-3.16-rcX 2014-07-22 18:38:27 -04:00
slob.c slab: get_online_mems for kmem_cache_{create,destroy,shrink} 2014-06-04 16:53:59 -07:00
slub.c slub/memcg: cure the brainless abuse of sysfs attributes 2017-09-15 18:29:54 +01:00
sparse-vmemmap.c mm/sparse: use memblock apis for early memory allocations 2014-01-21 16:19:47 -08:00
sparse.c mm: use macros from compiler.h instead of __attribute__((...)) 2014-04-07 16:35:54 -07:00
swap.c rmap: drop support of non-linear mappings 2018-10-03 04:09:51 +01:00
swap_state.c mm: page_alloc: convert hot/cold parameter and immediate callers to bool 2014-06-04 16:54:09 -07:00
swapfile.c mm, swap: bounds check swap_info array accesses to avoid NULL derefs 2019-07-09 22:04:13 +01:00
truncate.c mm: cleancache: fix corruption on missed inode invalidation 2018-12-16 22:09:45 +00:00
util.c fs/proc: Stop trying to report thread stacks 2018-11-20 18:05:58 +00:00
vmacache.c mm: get rid of vmacache_flush_all() entirely 2018-09-25 23:47:35 +01:00
vmalloc.c mm/vmalloc: fix size check for remap_vmalloc_range_partial() 2019-07-09 22:04:12 +01:00
vmpressure.c mm: vmpressure: fix sending wrong events on underflow 2017-06-05 21:17:16 +01:00
vmscan.c mm: fix the NULL mapping case in __isolate_lru_page() 2018-06-16 22:22:04 +01:00
vmstat.c mm/vmstat.c: fix /proc/vmstat format for CONFIG_DEBUG_TLBFLUSH=y CONFIG_SMP=n 2019-08-13 12:39:12 +01:00
workingset.c mm: workingset: fix crash in shadow node shrinker caused by replace_page_cache_page() 2016-11-20 01:17:36 +00:00
zbud.c mm/zbud.c: make size unsigned like unique callsite 2014-06-04 16:54:13 -07:00
zsmalloc.c zsmalloc: fixup trivial zs size classes value in comments 2014-06-04 16:54:13 -07:00
zswap.c mm/zswap: NUMA aware allocation for zswap_dstmem 2014-06-04 16:54:14 -07:00