Letting a function argument indicate whether a lock or unlock operation
should be performed is incompatible with compile-time analysis of locking
operations by sparse and Clang. Hence, split codetag_lock_module_list()
into two functions: a function that locks cttype->mod_lock and another
function that unlocks cttype->mod_lock. No functionality has been
changed. See also commit
916cc5167cc6 ("lib: code tagging framework").
Link: https://lore.kernel.org/20260324214226.3684605-1-bvanassche@acm.org
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: Suren Baghdasaryan <surenb@google.com>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
.flags = 0, \
}
-void codetag_lock_module_list(struct codetag_type *cttype, bool lock);
+void codetag_lock_module_list(struct codetag_type *cttype);
bool codetag_trylock_module_list(struct codetag_type *cttype);
+void codetag_unlock_module_list(struct codetag_type *cttype);
struct codetag_iterator codetag_get_ct_iter(struct codetag_type *cttype);
struct codetag *codetag_next_ct(struct codetag_iterator *iter);
loff_t node = *pos;
priv = (struct allocinfo_private *)m->private;
- codetag_lock_module_list(alloc_tag_cttype, true);
+ codetag_lock_module_list(alloc_tag_cttype);
if (node == 0) {
priv->print_header = true;
priv->iter = codetag_get_ct_iter(alloc_tag_cttype);
static void allocinfo_stop(struct seq_file *m, void *arg)
{
- codetag_lock_module_list(alloc_tag_cttype, false);
+ codetag_unlock_module_list(alloc_tag_cttype);
}
static void print_allocinfo_header(struct seq_buf *buf)
return 0;
if (can_sleep)
- codetag_lock_module_list(alloc_tag_cttype, true);
+ codetag_lock_module_list(alloc_tag_cttype);
else if (!codetag_trylock_module_list(alloc_tag_cttype))
return 0;
}
}
- codetag_lock_module_list(alloc_tag_cttype, false);
+ codetag_unlock_module_list(alloc_tag_cttype);
return nr;
}
static DEFINE_MUTEX(codetag_lock);
static LIST_HEAD(codetag_types);
-void codetag_lock_module_list(struct codetag_type *cttype, bool lock)
+void codetag_lock_module_list(struct codetag_type *cttype)
{
- if (lock)
- down_read(&cttype->mod_lock);
- else
- up_read(&cttype->mod_lock);
+ down_read(&cttype->mod_lock);
}
bool codetag_trylock_module_list(struct codetag_type *cttype)
return down_read_trylock(&cttype->mod_lock) != 0;
}
+void codetag_unlock_module_list(struct codetag_type *cttype)
+{
+ up_read(&cttype->mod_lock);
+}
+
struct codetag_iterator codetag_get_ct_iter(struct codetag_type *cttype)
{
struct codetag_iterator iter = {