mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] IB/ipoib: optimized the function ipoib_mcast_alloc
@ 2015-11-01  6:23 Saurabh Sengar
  2015-11-02 10:08 ` Erez Shitrit
  0 siblings, 1 reply; 2+ messages in thread
From: Saurabh Sengar @ 2015-11-01  6:23 UTC (permalink / raw)
  To: sean.hefty, hal.rosenstock, roland, ogerlitz, jgunthorpe, cl,
	linux-rdma, linux-kernel
  Cc: Saurabh Sengar

ipoib_mcast_alloc is called only in atomic context,
hence removing the extra check.

Signed-off-by: Saurabh Sengar <saurabh.truth@gmail.com>
---
Hi, 
Even if in future, if there are some functions expected to call it in normal context(not atomic),
we can pass the GFP_KERNEL or GFP_ATOMIC directly to function call instead of passing 0 and 1,
which later again need to be compared in order to change it to GFP_KERNEL and GFP_ATOMIC.
Please let me know if there are better ways to improve it.

 drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index d750a86..15d35be 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -132,12 +132,11 @@ void ipoib_mcast_free(struct ipoib_mcast *mcast)
 	kfree(mcast);
 }
 
-static struct ipoib_mcast *ipoib_mcast_alloc(struct net_device *dev,
-					     int can_sleep)
+static struct ipoib_mcast *ipoib_mcast_alloc(struct net_device *dev)
 {
 	struct ipoib_mcast *mcast;
 
-	mcast = kzalloc(sizeof *mcast, can_sleep ? GFP_KERNEL : GFP_ATOMIC);
+	mcast = kzalloc(sizeof *mcast, GFP_ATOMIC);
 	if (!mcast)
 		return NULL;
 
@@ -573,7 +572,7 @@ void ipoib_mcast_join_task(struct work_struct *work)
 	if (!priv->broadcast) {
 		struct ipoib_mcast *broadcast;
 
-		broadcast = ipoib_mcast_alloc(dev, 0);
+		broadcast = ipoib_mcast_alloc(dev);
 		if (!broadcast) {
 			ipoib_warn(priv, "failed to allocate broadcast group\n");
 			/*
@@ -728,7 +727,7 @@ void ipoib_mcast_send(struct net_device *dev, u8 *daddr, struct sk_buff *skb)
 			ipoib_dbg_mcast(priv, "setting up send only multicast group for %pI6\n",
 					mgid);
 
-			mcast = ipoib_mcast_alloc(dev, 0);
+			mcast = ipoib_mcast_alloc(dev);
 			if (!mcast) {
 				ipoib_warn(priv, "unable to allocate memory "
 					   "for multicast structure\n");
@@ -886,7 +885,7 @@ void ipoib_mcast_restart_task(struct work_struct *work)
 			ipoib_dbg_mcast(priv, "adding multicast entry for mgid %pI6\n",
 					mgid.raw);
 
-			nmcast = ipoib_mcast_alloc(dev, 0);
+			nmcast = ipoib_mcast_alloc(dev);
 			if (!nmcast) {
 				ipoib_warn(priv, "unable to allocate memory for multicast structure\n");
 				continue;
-- 
1.9.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] IB/ipoib: optimized the function ipoib_mcast_alloc
  2015-11-01  6:23 [PATCH] IB/ipoib: optimized the function ipoib_mcast_alloc Saurabh Sengar
@ 2015-11-02 10:08 ` Erez Shitrit
  0 siblings, 0 replies; 2+ messages in thread
From: Erez Shitrit @ 2015-11-02 10:08 UTC (permalink / raw)
  To: Saurabh Sengar
  Cc: sean.hefty, hal.rosenstock, Roland Dreier, Or Gerlitz,
	Jason Gunthorpe, cl, linux-rdma, linux-kernel

On Sun, Nov 1, 2015 at 8:23 AM, Saurabh Sengar <saurabh.truth@gmail.com> wrote:
> ipoib_mcast_alloc is called only in atomic context,
> hence removing the extra check.
>
> Signed-off-by: Saurabh Sengar <saurabh.truth@gmail.com>

Acked-by: Erez Shitrit <erezsh@mellanox.com>

> ---
> Hi,
> Even if in future, if there are some functions expected to call it in normal context(not atomic),
> we can pass the GFP_KERNEL or GFP_ATOMIC directly to function call instead of passing 0 and 1,
> which later again need to be compared in order to change it to GFP_KERNEL and GFP_ATOMIC.
> Please let me know if there are better ways to improve it.
>
>  drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
> index d750a86..15d35be 100644
> --- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
> +++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
> @@ -132,12 +132,11 @@ void ipoib_mcast_free(struct ipoib_mcast *mcast)
>         kfree(mcast);
>  }
>
> -static struct ipoib_mcast *ipoib_mcast_alloc(struct net_device *dev,
> -                                            int can_sleep)
> +static struct ipoib_mcast *ipoib_mcast_alloc(struct net_device *dev)
>  {
>         struct ipoib_mcast *mcast;
>
> -       mcast = kzalloc(sizeof *mcast, can_sleep ? GFP_KERNEL : GFP_ATOMIC);
> +       mcast = kzalloc(sizeof *mcast, GFP_ATOMIC);
>         if (!mcast)
>                 return NULL;
>
> @@ -573,7 +572,7 @@ void ipoib_mcast_join_task(struct work_struct *work)
>         if (!priv->broadcast) {
>                 struct ipoib_mcast *broadcast;
>
> -               broadcast = ipoib_mcast_alloc(dev, 0);
> +               broadcast = ipoib_mcast_alloc(dev);
>                 if (!broadcast) {
>                         ipoib_warn(priv, "failed to allocate broadcast group\n");
>                         /*
> @@ -728,7 +727,7 @@ void ipoib_mcast_send(struct net_device *dev, u8 *daddr, struct sk_buff *skb)
>                         ipoib_dbg_mcast(priv, "setting up send only multicast group for %pI6\n",
>                                         mgid);
>
> -                       mcast = ipoib_mcast_alloc(dev, 0);
> +                       mcast = ipoib_mcast_alloc(dev);
>                         if (!mcast) {
>                                 ipoib_warn(priv, "unable to allocate memory "
>                                            "for multicast structure\n");
> @@ -886,7 +885,7 @@ void ipoib_mcast_restart_task(struct work_struct *work)
>                         ipoib_dbg_mcast(priv, "adding multicast entry for mgid %pI6\n",
>                                         mgid.raw);
>
> -                       nmcast = ipoib_mcast_alloc(dev, 0);
> +                       nmcast = ipoib_mcast_alloc(dev);
>                         if (!nmcast) {
>                                 ipoib_warn(priv, "unable to allocate memory for multicast structure\n");
>                                 continue;
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-02 10:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-01  6:23 [PATCH] IB/ipoib: optimized the function ipoib_mcast_alloc Saurabh Sengar
2015-11-02 10:08 ` Erez Shitrit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome