mirror of
git://nv-tegra.nvidia.com/linux-nv-oot.git
synced 2025-12-22 09:11:26 +03:00
video: tegra: nvmap: Avoid double updation of RSS counter
The RSS counter is updated during buffer allocation as well as mmap,
which is leading to double updation. Fix this by decrementing the RSS
counter during page fault while increment it back during unmap flow.
Bug 5222690
Change-Id: I77972185f20d9d710571cc07ae1c5188060bfa1f
Signed-off-by: Ketan Patil <ketanp@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3442670
(cherry picked from commit 1c59063ce7)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3453106
Tested-by: Amulya Yarlagadda <ayarlagadda@nvidia.com>
Reviewed-by: Amulya Yarlagadda <ayarlagadda@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
committed by
Amulya Yarlagadda
parent
5fc4079741
commit
08fbba8f59
@@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2011-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
* Copyright (c) 2011-2025, NVIDIA CORPORATION. All rights reserved.
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) "%s: " fmt, __func__
|
||||
@@ -147,6 +147,14 @@ static void nvmap_vma_close(struct vm_area_struct *vma)
|
||||
BUG_ON(!vma_found);
|
||||
nvmap_umaps_dec(h);
|
||||
|
||||
mutex_lock(&priv->vma_lock);
|
||||
if (priv->mm != NULL && h->anon_count != 0) {
|
||||
nvmap_add_mm_counter(priv->mm, MM_ANONPAGES, priv->map_rss_count);
|
||||
priv->map_rss_count = 0;
|
||||
priv->mm = NULL;
|
||||
}
|
||||
mutex_unlock(&priv->vma_lock);
|
||||
|
||||
if (__atomic_add_unless(&priv->count, -1, 0) == 1) {
|
||||
if (h->heap_pgalloc) {
|
||||
for (i = 0; i < nr_page; i++) {
|
||||
@@ -233,6 +241,14 @@ static int nvmap_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
||||
return VM_FAULT_SIGSEGV;
|
||||
}
|
||||
|
||||
mutex_lock(&priv->vma_lock);
|
||||
if (priv->handle->anon_count != 0 && current->mm != NULL) {
|
||||
nvmap_add_mm_counter(current->mm, MM_ANONPAGES, -1);
|
||||
priv->map_rss_count++;
|
||||
priv->mm = current->mm;
|
||||
}
|
||||
mutex_unlock(&priv->vma_lock);
|
||||
|
||||
if (!nvmap_handle_track_dirty(priv->handle))
|
||||
goto finish;
|
||||
mutex_lock(&priv->handle->lock);
|
||||
|
||||
Reference in New Issue
Block a user