linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] vmalloc: Fix accounting of VmallocUsed with i915
@ 2024-12-11  4:32 Matthew Wilcox (Oracle)
  2024-12-11  4:32 ` [PATCH 2/2] vmalloc: Account memcg per vmalloc Matthew Wilcox (Oracle)
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Matthew Wilcox (Oracle) @ 2024-12-11  4:32 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Matthew Wilcox (Oracle),
	Christoph Hellwig, linux-mm, Johannes Weiner, Michal Hocko,
	Roman Gushchin, Shakeel Butt, Muchun Song, cgroups, stable

If the caller of vmap() specifies VM_MAP_PUT_PAGES (currently only the
i915 driver), we will decrement nr_vmalloc_pages in vfree() without ever
incrementing it.  Check the flag before decrementing the counter.

Fixes: b944afc9d64d (mm: add a VM_MAP_PUT_PAGES flag for vmap)
Cc: stable@vger.kernel.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/vmalloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index f009b21705c1..bc9c91f3b373 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -3382,7 +3382,8 @@ void vfree(const void *addr)
 		__free_page(page);
 		cond_resched();
 	}
-	atomic_long_sub(vm->nr_pages, &nr_vmalloc_pages);
+	if (!(vm->flags & VM_MAP_PUT_PAGES))
+		atomic_long_sub(vm->nr_pages, &nr_vmalloc_pages);
 	kvfree(vm->pages);
 	kfree(vm);
 }
-- 
2.45.2



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-12-11 23:37 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-11  4:32 [PATCH 1/2] vmalloc: Fix accounting of VmallocUsed with i915 Matthew Wilcox (Oracle)
2024-12-11  4:32 ` [PATCH 2/2] vmalloc: Account memcg per vmalloc Matthew Wilcox (Oracle)
2024-12-11  5:06   ` Shakeel Butt
2024-12-11 16:09   ` Johannes Weiner
2024-12-11 16:50     ` Matthew Wilcox
2024-12-11 19:32       ` Shakeel Butt
2024-12-11 20:20         ` Matthew Wilcox
2024-12-11 20:58           ` Shakeel Butt
2024-12-11 21:08             ` Matthew Wilcox
2024-12-11 22:17   ` kernel test robot
2024-12-11 23:36   ` kernel test robot
2024-12-11 15:32 ` [PATCH 1/2] vmalloc: Fix accounting of VmallocUsed with i915 Johannes Weiner
2024-12-11 20:45 ` Shakeel Butt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox