]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
RDMA/hns: Add trace for flush CQE
authorJunxian Huang <huangjunxian6@hisilicon.com>
Mon, 21 Apr 2025 13:27:45 +0000 (21:27 +0800)
committerLeon Romanovsky <leon@kernel.org>
Mon, 21 Apr 2025 18:20:27 +0000 (14:20 -0400)
Add trace to print the producer index of QP when triggering flush CQE.

Output example:
$ cat /sys/kernel/debug/tracing/trace
  tracer: nop

  entries-in-buffer/entries-written: 2/2   #P:128

                                 _-----=> irqs-off/BH-disabled
                                / _----=> need-resched
                               | / _---=> hardirq/softirq
                               || / _--=> preempt-depth
                               ||| / _-=> migrate-disable
                               |||| /     delay
            TASK-PID     CPU#  |||||  TIMESTAMP  FUNCTION
               | |         |   |||||     |         |
      ib_send_bw-11474   [075] d..1.  2393.434738: hns_sq_flush_cqe: SQ 0x2 flush head 0xb5c7.
      ib_send_bw-11474   [075] d..1.  2393.434739: hns_rq_flush_cqe: RQ 0x2 flush head 0.

Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
Link: https://patch.msgid.link/20250421132750.1363348-2-huangjunxian6@hisilicon.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/hns/hns_roce_device.h
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
drivers/infiniband/hw/hns/hns_roce_trace.h [new file with mode: 0644]

index 560a1d9de408fffd150c542f5a601c1550715eaa..080bd049b0f8d4f68e0109a4850ad50a58247cac 100644 (file)
@@ -1027,6 +1027,23 @@ struct hns_roce_dev {
        atomic64_t *dfx_cnt;
 };
 
+enum hns_roce_trace_type {
+       TRACE_SQ,
+       TRACE_RQ,
+};
+
+static inline const char *trace_type_to_str(enum hns_roce_trace_type type)
+{
+       switch (type) {
+       case TRACE_SQ:
+               return "SQ";
+       case TRACE_RQ:
+               return "RQ";
+       default:
+               return "UNKNOWN";
+       }
+}
+
 static inline struct hns_roce_dev *to_hr_dev(struct ib_device *ib_dev)
 {
        return container_of(ib_dev, struct hns_roce_dev, ib_dev);
index c6399490e3a5d31d791a3a07471321d085f4ec1a..e1c27c9556fd205f979b5fcb52d9cb2db39e7fcd 100644 (file)
@@ -50,6 +50,9 @@
 #include "hns_roce_hem.h"
 #include "hns_roce_hw_v2.h"
 
+#define CREATE_TRACE_POINTS
+#include "hns_roce_trace.h"
+
 enum {
        CMD_RST_PRC_OTHERS,
        CMD_RST_PRC_SUCCESS,
@@ -5312,6 +5315,7 @@ static void v2_set_flushed_fields(struct ib_qp *ibqp,
                return;
 
        spin_lock_irqsave(&hr_qp->sq.lock, sq_flag);
+       trace_hns_sq_flush_cqe(hr_qp->qpn, hr_qp->sq.head, TRACE_SQ);
        hr_reg_write(context, QPC_SQ_PRODUCER_IDX, hr_qp->sq.head);
        hr_reg_clear(qpc_mask, QPC_SQ_PRODUCER_IDX);
        hr_qp->state = IB_QPS_ERR;
@@ -5321,6 +5325,7 @@ static void v2_set_flushed_fields(struct ib_qp *ibqp,
                return;
 
        spin_lock_irqsave(&hr_qp->rq.lock, rq_flag);
+       trace_hns_rq_flush_cqe(hr_qp->qpn, hr_qp->rq.head, TRACE_RQ);
        hr_reg_write(context, QPC_RQ_PRODUCER_IDX, hr_qp->rq.head);
        hr_reg_clear(qpc_mask, QPC_RQ_PRODUCER_IDX);
        spin_unlock_irqrestore(&hr_qp->rq.lock, rq_flag);
diff --git a/drivers/infiniband/hw/hns/hns_roce_trace.h b/drivers/infiniband/hw/hns/hns_roce_trace.h
new file mode 100644 (file)
index 0000000..3deace3
--- /dev/null
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2025 Hisilicon Limited.
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM hns_roce
+
+#if !defined(__HNS_ROCE_TRACE_H) || defined(TRACE_HEADER_MULTI_READ)
+#define __HNS_ROCE_TRACE_H
+
+#include <linux/tracepoint.h>
+#include "hns_roce_device.h"
+
+DECLARE_EVENT_CLASS(flush_head_template,
+                   TP_PROTO(unsigned long qpn, u32 pi,
+                            enum hns_roce_trace_type type),
+                   TP_ARGS(qpn, pi, type),
+
+                   TP_STRUCT__entry(__field(unsigned long, qpn)
+                                    __field(u32, pi)
+                                    __field(enum hns_roce_trace_type, type)
+                   ),
+
+                   TP_fast_assign(__entry->qpn = qpn;
+                                  __entry->pi = pi;
+                                  __entry->type = type;
+                   ),
+
+                   TP_printk("%s 0x%lx flush head 0x%x.",
+                             trace_type_to_str(__entry->type),
+                             __entry->qpn, __entry->pi)
+);
+
+DEFINE_EVENT(flush_head_template, hns_sq_flush_cqe,
+            TP_PROTO(unsigned long qpn, u32 pi,
+                     enum hns_roce_trace_type type),
+            TP_ARGS(qpn, pi, type));
+DEFINE_EVENT(flush_head_template, hns_rq_flush_cqe,
+            TP_PROTO(unsigned long qpn, u32 pi,
+                     enum hns_roce_trace_type type),
+            TP_ARGS(qpn, pi, type));
+
+#endif /* __HNS_ROCE_TRACE_H */
+
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE hns_roce_trace
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH .
+#include <trace/define_trace.h>