From patchwork Sun Nov 1 06:23:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: saurabh X-Patchwork-Id: 7531561 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1F47ABEEA4 for ; Sun, 1 Nov 2015 06:24:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 151DB2074A for ; Sun, 1 Nov 2015 06:24:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0654320749 for ; Sun, 1 Nov 2015 06:24:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751126AbbKAGYj (ORCPT ); Sun, 1 Nov 2015 01:24:39 -0500 Received: from mail-pa0-f65.google.com ([209.85.220.65]:33012 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750874AbbKAGYi (ORCPT ); Sun, 1 Nov 2015 01:24:38 -0500 Received: by padfb7 with SMTP id fb7so12858953pad.0; Sat, 31 Oct 2015 23:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=MBncBFp/T6iE/JvHKfT//Gjg4IdRdenhHDKhGgl1UtU=; b=xfNgc1rWtrH9SlkCn07DfjtO2nkaooWt57z4IgRwhKHyCrVM2wJkiL/HBoti0doIct T7lH1f+XtbWNqwD+f6T+J5lf13JEnah/QfvusRRTSlQ6OywM6m9QWnNVouFtBHsXaKTV RtbiP/J6x+dTLIWXlteywaC0o0lCcRj2J3rqpLlC6JuB+kjW2F3sPB1yQDC7rtboZ6vX 5hSxFYLBY9/TlvF1eUNUEytNDbuQA7QN+qHqGhkWeHo44YUsPb+03Blo7jU8ZdImZwuA m54MBtGZqYSUK2accm5IhrwRJR6aCVohNL9wN8VhYWsOcoxOdcsAZEQo0Q2BMakxmKFi 1sLA== X-Received: by 10.67.5.193 with SMTP id co1mr18356650pad.134.1446359077983; Sat, 31 Oct 2015 23:24:37 -0700 (PDT) Received: from localhost.localdomain ([122.175.26.87]) by smtp.gmail.com with ESMTPSA id ea5sm16892679pbc.92.2015.10.31.23.24.34 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 31 Oct 2015 23:24:37 -0700 (PDT) From: Saurabh Sengar To: sean.hefty@intel.com, hal.rosenstock@gmail.com, roland@purestorage.com, ogerlitz@mellanox.com, jgunthorpe@obsidianresearch.com, cl@linux.com, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Saurabh Sengar Subject: [PATCH] IB/ipoib: optimized the function ipoib_mcast_alloc Date: Sun, 1 Nov 2015 11:53:49 +0530 Message-Id: <1446359029-6261-1-git-send-email-saurabh.truth@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ipoib_mcast_alloc is called only in atomic context, hence removing the extra check. Signed-off-by: Saurabh Sengar Acked-by: Erez Shitrit --- 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;