[SCSI] fcoe: Use percpu kernel funcs for struct fcoe_percpu_s
Convert fcoe_percpu array to use the per-cpu variables that the kernel provides. Use the kernel's functions to access this structure. The cpu member of the fcoe_percpu_s is no longer needed, so this patch removes it too. Signed-off-by: Yi Zou <yi.zou@intel.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
This commit is contained in:
parent
38eccabd10
commit
5e5e92df49
2 changed files with 43 additions and 52 deletions
|
@ -65,7 +65,7 @@ MODULE_LICENSE("GPL");
|
||||||
LIST_HEAD(fcoe_hostlist);
|
LIST_HEAD(fcoe_hostlist);
|
||||||
DEFINE_RWLOCK(fcoe_hostlist_lock);
|
DEFINE_RWLOCK(fcoe_hostlist_lock);
|
||||||
DEFINE_TIMER(fcoe_timer, NULL, 0, 0);
|
DEFINE_TIMER(fcoe_timer, NULL, 0, 0);
|
||||||
struct fcoe_percpu_s *fcoe_percpu[NR_CPUS];
|
DEFINE_PER_CPU(struct fcoe_percpu_s, fcoe_percpu);
|
||||||
|
|
||||||
|
|
||||||
/* Function Prototyes */
|
/* Function Prototyes */
|
||||||
|
@ -226,6 +226,7 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *dev,
|
||||||
fr->fr_dev = lp;
|
fr->fr_dev = lp;
|
||||||
fr->ptype = ptype;
|
fr->ptype = ptype;
|
||||||
cpu_idx = 0;
|
cpu_idx = 0;
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
/*
|
/*
|
||||||
* The incoming frame exchange id(oxid) is ANDed with num of online
|
* The incoming frame exchange id(oxid) is ANDed with num of online
|
||||||
|
@ -235,10 +236,12 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *dev,
|
||||||
* initialize to first online cpu index.
|
* initialize to first online cpu index.
|
||||||
*/
|
*/
|
||||||
cpu_idx = oxid & (num_online_cpus() - 1);
|
cpu_idx = oxid & (num_online_cpus() - 1);
|
||||||
if (!fcoe_percpu[cpu_idx] || !cpu_online(cpu_idx))
|
if (!cpu_online(cpu_idx))
|
||||||
cpu_idx = first_cpu(cpu_online_map);
|
cpu_idx = first_cpu(cpu_online_map);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
fps = fcoe_percpu[cpu_idx];
|
|
||||||
|
fps = &per_cpu(fcoe_percpu, cpu_idx);
|
||||||
|
|
||||||
spin_lock_bh(&fps->fcoe_rx_list.lock);
|
spin_lock_bh(&fps->fcoe_rx_list.lock);
|
||||||
__skb_queue_tail(&fps->fcoe_rx_list, skb);
|
__skb_queue_tail(&fps->fcoe_rx_list, skb);
|
||||||
|
@ -292,15 +295,13 @@ static int fcoe_get_paged_crc_eof(struct sk_buff *skb, int tlen)
|
||||||
{
|
{
|
||||||
struct fcoe_percpu_s *fps;
|
struct fcoe_percpu_s *fps;
|
||||||
struct page *page;
|
struct page *page;
|
||||||
unsigned int cpu_idx;
|
|
||||||
|
|
||||||
cpu_idx = get_cpu();
|
fps = &get_cpu_var(fcoe_percpu);
|
||||||
fps = fcoe_percpu[cpu_idx];
|
|
||||||
page = fps->crc_eof_page;
|
page = fps->crc_eof_page;
|
||||||
if (!page) {
|
if (!page) {
|
||||||
page = alloc_page(GFP_ATOMIC);
|
page = alloc_page(GFP_ATOMIC);
|
||||||
if (!page) {
|
if (!page) {
|
||||||
put_cpu();
|
put_cpu_var(fcoe_percpu);
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
fps->crc_eof_page = page;
|
fps->crc_eof_page = page;
|
||||||
|
@ -320,7 +321,7 @@ static int fcoe_get_paged_crc_eof(struct sk_buff *skb, int tlen)
|
||||||
fps->crc_eof_offset = 0;
|
fps->crc_eof_offset = 0;
|
||||||
put_page(page);
|
put_page(page);
|
||||||
}
|
}
|
||||||
put_cpu();
|
put_cpu_var(fcoe_percpu);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1122,16 +1123,15 @@ EXPORT_SYMBOL_GPL(fcoe_link_ok);
|
||||||
*/
|
*/
|
||||||
void fcoe_percpu_clean(struct fc_lport *lp)
|
void fcoe_percpu_clean(struct fc_lport *lp)
|
||||||
{
|
{
|
||||||
int idx;
|
|
||||||
struct fcoe_percpu_s *pp;
|
struct fcoe_percpu_s *pp;
|
||||||
struct fcoe_rcv_info *fr;
|
struct fcoe_rcv_info *fr;
|
||||||
struct sk_buff_head *list;
|
struct sk_buff_head *list;
|
||||||
struct sk_buff *skb, *next;
|
struct sk_buff *skb, *next;
|
||||||
struct sk_buff *head;
|
struct sk_buff *head;
|
||||||
|
unsigned int cpu;
|
||||||
|
|
||||||
for (idx = 0; idx < NR_CPUS; idx++) {
|
for_each_possible_cpu(cpu) {
|
||||||
if (fcoe_percpu[idx]) {
|
pp = &per_cpu(fcoe_percpu, cpu);
|
||||||
pp = fcoe_percpu[idx];
|
|
||||||
spin_lock_bh(&pp->fcoe_rx_list.lock);
|
spin_lock_bh(&pp->fcoe_rx_list.lock);
|
||||||
list = &pp->fcoe_rx_list;
|
list = &pp->fcoe_rx_list;
|
||||||
head = list->next;
|
head = list->next;
|
||||||
|
@ -1146,7 +1146,6 @@ void fcoe_percpu_clean(struct fc_lport *lp)
|
||||||
}
|
}
|
||||||
spin_unlock_bh(&pp->fcoe_rx_list.lock);
|
spin_unlock_bh(&pp->fcoe_rx_list.lock);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(fcoe_percpu_clean);
|
EXPORT_SYMBOL_GPL(fcoe_percpu_clean);
|
||||||
|
|
||||||
|
@ -1377,8 +1376,7 @@ static int __init fcoe_init(void)
|
||||||
#endif /* CONFIG_HOTPLUG_CPU */
|
#endif /* CONFIG_HOTPLUG_CPU */
|
||||||
|
|
||||||
for_each_possible_cpu(cpu) {
|
for_each_possible_cpu(cpu) {
|
||||||
p = fcoe_percpu[cpu];
|
p = &per_cpu(fcoe_percpu, cpu);
|
||||||
p->cpu = cpu;
|
|
||||||
skb_queue_head_init(&p->fcoe_rx_list);
|
skb_queue_head_init(&p->fcoe_rx_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1386,24 +1384,19 @@ static int __init fcoe_init(void)
|
||||||
* initialize per CPU interrupt thread
|
* initialize per CPU interrupt thread
|
||||||
*/
|
*/
|
||||||
for_each_online_cpu(cpu) {
|
for_each_online_cpu(cpu) {
|
||||||
p = kzalloc(sizeof(struct fcoe_percpu_s), GFP_KERNEL);
|
p = &per_cpu(fcoe_percpu, cpu);
|
||||||
if (p) {
|
|
||||||
p->thread = kthread_create(fcoe_percpu_receive_thread,
|
p->thread = kthread_create(fcoe_percpu_receive_thread,
|
||||||
(void *)p,
|
(void *)p, "fcoethread/%d", cpu);
|
||||||
"fcoethread/%d", cpu);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if there is no error then bind the thread to the cpu
|
* If there is no error then bind the thread to the CPU
|
||||||
* initialize the semaphore and skb queue head
|
* and wake it up.
|
||||||
*/
|
*/
|
||||||
if (likely(!IS_ERR(p->thread))) {
|
if (!IS_ERR(p->thread)) {
|
||||||
fcoe_percpu[cpu] = p;
|
|
||||||
kthread_bind(p->thread, cpu);
|
kthread_bind(p->thread, cpu);
|
||||||
wake_up_process(p->thread);
|
wake_up_process(p->thread);
|
||||||
} else {
|
} else {
|
||||||
fcoe_percpu[cpu] = NULL;
|
p->thread = NULL;
|
||||||
kfree(p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1432,7 +1425,7 @@ module_init(fcoe_init);
|
||||||
*/
|
*/
|
||||||
static void __exit fcoe_exit(void)
|
static void __exit fcoe_exit(void)
|
||||||
{
|
{
|
||||||
u32 idx;
|
unsigned int cpu;
|
||||||
struct fcoe_softc *fc, *tmp;
|
struct fcoe_softc *fc, *tmp;
|
||||||
struct fcoe_percpu_s *p;
|
struct fcoe_percpu_s *p;
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
|
@ -1454,17 +1447,16 @@ static void __exit fcoe_exit(void)
|
||||||
list_for_each_entry_safe(fc, tmp, &fcoe_hostlist, list)
|
list_for_each_entry_safe(fc, tmp, &fcoe_hostlist, list)
|
||||||
fcoe_transport_release(fc->real_dev);
|
fcoe_transport_release(fc->real_dev);
|
||||||
|
|
||||||
for (idx = 0; idx < NR_CPUS; idx++) {
|
for_each_possible_cpu(cpu) {
|
||||||
if (fcoe_percpu[idx]) {
|
p = &per_cpu(fcoe_percpu, cpu);
|
||||||
kthread_stop(fcoe_percpu[idx]->thread);
|
if (p->thread) {
|
||||||
p = fcoe_percpu[idx];
|
kthread_stop(p->thread);
|
||||||
spin_lock_bh(&p->fcoe_rx_list.lock);
|
spin_lock_bh(&p->fcoe_rx_list.lock);
|
||||||
while ((skb = __skb_dequeue(&p->fcoe_rx_list)) != NULL)
|
while ((skb = __skb_dequeue(&p->fcoe_rx_list)) != NULL)
|
||||||
kfree_skb(skb);
|
kfree_skb(skb);
|
||||||
spin_unlock_bh(&p->fcoe_rx_list.lock);
|
spin_unlock_bh(&p->fcoe_rx_list.lock);
|
||||||
if (fcoe_percpu[idx]->crc_eof_page)
|
if (p->crc_eof_page)
|
||||||
put_page(fcoe_percpu[idx]->crc_eof_page);
|
put_page(p->crc_eof_page);
|
||||||
kfree(fcoe_percpu[idx]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
* this percpu struct for fcoe
|
* this percpu struct for fcoe
|
||||||
*/
|
*/
|
||||||
struct fcoe_percpu_s {
|
struct fcoe_percpu_s {
|
||||||
unsigned int cpu;
|
|
||||||
struct task_struct *thread;
|
struct task_struct *thread;
|
||||||
struct sk_buff_head fcoe_rx_list;
|
struct sk_buff_head fcoe_rx_list;
|
||||||
struct page *crc_eof_page;
|
struct page *crc_eof_page;
|
||||||
|
|
Loading…
Reference in a new issue