소스 검색

qcacmn: Add QDF debug capability to track total SKB allocation

Enhance existing SKB leak debug capability to track total
SKB allocation by driver in SLUB debug enabled builds.

Change-Id: I6bb19ab482961febd8bb5adebe8f71e732ff60dd
CRs-Fixed: 2066205
Rajeev Kumar 7 년 전
부모
커밋
bc19894820
3개의 변경된 파일34개의 추가작업 그리고 0개의 파일을 삭제
  1. 15 0
      qdf/inc/qdf_mem.h
  2. 17 0
      qdf/linux/src/qdf_mem.c
  3. 2 0
      qdf/linux/src/qdf_nbuf.c

+ 15 - 0
qdf/inc/qdf_mem.h

@@ -302,5 +302,20 @@ void qdf_mem_multi_pages_free(qdf_device_t osdev,
 int qdf_mem_multi_page_link(qdf_device_t osdev,
 		struct qdf_mem_multi_page_t *pages,
 		uint32_t elem_size, uint32_t elem_count, uint8_t cacheable);
+/**
+ * qdf_mem_skb_inc() - increment total skb allocation size
+ * @size: size to be added
+ *
+ * Return: none
+ */
+void qdf_mem_skb_inc(qdf_size_t size);
+
+/**
+ * qdf_mem_skb_dec() - decrement total skb allocation size
+ * @size: size to be decremented
+ *
+ * Return: none
+ */
+void qdf_mem_skb_dec(qdf_size_t size);
 
 #endif /* __QDF_MEMORY_H */

+ 17 - 0
qdf/linux/src/qdf_mem.c

@@ -107,10 +107,12 @@ static struct dentry *qdf_mem_debugfs_root;
  * struct __qdf_mem_stat - qdf memory statistics
  * @kmalloc:	total kmalloc allocations
  * @dma:	total dma allocations
+ * @skb:	total skb allocations
  */
 static struct __qdf_mem_stat {
 	qdf_atomic_t kmalloc;
 	qdf_atomic_t dma;
+	qdf_atomic_t skb;
 } qdf_mem_stat;
 
 static inline void qdf_mem_kmalloc_inc(qdf_size_t size)
@@ -123,6 +125,11 @@ static inline void qdf_mem_dma_inc(qdf_size_t size)
 	qdf_atomic_add(size, &qdf_mem_stat.dma);
 }
 
+void qdf_mem_skb_inc(qdf_size_t size)
+{
+	qdf_atomic_add(size, &qdf_mem_stat.skb);
+}
+
 static inline void qdf_mem_kmalloc_dec(qdf_size_t size)
 {
 	qdf_atomic_sub(size, &qdf_mem_stat.kmalloc);
@@ -133,6 +140,11 @@ static inline void qdf_mem_dma_dec(qdf_size_t size)
 	qdf_atomic_sub(size, &qdf_mem_stat.dma);
 }
 
+void qdf_mem_skb_dec(qdf_size_t size)
+{
+	qdf_atomic_sub(size, &qdf_mem_stat.skb);
+}
+
 #ifdef MEMORY_DEBUG
 /**
  * struct __qdf_mem_info - memory statistics
@@ -493,6 +505,11 @@ static QDF_STATUS qdf_mem_debugfs_init(void)
 				qdf_mem_debugfs_root,
 				&qdf_mem_stat.dma);
 
+	debugfs_create_atomic_t("skb",
+				S_IRUSR,
+				qdf_mem_debugfs_root,
+				&qdf_mem_stat.skb);
+
 	return QDF_STATUS_SUCCESS;
 }
 

+ 2 - 0
qdf/linux/src/qdf_nbuf.c

@@ -1539,6 +1539,7 @@ void qdf_net_buf_debug_add_node(qdf_nbuf_t net_buf, size_t size,
 			p_node->file_name = file_name;
 			p_node->line_num = line_num;
 			p_node->size = size;
+			qdf_mem_skb_inc(size);
 			p_node->p_next = gp_qdf_net_buf_track_tbl[i];
 			gp_qdf_net_buf_track_tbl[i] = p_node;
 		} else
@@ -1601,6 +1602,7 @@ done:
 			  net_buf);
 		QDF_ASSERT(0);
 	} else {
+		qdf_mem_skb_dec(p_node->size);
 		qdf_nbuf_track_free(p_node);
 	}
 }