aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorVladimir Davydov <vdavydov@virtuozzo.com>2016-01-14 18:18:21 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-01-14 19:00:49 -0500
commit5d097056c9a017a3b720849efb5432f37acabbac (patch)
treee960a2513a789101097e97cfda27b247ef8650eb /fs/xfs
parent37f08dda29dac8a595999b8d3eaa9bf0f763dd9d (diff)
kmemcg: account certain kmem allocations to memcg
Mark those kmem allocations that are known to be easily triggered from userspace as __GFP_ACCOUNT/SLAB_ACCOUNT, which makes them accounted to memcg. For the list, see below: - threadinfo - task_struct - task_delay_info - pid - cred - mm_struct - vm_area_struct and vm_region (nommu) - anon_vma and anon_vma_chain - signal_struct - sighand_struct - fs_struct - files_struct - fdtable and fdtable->full_fds_bits - dentry and external_name - inode for all filesystems. This is the most tedious part, because most filesystems overwrite the alloc_inode method. The list is far from complete, so feel free to add more objects. Nevertheless, it should be close to "account everything" approach and keep most workloads within bounds. Malevolent users will be able to breach the limit, but this was possible even with the former "account everything" approach (simply because it did not account everything in fact). [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Vladimir Davydov <vdavydov@virtuozzo.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Tejun Heo <tj@kernel.org> Cc: Greg Thelen <gthelen@google.com> Cc: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@kernel.org> Cc: David Rientjes <rientjes@google.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/kmem.h1
-rw-r--r--fs/xfs/xfs_super.c4
2 files changed, 3 insertions, 2 deletions
diff --git a/fs/xfs/kmem.h b/fs/xfs/kmem.h
index cc6b768fc068..d1c66e465ca5 100644
--- a/fs/xfs/kmem.h
+++ b/fs/xfs/kmem.h
@@ -84,6 +84,7 @@ kmem_zalloc(size_t size, xfs_km_flags_t flags)
84#define KM_ZONE_HWALIGN SLAB_HWCACHE_ALIGN 84#define KM_ZONE_HWALIGN SLAB_HWCACHE_ALIGN
85#define KM_ZONE_RECLAIM SLAB_RECLAIM_ACCOUNT 85#define KM_ZONE_RECLAIM SLAB_RECLAIM_ACCOUNT
86#define KM_ZONE_SPREAD SLAB_MEM_SPREAD 86#define KM_ZONE_SPREAD SLAB_MEM_SPREAD
87#define KM_ZONE_ACCOUNT SLAB_ACCOUNT
87 88
88#define kmem_zone kmem_cache 89#define kmem_zone kmem_cache
89#define kmem_zone_t struct kmem_cache 90#define kmem_zone_t struct kmem_cache
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index b35775752b74..59c9b7bd958d 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1714,8 +1714,8 @@ xfs_init_zones(void)
1714 1714
1715 xfs_inode_zone = 1715 xfs_inode_zone =
1716 kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode", 1716 kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode",
1717 KM_ZONE_HWALIGN | KM_ZONE_RECLAIM | KM_ZONE_SPREAD, 1717 KM_ZONE_HWALIGN | KM_ZONE_RECLAIM | KM_ZONE_SPREAD |
1718 xfs_fs_inode_init_once); 1718 KM_ZONE_ACCOUNT, xfs_fs_inode_init_once);
1719 if (!xfs_inode_zone) 1719 if (!xfs_inode_zone)
1720 goto out_destroy_efi_zone; 1720 goto out_destroy_efi_zone;
1721 1721