]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
perf/core: Rework memory accounting in perf_mmap()
authorSong Liu <songliubraving@fb.com>
Wed, 4 Sep 2019 21:46:18 +0000 (14:46 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 12 Nov 2019 17:47:12 +0000 (18:47 +0100)
commit712b583cb873baeb54fb8d8c291149783d1240c0
tree02c6e3d085cc2746ea6ed76f8fa176eaaaf78c19
parent14c5126ec83ecb7ba3959cf6774547bf9e80c787
perf/core: Rework memory accounting in perf_mmap()

BugLink: https://bugs.launchpad.net/bugs/1851550
[ Upstream commit d44248a41337731a111374822d7d4451b64e73e4 ]

perf_mmap() always increases user->locked_vm. As a result, "extra" could
grow bigger than "user_extra", which doesn't make sense. Here is an
example case:

(Note: Assume "user_lock_limit" is very small.)

  | # of perf_mmap calls |vma->vm_mm->pinned_vm|user->locked_vm|
  | 0                    | 0                   | 0             |
  | 1                    | user_extra          | user_extra    |
  | 2                    | 3 * user_extra      | 2 * user_extra|
  | 3                    | 6 * user_extra      | 3 * user_extra|
  | 4                    | 10 * user_extra     | 4 * user_extra|

Fix this by maintaining proper user_extra and extra.

Reviewed-By: Hechao Li <hechaol@fb.com>
Reported-by: Hechao Li <hechaol@fb.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: <kernel-team@fb.com>
Cc: Jie Meng <jmeng@fb.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20190904214618.3795672-1-songliubraving@fb.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Connor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
kernel/events/core.c