summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/linux/codetag.h3
-rw-r--r--lib/alloc_tag.c8
-rw-r--r--lib/codetag.c12
3 files changed, 13 insertions, 10 deletions
diff --git a/include/linux/codetag.h b/include/linux/codetag.h
index 8ea2a5f7c98a..ddae7484ca45 100644
--- a/include/linux/codetag.h
+++ b/include/linux/codetag.h
@@ -74,8 +74,9 @@ struct codetag_iterator {
.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);
diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
index 551cc14bb1fd..d9be1cf5187d 100644
--- a/lib/alloc_tag.c
+++ b/lib/alloc_tag.c
@@ -55,7 +55,7 @@ static void *allocinfo_start(struct seq_file *m, loff_t *pos)
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);
@@ -82,7 +82,7 @@ static void *allocinfo_next(struct seq_file *m, void *arg, loff_t *pos)
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)
@@ -141,7 +141,7 @@ size_t alloc_tag_top_users(struct codetag_bytes *tags, size_t count, bool can_sl
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;
@@ -166,7 +166,7 @@ size_t alloc_tag_top_users(struct codetag_bytes *tags, size_t count, bool can_sl
}
}
- codetag_lock_module_list(alloc_tag_cttype, false);
+ codetag_unlock_module_list(alloc_tag_cttype);
return nr;
}
diff --git a/lib/codetag.c b/lib/codetag.c
index 304667897ad4..4001a7ea6675 100644
--- a/lib/codetag.c
+++ b/lib/codetag.c
@@ -35,12 +35,9 @@ struct codetag_module {
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)
@@ -48,6 +45,11 @@ 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 = {