[PATCH 13/21] trace: don't use GENMASK()

Yury Norov (NVIDIA)
2025-10-25T16:33:22Z

GENMASK(high, low) notation is confusing. FIRST_BITS() is more
appropriate.

Signed-off-by: Yury Norov (NVIDIA) <yury.norov@gmail.com>
---
kernel/trace/fgraph.c | 10 +++++-----
kernel/trace/trace_probe.h | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
index 484ad7a18463..4f21bd837055 100644
--- a/kernel/trace/fgraph.c
+++ b/kernel/trace/fgraph.c
@@ -106,10 +106,10 @@
* (RESERVED or BITMAP)
*/
#define FGRAPH_FRAME_OFFSET_BITS 10
-#define FGRAPH_FRAME_OFFSET_MASK GENMASK(FGRAPH_FRAME_OFFSET_BITS - 1, 0)
+#define FGRAPH_FRAME_OFFSET_MASK FIRST_BITS(FGRAPH_FRAME_OFFSET_BITS)

#define FGRAPH_TYPE_BITS 2
-#define FGRAPH_TYPE_MASK GENMASK(FGRAPH_TYPE_BITS - 1, 0)
+#define FGRAPH_TYPE_MASK FIRST_BITS(FGRAPH_TYPE_BITS)
#define FGRAPH_TYPE_SHIFT FGRAPH_FRAME_OFFSET_BITS

enum {
@@ -123,7 +123,7 @@ enum {
* FGRAPH_INDEX (12-27) bits holding the gops index wanting return callback called
*/
#define FGRAPH_INDEX_BITS 16
-#define FGRAPH_INDEX_MASK GENMASK(FGRAPH_INDEX_BITS - 1, 0)
+#define FGRAPH_INDEX_MASK FIRST_BITS(FGRAPH_INDEX_BITS)
#define FGRAPH_INDEX_SHIFT (FGRAPH_TYPE_SHIFT + FGRAPH_TYPE_BITS)

/*
@@ -135,12 +135,12 @@ enum {
* data_size == 0 means 1 word, and 31 (=2^5 - 1) means 32 words.
*/
#define FGRAPH_DATA_BITS 5
-#define FGRAPH_DATA_MASK GENMASK(FGRAPH_DATA_BITS - 1, 0)
+#define FGRAPH_DATA_MASK FIRST_BITS(FGRAPH_DATA_BITS)
#define FGRAPH_DATA_SHIFT (FGRAPH_TYPE_SHIFT + FGRAPH_TYPE_BITS)
#define FGRAPH_MAX_DATA_SIZE (sizeof(long) * (1 << FGRAPH_DATA_BITS))

#define FGRAPH_DATA_INDEX_BITS 4
-#define FGRAPH_DATA_INDEX_MASK GENMASK(FGRAPH_DATA_INDEX_BITS - 1, 0)
+#define FGRAPH_DATA_INDEX_MASK FIRST_BITS(FGRAPH_DATA_INDEX_BITS)
#define FGRAPH_DATA_INDEX_SHIFT (FGRAPH_DATA_SHIFT + FGRAPH_DATA_BITS)

#define FGRAPH_MAX_INDEX \
diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
index 08b5bda24da2..88de129dcde0 100644
--- a/kernel/trace/trace_probe.h
+++ b/kernel/trace/trace_probe.h
@@ -401,7 +401,7 @@ static inline int traceprobe_get_entry_data_size(struct trace_probe *tp)
#define TPARG_FL_USER BIT(4)
#define TPARG_FL_FPROBE BIT(5)
#define TPARG_FL_TPOINT BIT(6)
-#define TPARG_FL_LOC_MASK GENMASK(4, 0)
+#define TPARG_FL_LOC_MASK FIRST_BITS(5)

static inline bool tparg_is_function_entry(unsigned int flags)
{
--
2.43.0