aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Horman <nhorman@tuxdriver.com>2012-07-06 13:40:05 -0400
committerJames Bottomley <JBottomley@Parallels.com>2012-07-20 03:58:55 -0400
commit95fdd5e980e6eea4579c15043f7a9be6ad63012c (patch)
treee74fcd944435fe471d15e78e901dee32e1b46a98
parent902a45af5c9fad283a530c3bc71225fa6a8e616a (diff)
[SCSI] fcoe: Cleanup locking on fcoe_percpu_receive_thread
Noticed that we can shuffle the code around in fcoe_percpu_receive_thread a bit and avoid taking the fcoe_rx_list lock twice per iteration. This should improve throughput somewhat. With this change we take the lock, and check for new frames in a single critical section. Only if the list is empty do we drop the lock and re-acquire it after being signaled to wake up. Change Notes: v2) did some further cleanup on the patch by replacing the 2nd call of spin_lock/splice_init with a goto to the top of the outer loop. This allows me to change the inner while loop to an if conditional and remove the sencond check of kthread_should_stop. Based on suggestion from Vasu Dev. Signed-off-by: Neil Horman <nhorman@tuxdriver.com> Acked-by: Vasu Dev <vasu.dev@intel.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--drivers/scsi/fcoe/fcoe.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 2b065d26a5ae..078d262ac7cc 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -1851,23 +1851,25 @@ static int fcoe_percpu_receive_thread(void *arg)
1851 1851
1852 set_user_nice(current, -20); 1852 set_user_nice(current, -20);
1853 1853
1854retry:
1854 while (!kthread_should_stop()) { 1855 while (!kthread_should_stop()) {
1855 1856
1856 spin_lock_bh(&p->fcoe_rx_list.lock); 1857 spin_lock_bh(&p->fcoe_rx_list.lock);
1857 skb_queue_splice_init(&p->fcoe_rx_list, &tmp); 1858 skb_queue_splice_init(&p->fcoe_rx_list, &tmp);
1858 spin_unlock_bh(&p->fcoe_rx_list.lock);
1859
1860 while ((skb = __skb_dequeue(&tmp)) != NULL)
1861 fcoe_recv_frame(skb);
1862 1859
1863 spin_lock_bh(&p->fcoe_rx_list.lock); 1860 if (!skb_queue_len(&tmp)) {
1864 if (!skb_queue_len(&p->fcoe_rx_list)) {
1865 set_current_state(TASK_INTERRUPTIBLE); 1861 set_current_state(TASK_INTERRUPTIBLE);
1866 spin_unlock_bh(&p->fcoe_rx_list.lock); 1862 spin_unlock_bh(&p->fcoe_rx_list.lock);
1867 schedule(); 1863 schedule();
1868 set_current_state(TASK_RUNNING); 1864 set_current_state(TASK_RUNNING);
1869 } else 1865 goto retry;
1870 spin_unlock_bh(&p->fcoe_rx_list.lock); 1866 }
1867
1868 spin_unlock_bh(&p->fcoe_rx_list.lock);
1869
1870 while ((skb = __skb_dequeue(&tmp)) != NULL)
1871 fcoe_recv_frame(skb);
1872
1871 } 1873 }
1872 return 0; 1874 return 0;
1873} 1875}