Skip to contentSkip to conversation

perf: Make the mlock accounting simple again

PATCH Applied Alexander Shishkin 3 participants 3 messages Nov 20, 2019 – Nov 21, 2019 perf events

lore
Share & tools
lore

Alexander Shishkin

author reviewer
#0 lore raw

PATCH 1/1 perf: Make the mlock accounting simple again

Commit

d44248a41337 ("perf/core: Rework memory accounting in perf_mmap()")

does a lot of things to the mlock accounting arithmetics, while the only thing that actually needed to happen is subtracting the part that is charged to the mm from the part that is charged to the user, so that the former isn't charged twice.

---
 kernel/events/core.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
kernel/events/core.c +1 -7
index 522438887206..059ee7116008 100644
@@ -5886,13 +5886,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
 
 	user_locked = atomic_long_read(&user->locked_vm) + user_extra;
 
-	if (user_locked <= user_lock_limit) {
-		/* charge all to locked_vm */
-	} else if (atomic_long_read(&user->locked_vm) >= user_lock_limit) {
-		/* charge all to pinned_vm */
-		extra = user_extra;
-		user_extra = 0;
-	} else {
+	if (user_locked > user_lock_limit) {
 		/*
 		 * charge locked_vm until it hits user_lock_limit;
 		 * charge the rest from pinned_vm
Signature · 1 line
2.24.0
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Alexander Shishkin

Commit

d44248a41337 ("perf/core: Rework memory accounting in perf_mmap()")

Quoted 7 lines

does a lot of things to the mlock accounting arithmetics, while the only thing that actually needed to happen is subtracting the part that is charged to the mm from the part that is charged to the user, so that the former isn't charged twice.

Thanks for the fix!

#2 lore raw

[tip: perf/urgent] perf/core: Make the mlock accounting simple again

In reply to Alexander Shishkin
The following commit has been merged into the perf/urgent branch of tip:

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     c4b75479741c9c3a4f0abff5baa5013d27640ac1
Gitweb:        https://git.kernel.org/tip/c4b75479741c9c3a4f0abff5baa5013d27640ac1
Author:        Alexander Shishkin <[email protected]>
AuthorDate:    Wed, 20 Nov 2019 19:06:40 +02:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Thu, 21 Nov 2019 07:37:50 +01:00

perf/core: Make the mlock accounting simple again

Commit:

d44248a41337 ("perf/core: Rework memory accounting in perf_mmap()")

does a lot of things to the mlock accounting arithmetics, while the only thing that actually needed to happen is subtracting the part that is charged to the mm from the part that is charged to the user, so that the former isn't charged twice.

---
 kernel/events/core.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
kernel/events/core.c +1 -7
index 8f66a48..7e8980d 100644
@@ -5825,13 +5825,7 @@ accounting:
 
 	user_locked = atomic_long_read(&user->locked_vm) + user_extra;
 
-	if (user_locked <= user_lock_limit) {
-		/* charge all to locked_vm */
-	} else if (atomic_long_read(&user->locked_vm) >= user_lock_limit) {
-		/* charge all to pinned_vm */
-		extra = user_extra;
-		user_extra = 0;
-	} else {
+	if (user_locked > user_lock_limit) {
 		/*
 		 * charge locked_vm until it hits user_lock_limit;
 		 * charge the rest from pinned_vm