aboutsummaryrefslogtreecommitdiffstats
path: root/mm/memcontrol.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-10-23 18:20:57 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-10-23 18:20:57 -0400
commitea1ee5ff1b500ccdc64782ecef13d276afb08f14 (patch)
tree085cb2fc7a5b4b4395f1f13cb05d989aa18bce8e /mm/memcontrol.c
parentef594c421a0f96197f28d205e2ee58a83c1e0e37 (diff)
parente27c5b9d23168cc2cb8fec147ae7ed1f7a2005c3 (diff)
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
Pull block layer fixes from Jens Axboe: "A final set of fixes for 4.3. It is (again) bigger than I would have liked, but it's all been through the testing mill and has been carefully reviewed by multiple parties. Each fix is either a regression fix for this cycle, or is marked stable. You can scold me at KS. The pull request contains: - Three simple fixes for NVMe, fixing regressions since 4.3. From Arnd, Christoph, and Keith. - A single xen-blkfront fix from Cathy, fixing a NULL dereference if an error is returned through the staste change callback. - Fixup for some bad/sloppy code in nbd that got introduced earlier in this cycle. From Markus Pargmann. - A blk-mq tagset use-after-free fix from Junichi. - A backing device lifetime fix from Tejun, fixing a crash. - And finally, a set of regression/stable fixes for cgroup writeback from Tejun" * 'for-linus' of git://git.kernel.dk/linux-block: writeback: remove broken rbtree_postorder_for_each_entry_safe() usage in cgwb_bdi_destroy() NVMe: Fix memory leak on retried commands block: don't release bdi while request_queue has live references nvme: use an integer value to Linux errno values blk-mq: fix use-after-free in blk_mq_free_tag_set() nvme: fix 32-bit build warning writeback: fix incorrect calculation of available memory for memcg domains writeback: memcg dirty_throttle_control should be initialized with wb->memcg_completions writeback: bdi_writeback iteration must not skip dying ones writeback: fix bdi_writeback iteration in wakeup_dirtytime_writeback() writeback: laptop_mode_timer_fn() needs rcu_read_lock() around bdi_writeback iteration nbd: Add locking for tasks xen-blkfront: check for null drvdata in blkback_changed (XenbusStateClosing)
Diffstat (limited to 'mm/memcontrol.c')
-rw-r--r--mm/memcontrol.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d9b5c817dce8..c57c4423c688 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3741,44 +3741,43 @@ struct wb_domain *mem_cgroup_wb_domain(struct bdi_writeback *wb)
3741/** 3741/**
3742 * mem_cgroup_wb_stats - retrieve writeback related stats from its memcg 3742 * mem_cgroup_wb_stats - retrieve writeback related stats from its memcg
3743 * @wb: bdi_writeback in question 3743 * @wb: bdi_writeback in question
3744 * @pavail: out parameter for number of available pages 3744 * @pfilepages: out parameter for number of file pages
3745 * @pheadroom: out parameter for number of allocatable pages according to memcg
3745 * @pdirty: out parameter for number of dirty pages 3746 * @pdirty: out parameter for number of dirty pages
3746 * @pwriteback: out parameter for number of pages under writeback 3747 * @pwriteback: out parameter for number of pages under writeback
3747 * 3748 *
3748 * Determine the numbers of available, dirty, and writeback pages in @wb's 3749 * Determine the numbers of file, headroom, dirty, and writeback pages in
3749 * memcg. Dirty and writeback are self-explanatory. Available is a bit 3750 * @wb's memcg. File, dirty and writeback are self-explanatory. Headroom
3750 * more involved. 3751 * is a bit more involved.
3751 * 3752 *
3752 * A memcg's headroom is "min(max, high) - used". The available memory is 3753 * A memcg's headroom is "min(max, high) - used". In the hierarchy, the
3753 * calculated as the lowest headroom of itself and the ancestors plus the 3754 * headroom is calculated as the lowest headroom of itself and the
3754 * number of pages already being used for file pages. Note that this 3755 * ancestors. Note that this doesn't consider the actual amount of
3755 * doesn't consider the actual amount of available memory in the system. 3756 * available memory in the system. The caller should further cap
3756 * The caller should further cap *@pavail accordingly. 3757 * *@pheadroom accordingly.
3757 */ 3758 */
3758void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pavail, 3759void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages,
3759 unsigned long *pdirty, unsigned long *pwriteback) 3760 unsigned long *pheadroom, unsigned long *pdirty,
3761 unsigned long *pwriteback)
3760{ 3762{
3761 struct mem_cgroup *memcg = mem_cgroup_from_css(wb->memcg_css); 3763 struct mem_cgroup *memcg = mem_cgroup_from_css(wb->memcg_css);
3762 struct mem_cgroup *parent; 3764 struct mem_cgroup *parent;
3763 unsigned long head_room = PAGE_COUNTER_MAX;
3764 unsigned long file_pages;
3765 3765
3766 *pdirty = mem_cgroup_read_stat(memcg, MEM_CGROUP_STAT_DIRTY); 3766 *pdirty = mem_cgroup_read_stat(memcg, MEM_CGROUP_STAT_DIRTY);
3767 3767
3768 /* this should eventually include NR_UNSTABLE_NFS */ 3768 /* this should eventually include NR_UNSTABLE_NFS */
3769 *pwriteback = mem_cgroup_read_stat(memcg, MEM_CGROUP_STAT_WRITEBACK); 3769 *pwriteback = mem_cgroup_read_stat(memcg, MEM_CGROUP_STAT_WRITEBACK);
3770 *pfilepages = mem_cgroup_nr_lru_pages(memcg, (1 << LRU_INACTIVE_FILE) |
3771 (1 << LRU_ACTIVE_FILE));
3772 *pheadroom = PAGE_COUNTER_MAX;
3770 3773
3771 file_pages = mem_cgroup_nr_lru_pages(memcg, (1 << LRU_INACTIVE_FILE) |
3772 (1 << LRU_ACTIVE_FILE));
3773 while ((parent = parent_mem_cgroup(memcg))) { 3774 while ((parent = parent_mem_cgroup(memcg))) {
3774 unsigned long ceiling = min(memcg->memory.limit, memcg->high); 3775 unsigned long ceiling = min(memcg->memory.limit, memcg->high);
3775 unsigned long used = page_counter_read(&memcg->memory); 3776 unsigned long used = page_counter_read(&memcg->memory);
3776 3777
3777 head_room = min(head_room, ceiling - min(ceiling, used)); 3778 *pheadroom = min(*pheadroom, ceiling - min(ceiling, used));
3778 memcg = parent; 3779 memcg = parent;
3779 } 3780 }
3780
3781 *pavail = file_pages + head_room;
3782} 3781}
3783 3782
3784#else /* CONFIG_CGROUP_WRITEBACK */ 3783#else /* CONFIG_CGROUP_WRITEBACK */