summaryrefslogtreecommitdiff
path: root/include/linux/alloc_tag.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/alloc_tag.h')
-rw-r--r--include/linux/alloc_tag.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/linux/alloc_tag.h b/include/linux/alloc_tag.h
index d18388c0e9e1..3af5d6a5ced4 100644
--- a/include/linux/alloc_tag.h
+++ b/include/linux/alloc_tag.h
@@ -29,6 +29,27 @@ struct alloc_tag {
struct alloc_tag_counters __percpu *counters;
} __aligned(8);
+#ifdef CONFIG_MEM_ALLOC_PROFILING_DEBUG
+
+#define CODETAG_EMPTY ((void *)1)
+
+static inline bool is_codetag_empty(union codetag_ref *ref)
+{
+ return ref->ct == CODETAG_EMPTY;
+}
+
+static inline void set_codetag_empty(union codetag_ref *ref)
+{
+ if (ref)
+ ref->ct = CODETAG_EMPTY;
+}
+
+#else /* CONFIG_MEM_ALLOC_PROFILING_DEBUG */
+
+static inline bool is_codetag_empty(union codetag_ref *ref) { return false; }
+
+#endif /* CONFIG_MEM_ALLOC_PROFILING_DEBUG */
+
#ifdef CONFIG_MEM_ALLOC_PROFILING
struct codetag_bytes {
@@ -151,6 +172,11 @@ static inline void alloc_tag_sub(union codetag_ref *ref, size_t bytes)
if (!ref || !ref->ct)
return;
+ if (is_codetag_empty(ref)) {
+ ref->ct = NULL;
+ return;
+ }
+
tag = ct_to_alloc_tag(ref->ct);
this_cpu_sub(tag->counters->bytes, bytes);