浏览代码

qcacmn: Update global frag counter and frag debug nodes refcount

The current logic for decrementing the global frag counter and
refcount for the frag debug nodes does not take into consideration
the no. of users of nbuf.

Decrement global frag counter and frag debug nodes refcount only
when no. of users of nbuf is 1.

Change-Id: I5b88691f7e3e9b7e29e19479c3a3c12e70c0f311
CRs-Fixed: 2776170
Harsh Kumar Bijlani 4 年之前
父节点
当前提交
1f7706356f
共有 1 个文件被更改,包括 17 次插入1 次删除
  1. 17 1
      qdf/linux/src/qdf_nbuf.c

+ 17 - 1
qdf/linux/src/qdf_nbuf.c

@@ -581,7 +581,14 @@ void __qdf_nbuf_free(struct sk_buff *skb)
 	if (pld_nbuf_pre_alloc_free(skb))
 		return;
 
-	qdf_frag_count_dec(qdf_nbuf_get_nr_frags(skb));
+	/**
+	 * Decrement global frag counter only when last user of nbuf
+	 * does free so as to avoid decrementing count on every free
+	 * expect the last one in case where nbuf has multiple users
+	 */
+	if (qdf_nbuf_get_users(skb) == 1)
+		qdf_frag_count_dec(qdf_nbuf_get_nr_frags(skb));
+
 	qdf_nbuf_count_dec(skb);
 	qdf_mem_skb_dec(skb->truesize);
 	if (nbuf_free_cb)
@@ -4783,6 +4790,15 @@ void qdf_net_buf_debug_release_frag(qdf_nbuf_t buf, const char *func,
 	if (qdf_unlikely(!buf))
 		return;
 
+	/**
+	 * Decrement refcount for frag debug nodes only when last user
+	 * of nbuf calls this API so as to avoid decrementing refcount
+	 * on every call expect the last one in case where nbuf has multiple
+	 * users
+	 */
+	if (qdf_nbuf_get_users(buf) > 1)
+		return;
+
 	/* Take care to update the refcount in the debug entries for frags */
 	num_nr_frags = qdf_nbuf_get_nr_frags(buf);