Commit 4b9bc86d authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Martin K. Petersen

fcoe: convert to kworker

The driver creates its own per-CPU threads which are updated based on
CPU hotplug events. It is also possible to use kworkers and remove some
of the kthread infrastrucure.

The code checked ->thread to decide if there is an active per-CPU
thread. By using the kworker infrastructure this is no longer
possible (or required). The thread pointer is saved in `kthread' instead
of `thread' so anything trying to use thread is caught by the
compiler. Currently only the bnx2fc driver is using struct fcoe_percpu_s
and the kthread member.

After a CPU went offline, we may still enqueue items on the "offline"
CPU. This isn't much of a problem. The work will be done on a random
CPU. The allocated crc_eof_page page won't be cleaned up. It is probably
expected that the CPU comes up at some point so it should not be a
problem. The crc_eof_page memory is released of course once the module
is removed.

This patch was only compile-tested due to -ENODEV.

Cc: Vasu Dev <vasu.dev@intel.com>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: fcoe-devel@open-fcoe.org
Cc: linux-scsi@vger.kernel.org
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Tested-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 49a75815
...@@ -486,7 +486,7 @@ static int bnx2fc_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -486,7 +486,7 @@ static int bnx2fc_rcv(struct sk_buff *skb, struct net_device *dev,
__skb_queue_tail(&bg->fcoe_rx_list, skb); __skb_queue_tail(&bg->fcoe_rx_list, skb);
if (bg->fcoe_rx_list.qlen == 1) if (bg->fcoe_rx_list.qlen == 1)
wake_up_process(bg->thread); wake_up_process(bg->kthread);
spin_unlock(&bg->fcoe_rx_list.lock); spin_unlock(&bg->fcoe_rx_list.lock);
...@@ -2715,7 +2715,7 @@ static int __init bnx2fc_mod_init(void) ...@@ -2715,7 +2715,7 @@ static int __init bnx2fc_mod_init(void)
} }
wake_up_process(l2_thread); wake_up_process(l2_thread);
spin_lock_bh(&bg->fcoe_rx_list.lock); spin_lock_bh(&bg->fcoe_rx_list.lock);
bg->thread = l2_thread; bg->kthread = l2_thread;
spin_unlock_bh(&bg->fcoe_rx_list.lock); spin_unlock_bh(&bg->fcoe_rx_list.lock);
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
...@@ -2788,8 +2788,8 @@ static void __exit bnx2fc_mod_exit(void) ...@@ -2788,8 +2788,8 @@ static void __exit bnx2fc_mod_exit(void)
/* Destroy global thread */ /* Destroy global thread */
bg = &bnx2fc_global; bg = &bnx2fc_global;
spin_lock_bh(&bg->fcoe_rx_list.lock); spin_lock_bh(&bg->fcoe_rx_list.lock);
l2_thread = bg->thread; l2_thread = bg->kthread;
bg->thread = NULL; bg->kthread = NULL;
while ((skb = __skb_dequeue(&bg->fcoe_rx_list)) != NULL) while ((skb = __skb_dequeue(&bg->fcoe_rx_list)) != NULL)
kfree_skb(skb); kfree_skb(skb);
......
This diff is collapsed.
...@@ -319,14 +319,16 @@ struct fcoe_transport { ...@@ -319,14 +319,16 @@ struct fcoe_transport {
/** /**
* struct fcoe_percpu_s - The context for FCoE receive thread(s) * struct fcoe_percpu_s - The context for FCoE receive thread(s)
* @thread: The thread context * @kthread: The thread context (used by bnx2fc)
* @work: The work item (used by fcoe)
* @fcoe_rx_list: The queue of pending packets to process * @fcoe_rx_list: The queue of pending packets to process
* @page: The memory page for calculating frame trailer CRCs * @page: The memory page for calculating frame trailer CRCs
* @crc_eof_offset: The offset into the CRC page pointing to available * @crc_eof_offset: The offset into the CRC page pointing to available
* memory for a new trailer * memory for a new trailer
*/ */
struct fcoe_percpu_s { struct fcoe_percpu_s {
struct task_struct *thread; struct task_struct *kthread;
struct work_struct work;
struct sk_buff_head fcoe_rx_list; struct sk_buff_head fcoe_rx_list;
struct page *crc_eof_page; struct page *crc_eof_page;
int crc_eof_offset; int crc_eof_offset;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment