[RFC PATCH 2.6.17-mm1 2/3] ieee1394: coarser locking for tlabel allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Full parallelism in getting and freeing transaction labels of different
nodes is not really required.  Therefore reduce the number of locks for
access to tlabel pools from 63 locks per host to 1 global lock.

Signed-off-by: Stefan Richter <[email protected]>
---
 drivers/ieee1394/ieee1394_transactions.c |   10 ++++++----
 drivers/ieee1394/ieee1394_types.h        |    2 --
 2 files changed, 6 insertions(+), 6 deletions(-)

Index: linux/drivers/ieee1394/ieee1394_types.h
===================================================================
--- linux.orig/drivers/ieee1394/ieee1394_types.h	2006-06-24 09:53:24.000000000 +0200
+++ linux/drivers/ieee1394/ieee1394_types.h	2006-06-24 10:02:15.000000000 +0200
@@ -16,7 +16,6 @@
 /* Transaction Label handling */
 struct hpsb_tlabel_pool {
 	DECLARE_BITMAP(pool, 64);
-	spinlock_t lock;
 #ifdef __BIG_ENDIAN_BITFIELD
 	u32 allocations	:26 __attribute__((packed));
 	u32 next	:6  __attribute__((packed));
@@ -30,7 +29,6 @@ struct hpsb_tlabel_pool {
 #define HPSB_TPOOL_INIT(_tp)			\
 do {						\
 	bitmap_zero((_tp)->pool, 64);		\
-	spin_lock_init(&(_tp)->lock);		\
 	(_tp)->next = 0;			\
 	(_tp)->allocations = 0;			\
 	sema_init(&(_tp)->count, 63);		\
Index: linux/drivers/ieee1394/ieee1394_transactions.c
===================================================================
--- linux.orig/drivers/ieee1394/ieee1394_transactions.c	2006-06-24 09:24:00.000000000 +0200
+++ linux/drivers/ieee1394/ieee1394_transactions.c	2006-06-24 10:08:35.000000000 +0200
@@ -31,6 +31,8 @@
         packet->header[1] = (packet->host->node_id << 16) | (addr >> 32); \
         packet->header[2] = addr & 0xffffffff
 
+static spinlock_t hpsb_tlabel_lock = SPIN_LOCK_UNLOCKED;
+
 static void fill_async_readquad(struct hpsb_packet *packet, u64 addr)
 {
 	PREP_ASYNC_HEAD_ADDRESS(TCODE_READQ);
@@ -149,7 +151,7 @@ int hpsb_get_tlabel(struct hpsb_packet *
 		down(&tp->count);
 	}
 
-	spin_lock_irqsave(&tp->lock, flags);
+	spin_lock_irqsave(&hpsb_tlabel_lock, flags);
 
 	tlabel = find_next_zero_bit(tp->pool, 64, tp->next);
 	if (tlabel > 63)
@@ -160,7 +162,7 @@ int hpsb_get_tlabel(struct hpsb_packet *
 	BUG_ON(test_and_set_bit(tlabel, tp->pool));
 	tp->allocations++;
 
-	spin_unlock_irqrestore(&tp->lock, flags);
+	spin_unlock_irqrestore(&hpsb_tlabel_lock, flags);
 	packet->tlabel = tlabel;
 	return 0;
 }
@@ -188,9 +190,9 @@ void hpsb_free_tlabel(struct hpsb_packet
 
 	BUG_ON(tlabel > 63 || tlabel < 0);
 
-	spin_lock_irqsave(&tp->lock, flags);
+	spin_lock_irqsave(&hpsb_tlabel_lock, flags);
 	BUG_ON(!test_and_clear_bit(tlabel, tp->pool));
-	spin_unlock_irqrestore(&tp->lock, flags);
+	spin_unlock_irqrestore(&hpsb_tlabel_lock, flags);
 
 	up(&tp->count);
 }


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux