mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhen Lei <thunder.leizhen@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	<linux-kernel@vger.kernel.org>
Cc: Zhen Lei <thunder.leizhen@huawei.com>
Subject: [PATCH v2 1/6] debugobjects: Fix the compilation attributes of some global variables
Date: Wed, 4 Sep 2024 21:39:39 +0800	[thread overview]
Message-ID: <20240904133944.2124-2-thunder.leizhen@huawei.com> (raw)
In-Reply-To: <20240904133944.2124-1-thunder.leizhen@huawei.com>

1. Both debug_objects_pool_min_level and debug_objects_pool_size are
   read-only after initialization, change attribute '__read_mostly' to
   '__ro_after_init', and remove '__data_racy'.
2. Many global variables are read in the debug_stats_show() function, but
   didn't mask KCSAN's detection. Add '__data_racy' for them.

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
 lib/debugobjects.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index 7cea91e193a8f04..7226fdb5e129a79 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -70,10 +70,10 @@ static HLIST_HEAD(obj_to_free);
  * made at debug_stats_show(). Both obj_pool_min_free and obj_pool_max_used
  * can be off.
  */
-static int			obj_pool_min_free = ODEBUG_POOL_SIZE;
-static int			obj_pool_free = ODEBUG_POOL_SIZE;
+static int __data_racy		obj_pool_min_free = ODEBUG_POOL_SIZE;
+static int __data_racy		obj_pool_free = ODEBUG_POOL_SIZE;
 static int			obj_pool_used;
-static int			obj_pool_max_used;
+static int __data_racy		obj_pool_max_used;
 static bool			obj_freeing;
 /* The number of objs on the global free list */
 static int			obj_nr_tofree;
@@ -84,9 +84,9 @@ static int __data_racy			debug_objects_fixups __read_mostly;
 static int __data_racy			debug_objects_warnings __read_mostly;
 static int __data_racy			debug_objects_enabled __read_mostly
 					= CONFIG_DEBUG_OBJECTS_ENABLE_DEFAULT;
-static int __data_racy			debug_objects_pool_size __read_mostly
+static int				debug_objects_pool_size __ro_after_init
 					= ODEBUG_POOL_SIZE;
-static int __data_racy			debug_objects_pool_min_level __read_mostly
+static int				debug_objects_pool_min_level __ro_after_init
 					= ODEBUG_POOL_MIN_LEVEL;
 
 static const struct debug_obj_descr *descr_test  __read_mostly;
@@ -95,8 +95,8 @@ static struct kmem_cache	*obj_cache __ro_after_init;
 /*
  * Track numbers of kmem_cache_alloc()/free() calls done.
  */
-static int			debug_objects_allocated;
-static int			debug_objects_freed;
+static int __data_racy		debug_objects_allocated;
+static int __data_racy		debug_objects_freed;
 
 static void free_obj_work(struct work_struct *work);
 static DECLARE_DELAYED_WORK(debug_obj_work, free_obj_work);
-- 
2.34.1


  reply	other threads:[~2024-09-04 13:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-04 13:39 [PATCH v2 0/6] debugobjects: Do some minor optimizations, fixes and cleaups Zhen Lei
2024-09-04 13:39 ` Zhen Lei [this message]
2024-09-09 14:59   ` [tip: core/debugobjects] debugobjects: Fix the compilation attributes of some global variables tip-bot2 for Zhen Lei
2024-09-04 13:39 ` [PATCH v2 2/6] debugobjects: Fix the misuse of global variables in fill_pool() Zhen Lei
2024-09-09 14:59   ` [tip: core/debugobjects] debugobjects: Fix conditions " tip-bot2 for Zhen Lei
2024-09-04 13:39 ` [PATCH v2 3/6] debugobjects: Remove redundant checks " Zhen Lei
2024-09-09 14:59   ` [tip: core/debugobjects] " tip-bot2 for Zhen Lei
2024-09-04 13:39 ` [PATCH v2 4/6] debugobjects: Don't start fill if there are remaining nodes locally Zhen Lei
2024-09-05  3:11   ` Leizhen (ThunderTown)
2024-09-05  3:45     ` Leizhen (ThunderTown)
2024-09-05  7:04       ` Leizhen (ThunderTown)
2024-09-09  9:22       ` Thomas Gleixner
2024-09-09 11:03         ` Leizhen (ThunderTown)
2024-09-09 12:10         ` Thomas Gleixner
2024-09-09 13:51           ` Leizhen (ThunderTown)
2024-09-09 14:35             ` Thomas Gleixner
2024-09-09 14:41               ` Thomas Gleixner
2024-09-10  6:13               ` Leizhen (ThunderTown)
2024-09-10 15:29             ` Leizhen (ThunderTown)
2024-09-11  1:21               ` Leizhen (ThunderTown)
2024-09-04 13:39 ` [PATCH v2 5/6] debugobjects: Use hlist_splice_init() to reduce lock conflicts Zhen Lei
2024-09-04 13:39 ` [PATCH v2 6/6] debugobjects: Delete a piece of redundant code Zhen Lei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240904133944.2124-2-thunder.leizhen@huawei.com \
    --to=thunder.leizhen@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®