[Devel] [PATCH rh7] mm: memcontrol: drop useless VM_BUG_ON's in memcg_{start, stop}_kmem_account

Vladimir Davydov vdavydov at virtuozzo.com
Fri May 20 04:18:54 PDT 2016


No point in them, really - if these are called from a kernel thread or
by a dying process nothing bad is going to happen.

Quite the contrary, having them will result in KP if any of those is
called after exit_mm. An example goes below:

  kernel BUG at mm/memcontrol.c:3358!
  invalid opcode: 0000 [#1] SMP
  CPU: 13 PID: 35647 Comm: mailsrvanalog ve: 1000 Not tainted 3.10.0-327.10.1.ovz.12.17+ #863 12.17
  task: ffff8800a0188cb0 ti: ffff88005634c000 task.ti: ffff88005634c000
  RIP: 0010:[<ffffffff811e9b55>]  [<ffffffff811e9b55>] memcg_stop_kmem_account+0x25/0x30
  RSP: 0018:ffff88005634fd00  EFLAGS: 00010246
  RAX: ffff8800a0188cb0 RBX: ffff880118b580b0 RCX: ffff88005634fd39
  RDX: 0000000000000033 RSI: ffff88005634fd36 RDI: 0000000000000035
  RBP: ffff88005634fd00 R08: ffff880118b58000 R09: 00000000bed7ff49
  R10: 000000007c640f5b R11: 00000000b6f8c81e R12: ffff880036aa4000
  R13: ffff88005634fdc4 R14: ffff880118b58130 R15: ffff88009f440020
  FS:  0000000000000000(0000) GS:ffff88014b140000(0000) knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: 00007fcbdb0977c0 CR3: 000000000194e000 CR4: 00000000000006e0
  DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
  DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
  Stack:
   ffff88005634fd80 ffffffffa01ab5f6 ffff880144cf1f20 ffff8800364a38c0
   2078696674736f50 737973206c69616d 336300800a6d6574 643332343339342f
   3839336165356264 6236373636343735 3232626364373932 0033353639653465
  Call Trace:
   [<ffffffffa01ab5f6>] ext4_open_pfcache+0xc6/0x1a0 [ext4]
   [<ffffffffa01abd59>] ext4_save_data_csum+0xc9/0x150 [ext4]
   [<ffffffffa01aca3c>] ext4_commit_data_csum+0xac/0xd0 [ext4]
   [<ffffffffa01570bc>] ext4_release_file+0xdc/0xf0 [ext4]
   [<ffffffff811ffea1>] __fput+0xe1/0x250
   [<ffffffff8120001e>] ____fput+0xe/0x10
   [<ffffffff810a40f4>] task_work_run+0xc4/0xe0
   [<ffffffff8108216b>] do_exit+0x2eb/0xb10
   [<ffffffff81642984>] ? __do_page_fault+0x164/0x450
   [<ffffffff81082a0f>] do_group_exit+0x3f/0xa0
   [<ffffffff81082a84>] SyS_exit_group+0x14/0x20
   [<ffffffff81647489>] system_call_fastpath+0x16/0x1b

Also, let's move memcg_{start,stop}_kmem_account to the header as they
both are tiny.

Fixes: 6812907ce7c3 ("pfcache: do not account peer files to memcg")
Signed-off-by: Vladimir Davydov <vdavydov at virtuozzo.com>
---
 include/linux/memcontrol.h | 11 +++++++++--
 mm/memcontrol.c            | 13 -------------
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 1c5f916054be..37ce43221f3c 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -517,8 +517,15 @@ extern int memcg_nr_cache_ids;
 extern void memcg_get_cache_ids(void);
 extern void memcg_put_cache_ids(void);
 
-extern void memcg_stop_kmem_account(void);
-extern void memcg_resume_kmem_account(void);
+static inline void memcg_stop_kmem_account(void)
+{
+	current->memcg_kmem_skip_account++;
+}
+
+static inline void memcg_resume_kmem_account(void)
+{
+	current->memcg_kmem_skip_account--;
+}
 
 /*
  * Helper macro to loop through all memcg-specific caches. Callers must still
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 89c9edfe6ce1..af2c14b88060 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3353,19 +3353,6 @@ static void memcg_free_cache_id(int id)
  * memcg_kmem_skip_account. So we enclose anything that might allocate memory
  * inside the following two functions.
  */
-void memcg_stop_kmem_account(void)
-{
-	VM_BUG_ON(!current->mm);
-	current->memcg_kmem_skip_account++;
-}
-EXPORT_SYMBOL(memcg_stop_kmem_account);
-
-void memcg_resume_kmem_account(void)
-{
-	VM_BUG_ON(!current->mm);
-	current->memcg_kmem_skip_account--;
-}
-EXPORT_SYMBOL(memcg_resume_kmem_account);
 
 struct memcg_kmem_cache_create_work {
 	struct mem_cgroup *memcg;
-- 
2.1.4



More information about the Devel mailing list