Extend the allocinfo filtering mechanism to allow users to filter tags based on their accuracy. Signed-off-by: Abhishek Bapat --- include/uapi/linux/alloc_tag.h | 3 +++ lib/alloc_tag.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/include/uapi/linux/alloc_tag.h b/include/uapi/linux/alloc_tag.h index 229068efd24c..99dfe951b185 100644 --- a/include/uapi/linux/alloc_tag.h +++ b/include/uapi/linux/alloc_tag.h @@ -20,6 +20,7 @@ struct allocinfo_tag { char function[ALLOCINFO_STR_SIZE]; char filename[ALLOCINFO_STR_SIZE]; __u64 lineno; + __u64 inaccurate; __u64 min_size; __u64 max_size; }; @@ -41,6 +42,7 @@ enum { ALLOCINFO_FILTER_FUNCTION, ALLOCINFO_FILTER_FILENAME, ALLOCINFO_FILTER_LINENO, + ALLOCINFO_FILTER_INACCURATE, ALLOCINFO_FILTER_MIN_SIZE, ALLOCINFO_FILTER_MAX_SIZE, __ALLOCINFO_FILTER_LAST = ALLOCINFO_FILTER_MAX_SIZE @@ -50,6 +52,7 @@ enum { #define ALLOCINFO_FILTER_MASK_FUNCTION (1 << ALLOCINFO_FILTER_FUNCTION) #define ALLOCINFO_FILTER_MASK_FILENAME (1 << ALLOCINFO_FILTER_FILENAME) #define ALLOCINFO_FILTER_MASK_LINENO (1 << ALLOCINFO_FILTER_LINENO) +#define ALLOCINFO_FILTER_MASK_INACCURATE (1 << ALLOCINFO_FILTER_INACCURATE) #define ALLOCINFO_FILTER_MASK_MIN_SIZE (1 << ALLOCINFO_FILTER_MIN_SIZE) #define ALLOCINFO_FILTER_MASK_MAX_SIZE (1 << ALLOCINFO_FILTER_MAX_SIZE) diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c index 98a27c302928..576ecb3c5b6c 100644 --- a/lib/alloc_tag.c +++ b/lib/alloc_tag.c @@ -197,6 +197,7 @@ static bool matches_filter(struct codetag *ct, struct allocinfo_filter *filter) { struct alloc_tag *tag; struct alloc_tag_counters counters; + bool inaccurate; if (!ct || !filter || !filter->mask) return true; @@ -217,6 +218,12 @@ static bool matches_filter(struct codetag *ct, struct allocinfo_filter *filter) ct->lineno != filter->fields.lineno) return false; + if (filter->mask & ALLOCINFO_FILTER_MASK_INACCURATE) { + inaccurate = !!(ct->flags & CODETAG_FLAG_INACCURATE); + if (inaccurate != filter->fields.inaccurate) + return false; + } + if ((filter->mask & ALLOCINFO_FILTER_MASK_MIN_SIZE) || (filter->mask & ALLOCINFO_FILTER_MASK_MAX_SIZE)) { tag = ct_to_alloc_tag(ct); -- 2.54.0.545.g6539524ca2-goog