[PATCH 3/3] mm: kmemleak: mark variables as __read_mostly

Luiz Capitulino posted 3 patches 9 months, 1 week ago
[PATCH 3/3] mm: kmemleak: mark variables as __read_mostly
Posted by Luiz Capitulino 9 months, 1 week ago
The variables kmemleak_enabled and kmemleak_free_enabled are read in the
kmemleak alloc and free path respectively, but are only written to if/when
kmemleak is disabled.

Signed-off-by: Luiz Capitulino <luizcap@redhat.com>
---
 mm/kmemleak.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 06baa3475252..da9cee34ee1b 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -210,9 +210,9 @@ static struct kmem_cache *object_cache;
 static struct kmem_cache *scan_area_cache;
 
 /* set if tracing memory operations is enabled */
-static int kmemleak_enabled = 1;
+static int kmemleak_enabled __read_mostly = 1;
 /* same as above but only for the kmemleak_free() callback */
-static int kmemleak_free_enabled = 1;
+static int kmemleak_free_enabled __read_mostly = 1;
 /* set in the late_initcall if there were no errors */
 static int kmemleak_late_initialized;
 /* set if a fatal kmemleak error has occurred */
-- 
2.49.0
Re: [PATCH 3/3] mm: kmemleak: mark variables as __read_mostly
Posted by Catalin Marinas 9 months, 1 week ago
On Wed, Apr 30, 2025 at 04:59:47PM -0400, Luiz Capitulino wrote:
> The variables kmemleak_enabled and kmemleak_free_enabled are read in the
> kmemleak alloc and free path respectively, but are only written to if/when
> kmemleak is disabled.
> 
> Signed-off-by: Luiz Capitulino <luizcap@redhat.com>

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>