瀏覽代碼

qcacmn: Reduce spinlock time in qdf_net_buf_debug_look_up

Improve hash function to better utilize the memory entropy.
Do memory allocation outside of the spinlock.

Change-Id: Ife7da44c81463bfa9bcf19850d98471f5c61d3f3
CRs-Fixed: 1013620
Houston Hoffman 9 年之前
父節點
當前提交
10749156e4
共有 1 個文件被更改,包括 8 次插入3 次删除
  1. 8 3
      qdf/linux/src/qdf_nbuf.c

+ 8 - 3
qdf/linux/src/qdf_nbuf.c

@@ -634,7 +634,9 @@ uint32_t qdf_net_buf_debug_hash(qdf_nbuf_t net_buf)
 {
 	uint32_t i;
 
-	i = (uint32_t) ((uintptr_t) net_buf & (QDF_NET_BUF_TRACK_MAX_SIZE - 1));
+	i = (uint32_t) (((uintptr_t) net_buf) >> 4);
+	i += (uint32_t) (((uintptr_t) net_buf) >> 14);
+	i &= (QDF_NET_BUF_TRACK_MAX_SIZE - 1);
 
 	return i;
 }
@@ -675,6 +677,9 @@ void qdf_net_buf_debug_add_node(qdf_nbuf_t net_buf, size_t size,
 	uint32_t i;
 	unsigned long irq_flag;
 	QDF_NBUF_TRACK *p_node;
+	QDF_NBUF_TRACK *new_node;
+
+	new_node = (QDF_NBUF_TRACK *) qdf_mem_malloc(sizeof(*new_node));
 
 	spin_lock_irqsave(&g_qdf_net_buf_track_lock, irq_flag);
 
@@ -687,10 +692,10 @@ void qdf_net_buf_debug_add_node(qdf_nbuf_t net_buf, size_t size,
 			  p_node->net_buf, p_node->file_name, p_node->line_num,
 			  net_buf, file_name, line_num);
 		QDF_ASSERT(0);
+		qdf_mem_free(new_node);
 		goto done;
 	} else {
-		p_node = (QDF_NBUF_TRACK *)
-			 qdf_mem_malloc(sizeof(*p_node));
+		p_node = new_node;
 		if (p_node) {
 			p_node->net_buf = net_buf;
 			p_node->file_name = file_name;