From: Abhishek Bapat <abhishekbapat@google.com>
To: Suren Baghdasaryan <surenb@google.com>, Hao Ge <hao.ge@linux.dev>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
linux-trace-kernel@vger.kernel.org,
Abhishek Bapat <abhishekbapat@google.com>
Subject: [PATCH v5 3/5] alloc_tag: Add a flags field to allocinfo_filter
Date: Wed, 4 Nov 2026 19:03:38 +0000 [thread overview]
Message-ID: <64ce5ba6eedf0950c22d1416b794e83afbab8ea8.1793818636.git.abhishekbapat@google.com> (raw)
In-Reply-To: <cover.1793818636.git.abhishekbapat@google.com>
struct allocinfo_filter uses a whole __u64 to hold the single boolean
used by the accuracy filter. Adding another boolean criterion the same
way would grow struct allocinfo_get_at, which changes the
ALLOCINFO_IOC_GET_AT ioctl number and breaks the UAPI.
Add a `flags` field that shares storage with `inaccurate` through an
anonymous union, and use bit 0, ALLOCINFO_FILTER_FLAG_INACCURATE, for
the accuracy criterion. New boolean criteria can take the remaining
bits without changing the struct layout.
Keeping `inaccurate` in the union means userspace built against the
older API still compiles, and the values 0 and 1 keep their meaning.
Previously any non-zero value selected inaccurate tags; now only bit 0
is checked, so a value such as 2 selects accurate tags instead.
Signed-off-by: Abhishek Bapat <abhishekbapat@google.com>
---
include/uapi/linux/alloc_tag.h | 16 ++++++++++++++--
mm/alloc_tag.c | 2 +-
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/include/uapi/linux/alloc_tag.h b/include/uapi/linux/alloc_tag.h
index dafcba2f7e2c..2fc843bb06bc 100644
--- a/include/uapi/linux/alloc_tag.h
+++ b/include/uapi/linux/alloc_tag.h
@@ -68,13 +68,25 @@ enum {
#define ALLOCINFO_FILTER_MASKS \
((1 << (__ALLOCINFO_FILTER_LAST + 1)) - 1)
+#define ALLOCINFO_FILTER_FLAG_INACCURATE (1ULL << 0)
+
struct allocinfo_filter {
__u64 mask; /* bitmask of the filter fields used */
struct allocinfo_tag fields;
__u64 min_size;
__u64 max_size;
- /* filter criteria only; see allocinfo_counter.accurate for actual accuracy */
- __u64 inaccurate;
+ /*
+ * Filter criteria only; see allocinfo_counter for the actual state.
+ * Set ALLOCINFO_FILTER_FLAG_* bits in flags for the criteria selected
+ * in mask. inaccurate is kept as an alias of flags so that userspace
+ * built against the older API still compiles. Note that only
+ * ALLOCINFO_FILTER_FLAG_INACCURATE is checked, so a non-zero value
+ * with bit 0 clear no longer selects inaccurate tags.
+ */
+ union {
+ __u64 inaccurate;
+ __u64 flags;
+ };
};
struct allocinfo_get_at {
diff --git a/mm/alloc_tag.c b/mm/alloc_tag.c
index 9ff9dd04d692..504c1a85050d 100644
--- a/mm/alloc_tag.c
+++ b/mm/alloc_tag.c
@@ -306,7 +306,7 @@ static bool matches_filter(struct codetag *ct, struct allocinfo_filter *filter,
if (filter->mask & ALLOCINFO_FILTER_MASK_INACCURATE) {
inaccurate = alloc_tag_is_inaccurate(ct_to_alloc_tag(ct));
- if (inaccurate != !!(filter->inaccurate))
+ if (inaccurate != !!(filter->flags & ALLOCINFO_FILTER_FLAG_INACCURATE))
return false;
}
--
2.56.0.506.g506a7eabc5-goog
next prev parent reply other threads:[~2026-11-04 19:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 19:03 [PATCH v5 0/5] alloc_tag: Introduce selective tracing for MAP Abhishek Bapat
2026-11-04 19:03 ` [PATCH v5 1/5] alloc_tag: Add trace events for tracing allocations Abhishek Bapat
2026-11-04 19:03 ` [PATCH v5 2/5] alloc_tag: Introduce IOCTLs to toggle allocation tracepoints Abhishek Bapat
2026-11-05 15:15 ` kernel test robot
2026-11-06 1:21 ` Andrew Morton
2026-11-06 7:54 ` Hao Ge
2026-11-06 15:26 ` Andrew Morton
2026-11-04 19:03 ` Abhishek Bapat [this message]
2026-11-04 19:03 ` [PATCH v5 4/5] alloc_tag: Extend allocinfo_filter to support tracing queries Abhishek Bapat
2026-11-04 19:03 ` [PATCH v5 5/5] alloc_tag: Add a test for trace state toggle and filtering Abhishek Bapat
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=64ce5ba6eedf0950c22d1416b794e83afbab8ea8.1793818636.git.abhishekbapat@google.com \
--to=abhishekbapat@google.com \
--cc=akpm@linux-foundation.org \
--cc=hao.ge@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=surenb@google.com \
/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®