public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libfc: add stats info against memory leakage in exchange pool
@ 2010-10-24  9:30 Hillf Danton
  2010-10-26 13:24 ` Hillf Danton
  0 siblings, 1 reply; 4+ messages in thread
From: Hillf Danton @ 2010-10-24  9:30 UTC (permalink / raw)
  To: devel; +Cc: linux-scsi

There seems stats info needed if mem leak is concerned.

Signed-off-by: Hillf Danton <dhillf@gmail.com>
---

--- a/drivers/scsi/libfc/fc_exch.c	2010-09-13 07:07:38.000000000 +0800
+++ b/drivers/scsi/libfc/fc_exch.c	2010-10-24 17:10:08.000000000 +0800
@@ -67,6 +67,11 @@ struct workqueue_struct *fc_exch_workque
 struct fc_exch_pool {
 	u16		 next_index;
 	u16		 total_exches;
+
+	/* stats info against memory leakage */
+	atomic_t	 allocated;
+	atomic_t	 released;
+
 	spinlock_t	 lock;
 	struct list_head ex_list;
 };
@@ -405,6 +410,8 @@ static void fc_exch_delete(struct fc_exc
 	fc_exch_ptr_set(pool, (ep->xid - ep->em->min_xid) >> fc_cpu_order,
 			NULL);
 	list_del(&ep->ex_list);
+	if (1 == atomic_read(&ep->ex_refcnt))
+		atomic_inc(&pool->released);
 	spin_unlock_bh(&pool->lock);
 	fc_exch_release(ep);	/* drop hold for exch in mp */
 }
@@ -689,6 +696,7 @@ static struct fc_exch *fc_exch_em_alloc(
 	pool->next_index = index == mp->pool_max_index ? 0 : index + 1;

 	fc_exch_hold(ep);	/* hold for exch in mp */
+	atomic_inc(&pool->allocated);
 	spin_lock_init(&ep->ex_lock);
 	/*
 	 * Hold exch lock for caller to prevent fc_exch_reset()
@@ -1699,6 +1707,12 @@ restart:
 			goto restart;
 		}
 	}
+	if (atomic_read(&pool->allocated) != atomic_read(&pool->released))
+		printk(KERN_WARNING "libfc: host %u exch pool %p "
+			"allocated %d released %d\n",
+			lport->host->host_no, pool,
+			atomic_read(&pool->allocated),
+			atomic_read(&pool->released));
 	spin_unlock_bh(&pool->lock);
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-10-28 13:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-24  9:30 [PATCH] libfc: add stats info against memory leakage in exchange pool Hillf Danton
2010-10-26 13:24 ` Hillf Danton
2010-10-28  0:49   ` [Open-FCoE] " Robert Love
2010-10-28 13:53     ` Hillf Danton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox