aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/scripts/python/bin
diff options
context:
space:
mode:
authorHugh Dickins <hughd@google.com>2012-07-11 14:02:47 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-11 16:04:48 -0700
commitd189922862e03ce6c7adc1e99d3b94e632dc8e89 (patch)
treef3408f4208ae51eefac07292dfa559257658d2d8 /tools/perf/scripts/python/bin
parenttmpfs: revert SEEK_DATA and SEEK_HOLE (diff)
downloadlinux-d189922862e03ce6c7adc1e99d3b94e632dc8e89.tar.gz
linux-d189922862e03ce6c7adc1e99d3b94e632dc8e89.zip
shmem: fix negative rss in memcg memory.stat
When adding the page_private checks before calling shmem_replace_page(), I did realize that there is a further race, but thought it too unlikely to need a hurried fix. But independently I've been chasing why a mem cgroup's memory.stat sometimes shows negative rss after all tasks have gone: I expected it to be a stats gathering bug, but actually it's shmem swapping's fault. It's an old surprise, that when you lock_page(lookup_swap_cache(swap)), the page may have been removed from swapcache before getting the lock; or it may have been freed and reused and be back in swapcache; and it can even be using the same swap location as before (page_private same). The swapoff case is already secure against this (swap cannot be reused until the whole area has been swapped off, and a new swapped on); and shmem_getpage_gfp() is protected by shmem_add_to_page_cache()'s check for the expected radix_tree entry - but a little too late. By that time, we might have already decided to shmem_replace_page(): I don't know of a problem from that, but I'd feel more at ease not to do so spuriously. And we have already done mem_cgroup_cache_charge(), on perhaps the wrong mem cgroup: and this charge is not then undone on the error path, because PageSwapCache ends up preventing that. It's this last case which causes the occasional negative rss in memory.stat: the page is charged here as cache, but (sometimes) found to be anon when eventually it's uncharged - and in between, it's an undeserved charge on the wrong memcg. Fix this by adding an earlier check on the radix_tree entry: it's inelegant to descend the tree twice, but swapping is not the fast path, and a better solution would need a pair (try+commit) of memcg calls, and a rework of shmem_replace_page() to keep out of the swapcache. We can use the added shmem_confirm_swap() function to replace the find_get_page+page_cache_release we were already doing on the error path. And add a comment on that -EEXIST: it seems a peculiar errno to be using, but originates from its use in radix_tree_insert(). [It can be surprising to see positive rss left in a memcg's memory.stat after all tasks have gone, since it is supposed to count anonymous but not shmem. Aside from sharing anon pages via fork with a task in some other memcg, it often happens after swapping: because a swap page can't be freed while under writeback, nor while locked. So it's not an error, and these residual pages are easily freed once pressure demands.] Signed-off-by: Hugh Dickins <hughd@google.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Michal Hocko <mhocko@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'tools/perf/scripts/python/bin')
0 files changed, 0 insertions, 0 deletions
td>2-0/+8 2013-02-25IB/srp: Avoid endless SCSI error handling loopBart Van Assche1-14/+15 2013-02-25IB/srp: Avoid sending a task management function needlesslyBart Van Assche1-2/+3 2013-02-25IB/srp: Track connection state properlyBart Van Assche1-1/+0 2013-02-25IB/mlx4: Remove redundant NULL check before kfreeSyam Sidhardhan1-2/+1 2013-02-25IB/mlx4: Fix compiler warning about uninitialized 'vlan' variablePaul Bolle1-1/+1 2013-02-25IB/mlx4: Convert is_xxx variables in build_mlx_header() to boolRoland Dreier2-6/+6 2013-02-26block: fix part_pack_uuid() build errorMimi Zohar2-5/+16 2013-02-26ima: "remove enforce checking duplication" merge fixMimi Zohar1-1/+2 2013-02-25ARM: DMA-mapping: fix memory leak in IOMMU dma-mapping implementationMarek Szyprowski1-3/+3 2013-02-25ARM: dma-mapping: Add maximum alignment order for dma iommu buffersSeung-Woo Kim2-0/+24 2013-02-25ARM: dma-mapping: use himem for DMA buffers for IOMMU-mapped devicesMarek Szyprowski1-2/+7 2013-02-25ARM: dma-mapping: add support for CMA regions placed in highmem zoneMarek Szyprowski1-15/+42 2013-02-25arm: dma mapping: export arm iommu functionsPrathyush K1-0/+4 2013-02-25ARM: dma-mapping: Add arm_iommu_detach_device()Hiroshi Doyu2-0/+26 2013-02-25ARM: dma-mapping: Add macro to_dma_iommu_mapping()Hiroshi Doyu1-0/+6 2013-02-25ARM: dma-mapping: Set arm_dma_set_mask() for iommu->set_dma_mask()Hiroshi Doyu1-0/+4 2013-02-25ARM: iommu: Include linux/kref.h in asm/dma-iommu.hLaurent Pinchart1-0/+1 2013-02-25ARM: KVM: fix compilation after removal of user_alloc from struct kvm_memory_...Marc Zyngier1-5/+0 2013-02-25ARM: KVM: Rename KVM_MEMORY_SLOTS -> KVM_USER_MEM_SLOTSMarc Zyngier1-1/+1 2013-02-25ARM: KVM: fix kvm_arch_{prepare,commit}_memory_regionMarc Zyngier1-2/+2 2013-02-24net/pasemi: Fix missing coding styleSyam Sidhardhan1-3/+6 2013-02-24tty vt: fix character insertion overflowNicolas Pitre1-1/+1 2013-02-24vmxnet3: fix ethtool ring buffer size settingNeil Horman1-4/+2 2013-02-24vmxnet3: make local function staticstephen hemminger1-2/+2 2013-02-24bnx2x: remove dead code and make local funcs staticstephen hemminger2-60/+2 2013-02-24mmc: tegra: assume CONFIG_OF, remove platform dataStephen Warren2-102/+45 2013-02-24mmc: add DT bindings for more MMC capability flagsGuennadi Liakhovetski2-0/+17 2013-02-24mmc: tmio: add support for the VccQ regulatorGuennadi Liakhovetski1-10/+46 2013-02-24mmc: tmio: remove unused and deprecated symbolsGuennadi Liakhovetski1-18/+0 2013-02-24mmc: sh_mobile_sdhi: use managed resource allocationsGuennadi Liakhovetski1-43/+14 2013-02-24mmc: sh_mobile_sdhi: remove unused .pdata fieldGuennadi Liakhovetski2-6/+0 2013-02-24mmc: tmio-mmc: parse device-tree bindingsGuennadi Liakhovetski2-8/+44