[openib-general] [PATCH] ib_addr: remove exported rdma_wq
Krishna Kumar2
krkumar2 at in.ibm.com
Mon Mar 27 21:59:57 PST 2006
Sean,
Changing the name wq in each file to addr_wq, cma_wq, sa_wq makes it
easier to
understand as to which wq we are adding the entry (and for cscope too).
Thanks,
- KK
openib-general-bounces at openib.org wrote on 03/28/2006 05:46:20 AM:
> Move rdma_wq internal to ib_addr. Give the RDMA CM and local SA their
> own work queues.
>
> The work queues are single threaded, but this is more an attempt to
reduce
> system resources, then a need to provide strict serialization. We can
examine
> using kernel provided work queue.
>
> Signed-off-by: Sean Hefty <sean.hefty at intel.com>
>
> ---
>
> Index: include/rdma/ib_addr.h
> ===================================================================
> --- include/rdma/ib_addr.h (revision 6042)
> +++ include/rdma/ib_addr.h (working copy)
> @@ -36,8 +36,6 @@
> #include <linux/socket.h>
> #include <rdma/ib_verbs.h>
>
> -extern struct workqueue_struct *rdma_wq;
> -
> struct rdma_dev_addr {
> unsigned char src_dev_addr[MAX_ADDR_LEN];
> unsigned char dst_dev_addr[MAX_ADDR_LEN];
> Index: core/addr.c
> ===================================================================
> --- core/addr.c (revision 6042)
> +++ core/addr.c (working copy)
> @@ -85,8 +85,7 @@ static void process_req(void *data);
> static DEFINE_MUTEX(lock);
> static LIST_HEAD(req_list);
> static DECLARE_WORK(work, process_req, NULL);
> -struct workqueue_struct *rdma_wq;
> -EXPORT_SYMBOL(rdma_wq);
> +static struct workqueue_struct *wq;
>
> static int copy_addr(struct rdma_dev_addr *dev_addr, struct net_device
*dev,
> unsigned char *dst_dev_addr)
> @@ -135,7 +134,7 @@ static void set_timeout(unsigned long ti
> if ((long)delay <= 0)
> delay = 1;
>
> - queue_delayed_work(rdma_wq, &work, delay);
> + queue_delayed_work(wq, &work, delay);
> }
>
> static void queue_req(struct addr_req *req)
> @@ -376,8 +375,8 @@ static struct packet_type addr_arp = {
>
> static int addr_init(void)
> {
> - rdma_wq = create_singlethread_workqueue("rdma_wq");
> - if (!rdma_wq)
> + wq = create_singlethread_workqueue("ib_addr_wq");
> + if (!wq)
> return -ENOMEM;
>
> dev_add_pack(&addr_arp);
> @@ -387,7 +386,7 @@ static int addr_init(void)
> static void addr_cleanup(void)
> {
> dev_remove_pack(&addr_arp);
> - destroy_workqueue(rdma_wq);
> + destroy_workqueue(wq);
> }
>
> module_init(addr_init);
> Index: core/local_sa.c
> ===================================================================
> --- core/local_sa.c (revision 6042)
> +++ core/local_sa.c (working copy)
> @@ -37,7 +37,6 @@
> #include <linux/mutex.h>
> #include <linux/pci.h>
>
> -#include <rdma/ib_addr.h>
> #include <rdma/ib_cache.h>
> #include <rdma/ib_local_sa.h>
>
> @@ -78,6 +77,7 @@ static struct ib_client sa_db_client = {
> static LIST_HEAD(dev_list);
> static DEFINE_MUTEX(lock);
> static unsigned long hold_time, update_delay;
> +static struct workqueue_struct *wq;
>
> struct sa_db_port {
> struct sa_db_device *dev;
> @@ -285,7 +283,7 @@ static void update_cache(void *data)
> * update if an event occurs while we're still processing this one.
> */
> port->update_time = jiffies;
> - queue_delayed_work(rdma_wq, &port->work, cache_timeout);
> + queue_delayed_work(wq, &port->work, cache_timeout);
> }
>
> static void schedule_update(struct sa_db_port *port)
> @@ -302,7 +300,7 @@ static void schedule_update(struct sa_db
> delay = port->update_time + hold_time - time;
>
> cancel_delayed_work(&port->work);
> - queue_delayed_work(rdma_wq, &port->work, delay);
> + queue_delayed_work(wq, &port->work, delay);
> }
>
> static void handle_event(struct ib_event_handler *event_handler,
> @@ -427,7 +425,7 @@ static void sa_db_remove_one(struct ib_d
> ib_unregister_event_handler(&dev->event_handler);
> for (i = 0; i < device->phys_port_cnt; i++)
> cancel_delayed_work(&dev->port[i].work);
> - flush_workqueue(rdma_wq);
> + flush_workqueue(wq);
>
> for (i = 0; i < device->phys_port_cnt; i++) {
> ib_unregister_mad_agent(dev->port[i].agent);
> @@ -443,15 +441,30 @@ static void sa_db_remove_one(struct ib_d
>
> static int __init sa_db_init(void)
> {
> + int ret;
> +
> cache_timeout = msecs_to_jiffies(cache_timeout);
> hold_time = msecs_to_jiffies(hold_time);
> update_delay = msecs_to_jiffies(update_delay);
> - return ib_register_client(&sa_db_client);
> +
> + wq = create_singlethread_workqueue("local_sa_wq");
> + if (!wq)
> + return -ENOMEM;
> +
> + ret = ib_register_client(&sa_db_client);
> + if (ret)
> + goto err;
> + return 0;
> +
> +err:
> + destroy_workqueue(wq);
> + return ret;
> }
>
> static void __exit sa_db_cleanup(void)
> {
> ib_unregister_client(&sa_db_client);
> + destroy_workqueue(wq);
> }
>
> module_init(sa_db_init);
> Index: core/cma.c
> ===================================================================
> --- core/cma.c (revision 6042)
> +++ core/cma.c (working copy)
> @@ -64,6 +64,7 @@ static struct ib_client cma_client = {
> static LIST_HEAD(dev_list);
> static LIST_HEAD(listen_any_list);
> static DEFINE_MUTEX(lock);
> +static struct workqueue_struct *wq;
>
> struct cma_device {
> struct list_head list;
> @@ -1134,7 +1135,7 @@ static int cma_resolve_ib_route(struct r
> work->old_state = CMA_ROUTE_QUERY;
> work->new_state = CMA_ROUTE_RESOLVED;
> work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
> - queue_work(rdma_wq, &work->work);
> + queue_work(wq, &work->work);
> return 0;
> err2:
> kfree(route->path_rec);
> @@ -1273,7 +1274,7 @@ static int cma_resolve_loopback(struct r
> work->old_state = CMA_ADDR_QUERY;
> work->new_state = CMA_ADDR_RESOLVED;
> work->event.event = RDMA_CM_EVENT_ADDR_RESOLVED;
> - queue_work(rdma_wq, &work->work);
> + queue_work(wq, &work->work);
> return 0;
> err:
> kfree(work);
> @@ -1687,12 +1688,26 @@ static void cma_remove_one(struct ib_dev
>
> static int cma_init(void)
> {
> - return ib_register_client(&cma_client);
> + int ret;
> +
> + wq = create_singlethread_workqueue("rdma_cm_wq");
> + if (!wq)
> + return -ENOMEM;
> +
> + ret = ib_register_client(&cma_client);
> + if (ret)
> + goto err;
> + return 0;
> +
> +err:
> + destroy_workqueue(wq);
> + return ret;
> }
>
> static void cma_cleanup(void)
> {
> ib_unregister_client(&cma_client);
> + destroy_workqueue(wq);
> }
>
> module_init(cma_init);
>
> _______________________________________________
> openib-general mailing list
> openib-general at openib.org
> http://openib.org/mailman/listinfo/openib-general
>
> To unsubscribe, please visit
http://openib.org/mailman/listinfo/openib-general
More information about the general
mailing list